From scipy-svn at scipy.org Tue Jan 2 09:23:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 08:23:13 -0600 (CST) Subject: [Scipy-svn] r2469 - trunk/Lib/sandbox/maskedarray Message-ID: <20070102142313.49C9C39C055@new.scipy.org> Author: pierregm Date: 2007-01-02 08:23:02 -0600 (Tue, 02 Jan 2007) New Revision: 2469 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/__init__.py trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/testutils.py Log: Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2006-12-30 20:59:39 UTC (rev 2468) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-02 14:23:02 UTC (rev 2469) @@ -1,5 +1,6 @@ #2006-12-30 : Core # : - Cleaned up setitem/setslice w/ hard_mask=True +# : - Fixed masked_unary/binary_operations to work with subclasses of MaskedArray #2006-12-22 : Core # : - Optimized(?) default_/maximum_/minimum_fill_value # : - Force __new__ to not return a MaskedArray, in order to ... Modified: trunk/Lib/sandbox/maskedarray/__init__.py =================================================================== --- trunk/Lib/sandbox/maskedarray/__init__.py 2006-12-30 20:59:39 UTC (rev 2468) +++ trunk/Lib/sandbox/maskedarray/__init__.py 2007-01-02 14:23:02 UTC (rev 2469) @@ -12,11 +12,11 @@ __date__ = '$Date$' import core -reload(core) +#reload(core) from core import * import extras -reload(extras) +#reload(extras) from extras import * Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2006-12-30 20:59:39 UTC (rev 2468) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-02 14:23:02 UTC (rev 2469) @@ -73,7 +73,7 @@ import warnings import logging -logging.basicConfig(level=logging.CRITICAL, +logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) @@ -123,6 +123,7 @@ "Class for MA related errors." def __init__ (self, args=None): "Creates an exception." + Exception.__init__(self,args) self.args = args def __str__(self): "Calculates the string representation." @@ -191,7 +192,7 @@ elif isinstance(obj, float): return max_filler['f'] elif isinstance(obj, int) or isinstance(obj, long): - #TODO: Check what happens to 'UnisgnedInteger'! + #TODO: Check what happens to 'UnsignedInteger'! return max_filler['i'] else: raise TypeError, 'Unsuitable type for calculating maximum.' @@ -326,10 +327,11 @@ m = getmask(a) d1 = filled(a, self.fill) if self.domain is not None: - m = mask_or(m, self.domain(d1)) + m = mask_or(m, numeric.asarray(self.domain(d1))) result = self.f(d1, *args, **kwargs) - if isinstance(a, MaskedArray): - return a.__class__(result, mask=m) + # + if isinstance(result, MaskedArray): + return result.__class__(result, mask=m) return masked_array(result, mask=m) # def __str__ (self): @@ -457,13 +459,15 @@ mb = getmask(b) d1 = filled(a, self.fillx) d2 = filled(b, self.filly) - t = self.domain(d1, d2) + t = numeric.asarray(self.domain(d1, d2)) if fromnumeric.sometrue(t, None): d2 = numeric.where(t, self.filly, d2) mb = mask_or(mb, t) m = mask_or(ma, mb) result = self.f(d1, d2) + if isinstance(result, MaskedArray): + return result.__class__(result, mask=m) return masked_array(result, mask=m) def __str__ (self): @@ -773,7 +777,7 @@ #####-------------------------------------------------------------------------- #---- --- MaskedArray class --- #####-------------------------------------------------------------------------- -class MaskedArray(numeric.ndarray, object): +class MaskedArray(numeric.ndarray): """Arrays with possibly masked values. Masked values of True exclude the corresponding element from any computation. @@ -802,7 +806,7 @@ """ __array_priority__ = 10.1 #TODO: There some reorganization to do round here - def __new__(cls, data, mask=nomask, dtype=None, copy=False, fill_value=None, + def __new__(cls, data=None, mask=nomask, dtype=None, copy=False, fill_value=None, keep_mask=True, small_mask=True, hard_mask=False): """array(data, dtype=None, copy=True, mask=nomask, fill_value=None) @@ -875,6 +879,10 @@ cls._defaulthardmask = hard_mask cls._defaultmask = mask # logging.debug("__new__ returned %s as %s" % (type(_data), cls)) +# data = numeric.ndarray.__new__(cls, shape=_data.shape,dtype=_data.dtype, +# buffer=_data.data, offset=0) +# print type(data), data.shape +# return data return numeric.asanyarray(_data).view(cls) #.................................. def __array_wrap__(self, obj, context=None): @@ -915,7 +923,8 @@ """ # # logging.debug("__finalize__ received %s" % type(obj)) - if isMaskedArray(obj): + if isinstance(obj, MaskedArray): +# if isMaskedArray(obj): self._data = obj._data self._mask = obj._mask self._hardmask = obj._hardmask @@ -1499,7 +1508,7 @@ flatsize = self.size self._data.resize((flatsize,)) if self.mask is not nomask: - self._mask.resize((flatsize,)) + self._mask.resize((flatsize,)) return self # @@ -1902,8 +1911,16 @@ self.fill_self = fill_self self.fill_other = fill_other self.domain = domain - self.__doc__ = getattr(methodname, '__doc__') + self.obj = None + self.__doc__ = self.getdoc() # + def getdoc(self): + "Returns the doc of the function (from the doc of the method)." + try: + return getattr(MaskedArray, self.methodname).__doc__ + except: + return getattr(numpy, self.methodname).__doc__ + # def __get__(self, obj, objtype=None): self.obj = obj return self @@ -1957,7 +1974,16 @@ self.methodname = methodname self.fill_self = fill_self self.fill_other = fill_other + self.obj = None + self.__doc__ = self.getdoc() # + def getdoc(self): + "Returns the doc of the function (from the doc of the method)." + try: + return getattr(MaskedArray, self.methodname).__doc__ + except: + return getattr(numpy, self.methodname).__doc__ + # def __get__(self, obj, objtype=None): self.obj = obj return self @@ -2098,16 +2124,20 @@ def __init__(self, funcname, onmask=True): self._name = funcname self._onmask = onmask + self.obj = None self.__doc__ = self.getdoc() + # def getdoc(self): "Returns the doc of the function (from the doc of the method)." try: return getattr(MaskedArray, self._name).__doc__ except: return getattr(numpy, self._name).__doc__ + # def __get__(self, obj, objtype=None): self.obj = obj return self + # def __call__(self, *args, **params): methodname = self._name (d, m) = (self.obj._data, self.obj._mask) @@ -2125,7 +2155,7 @@ dtype=t, fill_value=f) #...................................... MaskedArray.conj = MaskedArray.conjugate = _arraymethod('conjugate') -MaskedArray.copy = MaskedArray.conjugate = _arraymethod('copy') +MaskedArray.copy = _arraymethod('copy') MaskedArray.diagonal = _arraymethod('diagonal') MaskedArray.take = _arraymethod('take') MaskedArray.ravel = _arraymethod('ravel') @@ -2838,3 +2868,4 @@ MaskedArray.__dump__ = dump MaskedArray.__dumps__ = dumps + Modified: trunk/Lib/sandbox/maskedarray/testutils.py =================================================================== --- trunk/Lib/sandbox/maskedarray/testutils.py 2006-12-30 20:59:39 UTC (rev 2468) +++ trunk/Lib/sandbox/maskedarray/testutils.py 2007-01-02 14:23:02 UTC (rev 2469) @@ -17,7 +17,6 @@ from numpy.testing.utils import build_err_msg, rand import core -#reload(core) from core import mask_or, getmask, getmaskarray, masked_array, nomask from core import filled, equal, less From scipy-svn at scipy.org Tue Jan 2 10:31:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 09:31:33 -0600 (CST) Subject: [Scipy-svn] r2470 - trunk/Lib/sandbox/timeseries Message-ID: <20070102153133.BD91639C05D@new.scipy.org> Author: mattknox_ca Date: 2007-01-02 09:31:29 -0600 (Tue, 02 Jan 2007) New Revision: 2470 Modified: trunk/Lib/sandbox/timeseries/timeseries.py Log: fixed bug with series of type date losing their data type when performing operations on them Modified: trunk/Lib/sandbox/timeseries/timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-02 14:23:02 UTC (rev 2469) +++ trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-02 15:31:29 UTC (rev 2470) @@ -45,9 +45,15 @@ ts_compatible(a, b) return TimeSeries(self.f(a, b, *args, **kwargs), freq=a.freq, observed=a.observed, start_date=a.start_date()) elif isinstance(a, TimeSeries): - return TimeSeries(self.f(a, b, *args, **kwargs), freq=a.freq, observed=a.observed, start_date=a.start_date()) + if corelib.isDateType(a.tstype): + return TimeSeries(self.f(a, b, *args, **kwargs), dtype=a.tstype, freq=a.freq, observed=a.observed, start_date=a.start_date()) + else: + return TimeSeries(self.f(a, b, *args, **kwargs), freq=a.freq, observed=a.observed, start_date=a.start_date()) elif isinstance(b, TimeSeries): - return TimeSeries(self.f(a, b, *args, **kwargs), freq=b.freq, observed=b.observed, start_date=b.start_date()) + if corelib.isDateType(b.tstype): + return TimeSeries(self.f(a, b, *args, **kwargs), dtype=b.tstype, freq=b.freq, observed=b.observed, start_date=b.start_date()) + else: + return TimeSeries(self.f(a, b, *args, **kwargs), freq=b.freq, observed=b.observed, start_date=b.start_date()) else: return self.f(a, b, *args, **kwargs) From scipy-svn at scipy.org Tue Jan 2 12:09:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 11:09:38 -0600 (CST) Subject: [Scipy-svn] r2471 - in trunk/Lib/sandbox/timeseries: . plotlib Message-ID: <20070102170938.29A8539C01D@new.scipy.org> Author: mattknox_ca Date: 2007-01-02 11:09:32 -0600 (Tue, 02 Jan 2007) New Revision: 2471 Added: trunk/Lib/sandbox/timeseries/plotlib/ trunk/Lib/sandbox/timeseries/plotlib/__init__.py trunk/Lib/sandbox/timeseries/plotlib/__init__.pyc trunk/Lib/sandbox/timeseries/plotlib/plot.py trunk/Lib/sandbox/timeseries/plotlib/plot.pyc Log: Added a folder remotely Added: trunk/Lib/sandbox/timeseries/plotlib/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/__init__.py 2007-01-02 15:31:29 UTC (rev 2470) +++ trunk/Lib/sandbox/timeseries/plotlib/__init__.py 2007-01-02 17:09:32 UTC (rev 2471) @@ -0,0 +1 @@ +from plot import * \ No newline at end of file Added: trunk/Lib/sandbox/timeseries/plotlib/__init__.pyc =================================================================== (Binary files differ) Property changes on: trunk/Lib/sandbox/timeseries/plotlib/__init__.pyc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Lib/sandbox/timeseries/plotlib/plot.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/plot.py 2007-01-02 15:31:29 UTC (rev 2470) +++ trunk/Lib/sandbox/timeseries/plotlib/plot.py 2007-01-02 17:09:32 UTC (rev 2471) @@ -0,0 +1,230 @@ +import pylab as pl +import timeseries as ts +from matplotlib.ticker import FixedLocator, FuncFormatter +import numpy as np +import types + + +class DateAxis: + def __init__(self, start_date, end_date): + + freq = start_date.freq + numPers = end_date - start_date + 1 + + self.xaxis = np.arange(numPers) + self.xlabel_txt = '' + + tser = ts.tser(start_date, end_date) + + minor_labels = ['' for x in range(numPers)] + major_labels = ['' for x in range(numPers)] + + minor_ticks = [] + major_ticks = [] + + years = ts.year(tser) + year_starts = (years - ts.year(tser-1) != 0) + year_start_inds = [int(x) for x in np.where(year_starts)[0]] + + quarters = ts.quarter(tser) + quarter_starts = (quarters - ts.quarter(tser-1) != 0) + quarter_start_inds = [int(x) for x in np.where(quarter_starts)[0]] + + months = ts.month(tser) + month_starts = (months - ts.month(tser-1) != 0) + month_start_inds = [int(x) for x in np.where(month_starts)[0]] + + + def yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks): + + numYears = end_date.year() - start_date.year() + + if numYears < 20: minor_spacing, major_spacing = 1, 2 + elif numYears < 50: minor_spacing, major_spacing = 1, 5 + elif numYears < 100: minor_spacing, major_spacing = 5, 10 + elif numYears < 200: minor_spacing, major_spacing = 5, 20 + elif numYears < 400: minor_spacing, major_spacing = 5, 25 + elif numYears < 1000: minor_spacing, major_spacing = 10, 50 + else: minor_spacing, major_spacing = 20, 100 + + for x in [y for y in year_start_inds if years[y] % minor_spacing == 0]: + minor_ticks += [x] + if years[x] % major_spacing == 0: + major_ticks += [x] + major_labels[x] += (start_date + x).strfmt('%Y') + + return minor_labels, major_labels, minor_ticks, major_ticks + + if freq == 'A': + minor_labels, major_labels, minor_ticks, major_ticks = \ + yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) + + elif freq == 'Q': + + if numPers <= 3 * 4: + + minor_ticks = list(range(numPers)) + major_ticks = year_start_inds + + for x in range(numPers): + minor_labels[x] = (start_date + x).strfmt('Q%q') + if year_starts[x]: + major_labels[x] += '\n\n'+(start_date + x).strfmt('%Y') + + elif numPers <= 11 * 12: + + minor_ticks = list(range(numPers)) + + for x in [y for y in quarter_start_inds if quarters[y] == 1]: + major_ticks += [x] + major_labels[x] += (start_date + x).strfmt('%Y') + + else: + + minor_labels, major_labels, minor_ticks, major_ticks = \ + yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) + + elif freq == 'M': + + if numPers <= 1.5 * 12: + + minor_ticks = list(range(numPers)) + major_ticks = year_start_inds + + for x in range(numPers): + minor_labels[x] = (start_date + x).strfmt('%b') + if year_starts[x]: + major_labels[x] += '\n\n'+(start_date + x).strfmt('%Y') + + elif numPers <= 3 * 12: + + minor_ticks = list(range(numPers)) + + for x in range(numPers): + + _date = start_date + x + if (_date.month() - 1) % 2 == 0: + minor_labels[x] += _date.strfmt('%b') + + if year_starts[x] == 1: + major_ticks += [x] + major_labels[x] += '\n\n'+_date.strfmt('%Y') + + elif numPers <= 11 * 12: + + minor_ticks = quarter_start_inds + + for x in [y for y in quarter_start_inds if quarters[y] == 1]: + major_ticks += [x] + major_labels[x] += (start_date + x).strfmt('%Y') + + else: + + minor_labels, major_labels, minor_ticks, major_ticks = \ + yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) + + elif freq in ('B', 'D'): + + if freq == 'B': daysInYear = 261 + else: daysInYear = 365 + + if numPers <= daysInYear // 3: + + if numPers < daysInYear // 12: spacing = 1 + else: spacing = 5 + + minor_ticks = list(range(numPers)) + major_ticks = [int(x) for x in month_start_inds] + + for x in range(numPers): + + _date = start_date + x + + if x % spacing == 0: minor_labels[x] = _date.strfmt('%d') + if month_starts[x]: + major_labels[x] += '\n\n'+_date.strfmt('%b') + major_ticks += [x] + + if year_starts[x]: + major_labels[x] += '\n'+_date.strfmt('%Y') + + elif numPers <= 1.5 * daysInYear: + + minor_ticks = list(range(numPers)) + major_ticks = month_start_inds + + for x in month_start_inds: + _date = start_date + x + major_labels[x] += _date.strfmt('%b') + if months[x] == 1: major_labels[x] += '\n'+_date.strfmt('%Y') + + elif numPers <= 3 * daysInYear: + + minor_ticks = month_start_inds + + for x in [y for y in month_start_inds if (months[y] - 1) % 3 == 0]: + + _date = start_date + x + minor_labels[x] += _date.strfmt('%b') + + if months[x] == 1: + major_ticks += [x] + major_labels[x] += '\n\n'+_date.strfmt('%Y') + + elif numPers <= 11 * daysInYear: + + minor_ticks = quarter_start_inds + + for x in [y for y in quarter_start_inds if quarters[y] == 1]: + major_ticks += [x] + major_labels[x] += (start_date + x).strfmt('%Y') + + else: + + minor_labels, major_labels, minor_ticks, major_ticks = \ + yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) + + else: + raise ValueError("unsupported frequency: "+freq) + + # if date range is such that no year or month is included in the labels, add these to the start + if years[0] == years[-1] and (start_date - 1).year() == start_date.year(): + + breaksBeforeYear = 2 + + if freq in ('B', 'D'): + if months[0] == months[-1] and (start_date - 1).month() == start_date.month(): + major_labels[0] += '\n\n'+start_date.strfmt('%b') + breaksBeforeYear = 1 + + if breaksBeforeYear > 1 and len([x for x in major_labels if x != '']) > 0: breaksBeforeYear += 1 + + major_labels[0] += ('\n' * breaksBeforeYear)+(start_date).strfmt('%Y') + + if 0 not in major_ticks: major_ticks = [0] + major_ticks + + self.major_labels = major_labels + self.major_locator = FixedLocator(major_ticks) + + self.minor_labels = minor_labels + self.minor_locator = FixedLocator(minor_ticks) + + def minor_formatter(self, x, pos): + if type(x) is types.IntType: + return self.minor_labels[x] + else: + return '' + + def major_formatter(self, x, pos): + if type(x) is types.IntType: + return self.major_labels[x] + else: + return '' + + + def set_labels(self, subplot): + subplot.xaxis.set_minor_locator(self.minor_locator) + subplot.xaxis.set_minor_formatter(FuncFormatter(self.minor_formatter)) + + subplot.xaxis.set_major_locator(self.major_locator) + subplot.xaxis.set_major_formatter(FuncFormatter(self.major_formatter)) Added: trunk/Lib/sandbox/timeseries/plotlib/plot.pyc =================================================================== (Binary files differ) Property changes on: trunk/Lib/sandbox/timeseries/plotlib/plot.pyc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From scipy-svn at scipy.org Tue Jan 2 12:10:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 11:10:57 -0600 (CST) Subject: [Scipy-svn] r2472 - trunk/Lib/sandbox/timeseries/plotlib Message-ID: <20070102171057.9C41139C01D@new.scipy.org> Author: mattknox_ca Date: 2007-01-02 11:10:56 -0600 (Tue, 02 Jan 2007) New Revision: 2472 Removed: trunk/Lib/sandbox/timeseries/plotlib/plot.pyc Log: Removed file/folder Deleted: trunk/Lib/sandbox/timeseries/plotlib/plot.pyc =================================================================== (Binary files differ) From scipy-svn at scipy.org Tue Jan 2 12:11:39 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 11:11:39 -0600 (CST) Subject: [Scipy-svn] r2473 - trunk/Lib/sandbox/timeseries/plotlib Message-ID: <20070102171139.E866439C053@new.scipy.org> Author: mattknox_ca Date: 2007-01-02 11:11:38 -0600 (Tue, 02 Jan 2007) New Revision: 2473 Removed: trunk/Lib/sandbox/timeseries/plotlib/__init__.pyc Log: Removed file/folder Deleted: trunk/Lib/sandbox/timeseries/plotlib/__init__.pyc =================================================================== (Binary files differ) From scipy-svn at scipy.org Tue Jan 2 12:25:17 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 11:25:17 -0600 (CST) Subject: [Scipy-svn] r2474 - trunk/Lib/sandbox/timeseries/examples Message-ID: <20070102172517.E105B39C06C@new.scipy.org> Author: mattknox_ca Date: 2007-01-02 11:24:58 -0600 (Tue, 02 Jan 2007) New Revision: 2474 Added: trunk/Lib/sandbox/timeseries/examples/plotting.py Log: Added a file remotely Added: trunk/Lib/sandbox/timeseries/examples/plotting.py =================================================================== --- trunk/Lib/sandbox/timeseries/examples/plotting.py 2007-01-02 17:11:38 UTC (rev 2473) +++ trunk/Lib/sandbox/timeseries/examples/plotting.py 2007-01-02 17:24:58 UTC (rev 2474) @@ -0,0 +1,28 @@ +import pylab as pl +import timeseries as ts +import timeseries.plotlib as tpl +import numpy as np + +numPoints = 100 +freq = 'b' + +y_ts1 = ts.TimeSeries(100*np.cumprod(1 + np.random.normal(size=numPoints)/100), freq=freq, start_date=ts.thisday(freq)-numPoints) +y_ts2 = ts.TimeSeries(100*np.cumprod(1 + np.random.normal(size=numPoints)/100), freq=freq, start_date=ts.thisday(freq)-numPoints) + +y_ts1, y_ts2 = ts.aligned(y_ts1, y_ts2) + +sDate, eDate = y_ts1.start_date(), y_ts1.end_date() +dAxis = tpl.DateAxis(sDate, eDate) + +pl.clf() + +a = pl.subplot(1,1,1) +a.plot(dAxis.xaxis, y_ts1, '-', dAxis.xaxis, y_ts2, '-') +dAxis.set_labels(a) + +#a.set_xlim(dAxis.xaxis[0], dAxis.xaxis[-1]) + +pl.title('Time Series Plot') +pl.show() + + From scipy-svn at scipy.org Tue Jan 2 12:39:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 11:39:24 -0600 (CST) Subject: [Scipy-svn] r2475 - trunk/Lib/sandbox/timeseries/plotlib Message-ID: <20070102173924.EC08239C051@new.scipy.org> Author: mattknox_ca Date: 2007-01-02 11:39:21 -0600 (Tue, 02 Jan 2007) New Revision: 2475 Modified: trunk/Lib/sandbox/timeseries/plotlib/plot.py Log: Modified: trunk/Lib/sandbox/timeseries/plotlib/plot.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/plot.py 2007-01-02 17:24:58 UTC (rev 2474) +++ trunk/Lib/sandbox/timeseries/plotlib/plot.py 2007-01-02 17:39:21 UTC (rev 2475) @@ -71,7 +71,7 @@ if year_starts[x]: major_labels[x] += '\n\n'+(start_date + x).strfmt('%Y') - elif numPers <= 11 * 12: + elif numPers <= 11 * 4: minor_ticks = list(range(numPers)) From scipy-svn at scipy.org Tue Jan 2 12:55:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 11:55:03 -0600 (CST) Subject: [Scipy-svn] r2476 - in trunk/Lib/sandbox/timeseries: . mtimeseries Message-ID: <20070102175503.7471D39C051@new.scipy.org> Author: pierregm Date: 2007-01-02 11:54:31 -0600 (Tue, 02 Jan 2007) New Revision: 2476 Added: trunk/Lib/sandbox/timeseries/mtimeseries/ trunk/Lib/sandbox/timeseries/mtimeseries/__init__.py trunk/Lib/sandbox/timeseries/mtimeseries/example.py trunk/Lib/sandbox/timeseries/mtimeseries/test_date.py trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py trunk/Lib/sandbox/timeseries/mtimeseries/tests/ trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py Log: support for maskedarray Property changes on: trunk/Lib/sandbox/timeseries/mtimeseries ___________________________________________________________________ Name: svn:ignore + test_timeseriesA.py tseriesA.py crapper Added: trunk/Lib/sandbox/timeseries/mtimeseries/__init__.py =================================================================== Added: trunk/Lib/sandbox/timeseries/mtimeseries/example.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/example.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/example.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,290 @@ + +""" +=== TimeSeries === + +A TimeSeries object is the combination of three ndarrays: + + - `dates`: DateArray object. + - `data` : ndarray. + - `mask` : Boolean ndarray, indicating missing or invalid data. + + +==== Construction ==== + +To construct a TimeSeries, you can use the class constructor: + +>>> TimeSeries(data, dates=None, mask=nomask, + freq=None, observed=None, start_date=None, + dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False) + +where `data` is a sequence. +If `dates` is None, a DateArray of the same length as the data is constructed at +a `freq` frequency, starting at `start_date`. + +Alternatively, you can use the `time_series` function: + + +time_series(data, dates=None, freq=None, + start_date=None, end_date=None, length=None, include_last=True, + mask=nomask, dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False) + + +Let us construct a series of 600 random elements, starting 600 business days ago, +at a business daily frequency + +>>> import numpy as np +>>> import tseries as ts +>>> import tsdate as td +>>> data = np.random.uniform(-100,100,600) +>>> today = td.thisday('B') +>>> series = ts.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', + start_date=today-600) + +Let us set negative values to zero... + +>>> series[series<0] = 0 + +... and the values falling on Fridays to 100 +>>> series[series.day_of_week == 4] = 100 + +Note that we could also create a temporary array of 'day_of weeks' for the +corresponding period, and use it as condition. + +>>> weekdays = td.day_of_week(series) +>>> series[weekdays == 4] = 100 + +==== Slicing ==== + +Accessing elements of a TimeSeries works just like slicing +>>> series[-30:] + +But you can also use a date: +>>> thirtydaysago = today-30 +>>> series[thirtydaysago:] + +Or even a string +>>> series[thirtydaysago.tostring():] + + +==== Conversions ==== + +To convert a TimeSeries to another frequency, use the `convert` method or function. +The optional argument `func` must be a function that acts on a 1D masked array +and returns a scalar. + +>>> mSer1 = series.convert('M',func=ma.average) + +If `func` is not specified, the default value `'auto'` is used instead. In that case, +the conversion function is estimated from the `observed` attribute of the series. +For example, if `observed='SUMMED'`, then `func='auto'` is in fact `func=sum`. + +>>> mSer1_default = series.convert('M') + +If `func` is None, the convert method/function returns a 2D array, where each row +corresponds to the new frequency, and the columns to the original data. In our +example, convert will return a 2D array with 23 columns, as there are at most +23 business days per month. + +>>> mSer1_2d = series.convert('M',func=None) + +When converting from a lower frequency to a higher frequency, an extra argument +`position` is required. The value of the argument is either 'START' or 'END', +and determines where the data point will be placed in the +period. In the future, interpolation methods will be supported to fill in the +resulting masked values. + +Let us create a second series, this time with a monthly frequency, starting 110 +months ago. +>>> data = np.random.uniform(-100,100,100).astype(np.float_) +>>> today = today.asfreq('M') - 110 +>>> mSer2 = ts.TimeSeries(data, freq='m', observed='END',start_date=today) +>>> sixtymonthsago = today-60 +>>> mSer2[sixtymonthsago:sixtymonthsago+10] = 12 + +""" +import numpy as np +import tseries as ts +reload(ts) +import tsdate as td +reload(td) +#from numpy import ma +import maskedarray as ma + +data = np.random.uniform(-100,100,600) +today = td.thisday('B') +series = ts.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', + start_date=today-600) +series[series < 0] = 0 + +#WARNING: The ORIGINAL day_of_week version seemed bugged. +#It told me that 2006/12/28 was a Friday. +weekdays = td.day_of_week(series) +series[weekdays == 4] = 100 + +mSer1 = series.convert('M',func=ma.average) +mSer1_2d = series.convert('M',func=None) +mSer1_default = series.convert('M') +mToB = series.convert('M',position='START') + + +# Create another monthly frequency series +data = np.random.uniform(-100,100,100).astype(np.float_) +today = today.asfreq('M') - 110 +mSer2 = ts.TimeSeries(data, freq='m', observed='END',start_date=today) +sixtymonthsago = today-60 +mSer2[sixtymonthsago:sixtymonthsago+10] = 12 + + +""" +==== Operations on TimeSeries ==== + +If you work with only one TimeSeries, you can use regular commands to process +the data. For example: + +>>> mSer2_log = np.log(mSer2) + +Note that invalid values (negative, in that case), are automatically masked. +Note as well that trying to use the maskedarray command directly is unlikely to +work: you would end up with a regular MaskedArray. + +When working with multiple series, only series of the same frequency, size and +starting date can be used in basic operations. The function `align_series` forces +series to have matching starting and ending dates. By default, the starting date +will be set to the smallest starting date of the series, and the ending date to +the largest. [An alias to `align_series` is aligned] + +Let's construct a list of months, starting on Jan 2005 and ending on Dec 2006, +with a gap from Oct 2005 to Dec 2006. + +>>> mlist = ['2005-%02i' % i for i in range(1,10)] +>>> mlist += ['2006-%02i' % i for i in range(2,13)] +>>> mdata = numpy.arange(len(mlist)) +>>> mser1 = time_series(mdata, mlist, observed='SUMMED') + +Note that the frequency is 'U', for undefined. In fact, you have to specify what +kind of data is actually missing by forcing a given frequency. + +>>> mser1 = mser1.asfreq('M') + +Let us check whether there are some duplicated dates (no): + +>>> mser1.has_duplicated_dates() + +...or missing dates (yes): + +>>> mser1.has_missing_dates() + +Let us construct a second monthly series, this time without missing dates + +>>> mlist2 = ['2004-%02i' % i for i in range(1,13)] +>>> mlist2 += ['2005-%02i' % i for i in range(1,13)] +>>> mser2 = time_series(mdata, mlist2, observed='SUMMED') + +Let's try to add the two series: + +>>> mser3 = mser1 + mser2 + +That doesn't work, as the series have different starting dates. We need to align +them first. + +>>> (malg1,malg2) = aligned(mser1, mser2) + +That still doesnt' work, as `malg1` has missing dates. Let us fill it, then: +data falling on a date that was missing will be masked. + +>>> mser1_filled = fill_missing_dates(mser1) +>>> (malg1,malg2) = align_series(mser1_filled, mser2) + +Now we can add the two series. Only the data that fall on dates common to the +original, non-aligned series will be actually added, the others will be masked. +After all, we are adding masked arrays. + +>>> mser3 = malg1 + malg2 + +We could have filled the initial series first: +>>> mser3 = filled(malg1,0) + filled(malg2,0) + +Alternatively, we can force the series to start/end at some given dates + +>>> (malg1,malg2) = aligned(mser1_filled, mser2, +>>> start_date='2004-06', end_date='2006-06') + +""" +mlist = ['2005-%02i' % i for i in range(1,10)] +mlist += ['2006-%02i' % i for i in range(2,13)] +mdata = np.arange(len(mlist)) +mser1 = ts.time_series(mdata, mlist, observed='SUMMED') +mser1 = mser1.asfreq('M') +# +mlist2 = ['2004-%02i' % i for i in range(1,13)] +mlist2 += ['2005-%02i' % i for i in range(1,13)] +mser2 = ts.time_series(np.arange(len(mlist2)), mlist2, observed='SUMMED') +# +mser1_filled = ts.fill_missing_dates(mser1) +(malg1,malg2) = ts.aligned(mser1_filled, mser2) +mser3 = malg1 + malg2 + +""" +# add the two series together, first filling in masked values with zeros +mAdd1_filled = mSer1.filled(fill_value=0, ts=True) + mSer2.filled(fill_value=0, ts=True) + +# adjust the start and end dates of a series +newSer = ts.adjust_endpoints(mSer1, start_date=td.Date(freq='M', year=1954, month=5), end_date=td.Date(freq='M', year=2000, month=6)) + +# calculate the average value in the series. Behaves the same as in ma +bAverage = ma.average(series) + + + + + +# Get the last day of this year, at daily frequency +dLastDayOfYear = td.dateOf(td.thisday('A'),'D','AFTER') + + +# Get the first day of this year, at business frequency +bFirstDayOfYear = td.dateOf(td.thisday('A'),'B','BEFORE') + +# Get the last day of the previous quarter, business frequency +bLastDayOfLastQuarter = td.dateOf(td.thisday('Q')-1,'B','AFTER') + +# dateOf can also go from high frequency to low frequency. In this case, the third parameter has no impact +aTrueValue = (td.thisday('Q') == td.dateOf(td.thisday('b'),'Q')) + +# Dates of the same frequency can be subtracted (but not added obviously) +numberOfBusinessDaysPassedThisYear = td.thisday('b') - bFirstDayOfYear + +# Integers can be added/substracted to/from dates +fiveDaysFromNow = td.thisday('d') + 5 + + +# Get the previous business day, where business day is considered to +# end at day_end_hour and day_end_min +pbd = td.prevbusday(day_end_hour=18,day_end_min=0) +""" +# ------------------------------------------------------------------------------ +""" +=== Date construction === +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 `mxDate` keyword with an existing mx.DateTime.DateTime object, or + even a datetime.datetime object. + + >>> td.Date('D', mxDate=mx.DateTime.now()) + >>> td.Date('D', mxDate=datetime.datetime.now()) +""" + +# Construct a sequence of dates at a given frequency Added: trunk/Lib/sandbox/timeseries/mtimeseries/test_date.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/test_date.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/test_date.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,145 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for MaskedArray. +Adapted from the original test_ma by Pierre Gerard-Marchant + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: test_core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + +import types +import datetime + +import numpy as N +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 + +import maskedarray.testutils +reload(maskedarray.testutils) +from maskedarray.testutils import assert_equal, assert_array_equal + +import tsdate +reload(tsdate) +from tsdate import * + +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" + dlist = ['2007-01-%02i' % i for i in range(1,15)] + # A simple case: daily data + dates = datearray_fromlist(dlist, 'D') + assert_equal(dates.freq,'D') + assert(dates.isfull()) + assert(not dates.ispacked()) + assert_equal(dates, 732677+numpy.arange(len(dlist))) + # as simple, but we need to guess the frequency this time + dates = datearray_fromlist(dlist, 'D') + assert_equal(dates.freq,'D') + assert(dates.isfull()) + assert(not dates.ispacked()) + assert_equal(dates, 732677+numpy.arange(len(dlist))) + # Still daily data, that we force to month + dates = datearray_fromlist(dlist, 'M') + assert_equal(dates.freq,'M') + assert(not dates.isfull()) + assert(dates.ispacked()) + assert_equal(dates, [24085]*len(dlist)) + # Now, for monthly data + dlist = ['2007-%02i' % i for i in range(1,13)] + dates = datearray_fromlist(dlist, 'M') + assert_equal(dates.freq,'M') + assert(dates.isfull()) + assert(not dates.ispacked()) + assert_equal(dates, 24085 + numpy.arange(12)) + # Monthly data w/ guessing + dlist = ['2007-%02i' % i for i in range(1,13)] + dates = datearray_fromlist(dlist, ) + assert_equal(dates.freq,'M') + assert(dates.isfull()) + assert(not dates.ispacked()) + assert_equal(dates, 24085 + numpy.arange(12)) + + def test_fromstrings_wmissing(self): + "Tests creation from list of strings w/ missing dates" + dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)] + dates = datearray_fromlist(dlist) + assert_equal(dates.freq,'U') + assert(not dates.isfull()) + assert(not dates.ispacked()) + assert_equal(dates.tovalue(),732676+numpy.array([1,2,4,5,7,8,10,11,13])) + # + ddates = datearray_fromlist(dlist, 'D') + assert_equal(ddates.freq,'D') + assert(not ddates.isfull()) + assert(not ddates.ispacked()) + # + mdates = datearray_fromlist(dlist, 'M') + assert_equal(mdates.freq,'M') + assert(not dates.isfull()) + assert(mdates.ispacked()) + # + + def test_fromsobjects(self): + "Tests creation from list of objects." + dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)] + dates = datearray_fromlist(dlist) + dobj = [datetime.datetime.fromordinal(d) for d in dates.toordinal()] + odates = datearray_fromlist(dobj) + assert_equal(dates,odates) + dobj = [mxDFromString(d) for d in dlist] + odates = datearray_fromlist(dobj) + assert_equal(dates,odates) + + +class test_methods(NumpyTestCase): + "Base test class for MaskedArrays." + + def __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)] + mdates = datearray_fromlist(dlist).asfreq('M') + # Using an integer + assert_equal(mdates[0].value, 24085) + assert_equal(mdates[-1].value, 24096) + # Using a date + lag = mdates.find_dates(mdates[0]) + assert_equal(mdates[lag], mdates[0]) + lag = mdates.find_dates(Date('M',value=24092)) + assert_equal(mdates[lag], mdates[5]) + # Using several dates + lag = mdates.find_dates(Date('M',value=24085), Date('M',value=24096)) + assert_equal(mdates[lag], + DateArray([mdates[0], mdates[-1]], freq='M')) + assert_equal(mdates[[mdates[0],mdates[-1]]], mdates[lag]) + # + 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 = datearray_fromlist(dlist).asfreq('M') + + + def test_getsteps(self): + dlist = ['2007-01-%02i' %i for i in (1,2,3,4,8,9,10,11,12,15)] + ddates = datearray_fromlist(dlist) + assert_equal(ddates.get_steps(), [1,1,1,4,1,1,1,1,3]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Added: trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,273 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for MaskedArray. +Adapted from the original test_ma by Pierre Gerard-Marchant + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: test_core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + +import types + +import numpy as N +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 + +import maskedarray.testutils +reload(maskedarray.testutils) +from maskedarray.testutils import assert_equal, assert_array_equal + +import tsdate +reload(tsdate) +from tsdate import date_array_fromlist +import tseries +reload(tseries) +from tseries import * + +class test_creation(NumpyTestCase): + "Base test class for MaskedArrays." + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' %i for i in range(1,16)] + dates = date_array_fromlist(dlist) + data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3) + self.d = (dlist, dates, data) + + def test_fromlist (self): + "Base data definition." + (dlist, dates, data) = self.d + series = time_series(data, dlist) + assert(isinstance(series, TimeSeries)) + assert_equal(series._mask, [1,0,0,0,0]*3) + assert_equal(series._series, data) + assert_equal(series._dates, date_array_fromlist(dlist)) + assert_equal(series.freq, 'D') + + def test_fromrange (self): + "Base data definition." + (dlist, dates, data) = self.d + series = time_series(data, start_date=Date('D',value=dates[0]), + length=15) + assert(isinstance(series, TimeSeries)) + assert_equal(series._mask, [1,0,0,0,0]*3) + assert_equal(series._series, data) + assert_equal(series._dates, dates) + assert_equal(series.freq, 'D') + + def test_fromseries (self): + "Base data definition." + (dlist, dates, data) = self.d + series = time_series(data, dlist) + dates = dates+15 + series = time_series(series, dates) + assert(isinstance(series, TimeSeries)) + assert_equal(series._mask, [1,0,0,0,0]*3) + assert_equal(series._series, data) + assert_equal(series._dates, dates) + assert_equal(series.freq, 'D') + +class test_arithmetics(NumpyTestCase): + "Some basic arithmetic tests" + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + 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 + # + nseries = series+1 + assert(isinstance(nseries, TimeSeries)) + 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) + 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) + 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) + 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 + nseries = series.astype(float_) + idini = id(nseries) + data = data.astype(float_) + # + nseries += 1. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data+1.) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + nseries -= 1. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + nseries *= 2. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data*2.) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + nseries /= 2. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + def test_updatemask(self): + "Checks modification of mask." + (series, data) =self.d + assert_equal(series._mask, [1,0,0,0,0]*3) + series.mask = nomask + assert(series._mask is nomask) + assert(series._series._mask is nomask) + series._series.mask = [1,0,0]*5 + assert_equal(series._mask, [1,0,0]*5) + assert_equal(series._series._mask, [1,0,0]*5) + series[2] = masked + assert_equal(series._mask, [1,0,1]+[1,0,0]*4) + assert_equal(series._series._mask, [1,0,1]+[1,0,0]*4) + + +class test_getitem(NumpyTestCase): + "Some getitem tests" + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + 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" + (tseries, data, dates) = self.d + last_date = tseries[-1]._dates + assert_equal(tseries[-1], tseries[last_date]) + assert_equal(tseries._dates[-1], dates[-1]) + assert_equal(tseries[-1]._dates, dates[-1]) + assert_equal(tseries[last_date]._dates, dates[-1]) + assert_equal(tseries._series[-1], data._data[-1]) + assert_equal(tseries[-1]._series, data._data[-1]) + assert_equal(tseries._mask[-1], data._mask[-1]) + # + tseries['2007-01-06'] = 999 + assert_equal(tseries[5], 999) + # + def test_wtimeseries(self): + "Tests getitem w/ TimeSeries as index" + (tseries, data, dates) = self.d + # Testing a basic condition on data + cond = (tseries<8).filled(False) + dseries = tseries[cond] + assert_equal(dseries._data, [1,2,3,4,6,7]) + assert_equal(dseries._dates, tseries._dates[[1,2,3,4,6,7]]) + assert_equal(dseries._mask, nomask) + # Testing a basic condition on dates + tseries[tseries._dates < Date('D',string='2007-01-06')] = MA.masked + assert_equal(tseries[:5]._series._mask, [1,1,1,1,1]) + + def test_wslices(self): + "Test get/set items." + (tseries, data, dates) = self.d + # Basic slices + assert_equal(tseries[3:7]._series._data, data[3:7]._data) + assert_equal(tseries[3:7]._series._mask, data[3:7]._mask) + assert_equal(tseries[3:7]._dates, dates[3:7]) + # Ditto + assert_equal(tseries[:5]._series._data, data[:5]._data) + assert_equal(tseries[:5]._series._mask, data[:5]._mask) + assert_equal(tseries[:5]._dates, dates[:5]) + # With set + tseries[:5] = 0 + assert_equal(tseries[:5]._series, [0,0,0,0,0]) + dseries = numpy.log(tseries) + tseries[-5:] = dseries[-5:] + assert_equal(tseries[-5:], dseries[-5:]) + # Now, using dates ! + dseries = tseries[tseries.dates[3]:tseries.dates[7]] + assert_equal(dseries, tseries[3:7]) + +class test_functions(NumpyTestCase): + "Some getitem tests" + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + 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, dates) + # + def test_adjustendpoints(self): + "Tests adjust_endpoints" + (tseries, data, dates) = self.d + dseries = adjust_endpoints(tseries, tseries.dates[0], tseries.dates[-1]) + assert_equal(dseries, tseries) + dseries = adjust_endpoints(tseries, tseries.dates[3], tseries.dates[-3]) + assert_equal(dseries, tseries[3:-2]) + dseries = adjust_endpoints(tseries, end_date=Date('D', string='2007-01-31')) + assert_equal(dseries.size, 31) + assert_equal(dseries._mask, numpy.r_[tseries._mask, [1]*16]) + dseries = adjust_endpoints(tseries, end_date=Date('D', string='2007-01-06')) + assert_equal(dseries.size, 6) + assert_equal(dseries, tseries[:6]) + dseries = adjust_endpoints(tseries, + start_date=Date('D', string='2007-01-06'), + end_date=Date('D', string='2007-01-31')) + assert_equal(dseries.size, 26) + assert_equal(dseries._mask, numpy.r_[tseries._mask[5:], [1]*16]) + # + def test_maskperiod(self): + "Test mask_period" + (tseries, data, dates) = self.d + tseries.mask = nomask + (start, end) = ('2007-01-06', '2007-01-12') + mask = mask_period(tseries, start, end, inside=True, include_edges=True, + inplace=False) + assert_equal(mask._mask, numpy.array([0,0,0,0,0,1,1,1,1,1,1,1,0,0,0])) + mask = mask_period(tseries, 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(tseries, 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(tseries, 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]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Added: trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,1494 @@ +# 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. + +These two classes were liberally adapted from `MaskedArray` class. + + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date: 2006-12-05 20:40:46 -0500 (Tue, 05 Dec 2006) $ +:version: $Id: timeseries.py 25 2006-12-06 01:40:46Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 25 $" +__date__ = '$Date: 2006-12-05 20:40:46 -0500 (Tue, 05 Dec 2006) $' + + +#import numpy as N + +#from numpy.core import bool_, float_, int_ +import numpy.core.umath as umath +import numpy.core.fromnumeric as fromnumeric +import numpy.core.numeric as numeric +from numpy import ndarray +from numpy.core.records import recarray +from numpy.core.records import fromarrays as recfromarrays + +#from cPickle import dump, dumps + +import core +reload(core) +from core import * + + +import maskedarray as MA +#reload(MA) +from maskedarray.core import domain_check_interval, \ + domain_greater_equal, domain_greater, domain_safe_divide, domain_tan +from maskedarray.core import MaskedArray, MAError, masked_array, isMaskedArray,\ + getmask, getmaskarray, filled, mask_or, make_mask +from maskedarray.core import convert_typecode, masked_print_option, \ + masked_singleton +from maskedarray.core import load, loads, dump, dumps + +import addons.numpyaddons +reload(addons.numpyaddons) +from addons.numpyaddons import ascondition + +#............................................................................... +talog = logging.getLogger('TimeArray') +tslog = logging.getLogger('TimeSeries') +mtslog = logging.getLogger('MaskedTimeSeries') + +nomask = MA.nomask +masked = MA.masked +masked_array = MA.masked_array +ufunc_domain = {} +ufunc_fills = {} + + +#### -------------------------------------------------------------------------- +#--- ... Date Tools ... +#### -------------------------------------------------------------------------- +dtmdefault = dtm.datetime(2001,1,1) + +def isDate(obj): + """Returns *True* if the argument is a `datetime.date` or `datetime.datetime` +instance.""" + return isinstance(obj,dtm.date) or isinstance(obj,dtm.datetime) + +def fake_dates(count, start=dtmdefault): + """fake_dates(count, start=dtmdefault) +Returns a *count x 1* array of daily `datetime` objects. +:Parameters: + - `count` (Integer) : Number of dates to output + - `start` (datetime object) : Starting date *[NOW]*.""" + dobj = list(dtmrule.rrule(DAILY,count=count,dtstart=start)) + return N.array(dobj) + +#### -------------------------------------------------------------------------- +#--- ... TimeArray class ... +#### -------------------------------------------------------------------------- +class TimeArrayError(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 TimeArray(ndarray): + """Stores datetime.dateime objects in an array.""" + def __new__(subtype, series, copy=False): + vlev = 3 + if isinstance(series, TimeArray): +# verbose.report("DA __new__: data isDA types %s, %s, %i" % \ +# (type(series), series, len(series)), vlev) + if not copy: + return series + else: + return series.copy() + else: + data = N.array(series) + if data.dtype.str == "|O8": + new = data #.view(subtype) + talog.debug("__new__: data isnotDA types %s, %s, %s, %i" % \ + (type(series), data.dtype, series, data.size),) + else: + new = N.empty(data.shape, dtype="|O8") + newflat = new.flat + talog.debug("DA __new__: data isnotDA types %s, %s, %s, %i" % \ + (type(series), data.dtype, series, data.size),) + # Forces years (as integers) to be read as characters + if N.all(data < 9999): + data = data.astype("|S4") + # Parse dates as characters + if data.dtype.char == "S": + for (k,s) in enumerate(data.flat): + newflat[k] = dtmparser.parse(s, default=dtmdefault) + else: + # Parse dates as ordinals + try: + for k,s in enumerate(data.flat): + newflat[k] = dtm.datetime.fromordinal(s) + except TypeError: + raise TypeError, "unable to process series !" + subtype._asobject = new + return new.view(subtype) +# #............................................ +# def __array_wrap__(self, obj): +# return TimeArray(obj) + #............................................ + def __array_finalize__(self, obj): + self._resolution = None + (self._years, self._months, self._days, self._yeardays) = [None]*4 + self._asobjects = None + self._asstrings = None + self._asordinals = None + return + #............................................ + def __len__(self): + "Returns the length of the object. Or zero if it fails." + if self.ndim == 0: + return 0 + return ndarray.__len__(self) + + + def __getitem__(self,i): + # Force a singleton to DateArray + try: + obj = ndarray.__getitem__(self,i) + except IndexError: + obj = self + return TimeArray(obj) +# if isDate(obj): +# return DateArray(obj) +# else: +# return obj + #............................................ + def __eq__(self, other): + return N.asarray(self).__eq__(N.asarray(other)) + + def __add__(self, other): + if not isinstance(other, dtm.timedelta): + raise TypeError, "Unsupported type for add operation" + return TimeArray(N.asarray(self).__add__(other)) + + def __sub__(self, other): + if not isinstance(other, dtm.timedelta) and \ + not isinstance(other, TimeArray): + raise TypeError, "Unsupported type for sub operation" + return N.asarray(self).__sub__(N.asarray(other)) + + def __mul__(self, other): + raise TimeArrayError, "TimeArray objects cannot be multiplied!" + __rmul__ = __mul__ + __imul__ = __mul__ +# def shape(self): +# if self.size == 1: +# return (1,) +# else: +# return self._data.shape + #............................................ + def __str__(self): + """x.__str__() <=> str(x)""" + return str(self.asstrings()) + def __repr__(self): + """Calculate the repr representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + template = """\ +timearray( + %(data)s,)""" + template_short = """\ +timearray(%(data)s)""" + if self.ndim <= 1: + return template_short % {'data': str(self)} + else: + return template % {'data': str(self)} + #............................................ + @property + def resolution(self): + """Calculates the initial resolution, as the smallest difference +between consecutive values (in days).""" + if self._resolution is None: + self._resolution = N.diff(self.asordinals().ravel()).min() + if self._resolution <= 3: + self._resolution = 1 + elif self._resolution <= 10: + self._resolution = 7 + elif self._resolution <= 270: + self._resolution = 30 + else: + self._resolution = 365 + return self._resolution + timestep = resolution + #............................................ + def has_missing_dates(self, resolution=None): + """Returns *True* there's a gap in the series, assuming a regular series +with a constant timestep of `resolution`. +If `resolution` is None, uses the default resolution of `self`. +""" + if self.size < 2: + return False + dt = N.diff(self.asordinals().ravel()) + if resolution is None: + resolution = self.resolution + if resolution == 1: + return (dt.max() > 1) + elif resolution == 30: + return (dt.max() > 31) + elif resolution == 365: + return (dt.max() > 730) + else: + #FIXME: OK, there's probly something wrong here... + return True + #............................................ + def asobjects(self): + """Transforms an array of ordinal dates to an array of date objects.""" + if self._asobjects is None: + if self.size == 1: + self._asobjects = self.item() + else: + self._asobjects = self + return self._asobjects + #............................................ + def asordinals(self): + """Transforms an array of dates to an array of date objects.""" + if self._asordinals is None: + # Build list of datetime objects + self._asordinals = N.empty(self.shape,dtype=int_) + _asordinalsflat = self._asordinals.flat + if self.size == 0: + self._asordinals = dtm.datetime.toordinal(dtmdefault) + elif self.size == 1: + self._asordinals = dtm.datetime.toordinal(self.item()) + else: + itr = (dtm.datetime.toordinal(val) for val in self.flat) + self._asordinals = N.fromiter(itr, float_) + return self._asordinals + #............................................ + def asstrings(self, stringsize=10): + """Transforms a *N*-array of ordinal dates to a *N*-list of +datestrings `YYYY-MM-DD`. + +:Parameters: + `stringsize` : Integer *[10]* + String size. + + - `< 4' outputs 4 + - `< 8' outputs 8 + - anything else outputs 10. + """ + if not stringsize: + strsize = 10 + elif stringsize <= 4: + strsize = 4 + elif stringsize <= 8: + strsize = 7 + else: + strsize = 10 + if self._asstrings is None: + deftype = "|S10" + if self.size == 0: + self._asstrings = N.array(dtmdefault.isoformat(), dtype=deftype) + elif self.size == 1: + self._asstrings = N.array(self.item().isoformat(), dtype=deftype) + else: + itr = (val.isoformat() for val in self.flat) + self._asstrings = N.fromiter(itr,dtype=deftype).reshape(self.shape) + return self._asstrings.getfield('S%i' % strsize) + #............................................ + def astype(self, newtype): + """Outputs the array in the type provided in argument.""" + newtype = N.dtype(newtype) + if newtype.type == int_: + return self.asordinals() + elif newtype.type == str_: + n = newtype.itemsize + if n > 0 : + return self.asstrings(stringsize=n) + else: + return self.asstrings(stringsize=n) + elif newtype.type == object_: + return self + else: + raise ValueError, "Invalid type: %s" % newtype + #------------------------------------------------------ + @property + def years(self): + """Returns the corresponding year (as integer).""" + if self._years is None: + self._years = self.asstrings(1).astype(int_) + return self._years + @property + def months(self): + """Returns the corresponding month (as integer).""" + if self._months is None: + self._months = N.empty(self.shape, dtype=int_) + _monthsflat = self._months.flat + if self.size == 1: + try: + _monthsflat[:] = self.asobjects().month + except AttributeError: + _monthsflat[:] = 1 + else: + for (k,val) in enumerate(self.asobjects().flat): + _monthsflat[k] = val.month + return self._months + @property + def days(self): + """Returns the corresponding day of month (as integer).""" + if self._days is None: + self._days = N.empty(self.shape, dtype=int_) + _daysflat = self._days.flat + if self.size == 1: + try: + _daysflat[:] = self.asobjects().day + except AttributeError: + _daysflat[:] = 1 + else: + for (k,val) in enumerate(self.asobjects().flat): + _daysflat[k] = val.day + return self._days + @property + def yeardays(self): + """Returns the corresponding day of year (as integer).""" + if self._yeardays is None: + self._yeardays = N.empty(self.size, dtype=int_) + _doyflat = self._yeardays.flat + for (k,val,yyy) in N.broadcast(N.arange(len(self)), + self.asordinals(), + self.years.flat): + _doyflat[k] = val - dtm.datetime(yyy-1,12,31).toordinal() + self._yeardays.reshape(self.shape).astype(int_) + return self._yeardays +#................................................ +def isTimeArray(x): + """Checks whether `x` is n array of times/dates (an instance of `TimeArray` ).""" + return isinstance(x,TimeArray) + +def time_array(t, copy=False): + """Creates a date array from the series `t`. + """ + if isinstance(t,TimeArray): + dobj = t + else: + t = N.asarray(t) + if t.dtype.str == "|O8": + dobj = t + else: + dobj = N.empty(t.shape, dtype="|O8") + dobjflat = dobj.flat + if t.dtype.char == 'S': + for k,s in enumerate(t.flat): + dobjflat[k] = dtmparser.parse(s) + else: + try: + for k,s in enumerate(t.flat): + dobjflat[k] = dtm.datetime.fromordinal(s) + except TypeError: + raise TypeError, "unable to process series !" + return TimeArray(dobj, copy=copy) + +#### -------------------------------------------------------------------------- +#--- ... Time Series ... +#### -------------------------------------------------------------------------- +class TimeSeriesError(Exception): + "Class for TS related errors." + def __init__ (self, args=None): + "Creates an exception." + Exception.__init__(self) + self.args = args + def __str__(self): + "Calculates the string representation." + return str(self.args) + __repr__ = __str__ +#...................................... +#TODO: __eq__, __cmp__ classes +class TimeSeries(ndarray, object): + """Base class for the definition of time series. +A time series is here defined as the combination of two arrays: + + - an array storing the time information (as a `TimeArray` instance); + - an array storing the data (as a `MaskedArray` instance. + """ + def __new__(cls, data, dates=None, dtype=None, copy=True): + tslog.debug("__new__: data types %s, %s" % (type(data), dtype)) +# if isinstance(data, TimeSeries): + if hasattr(data,"_series") and hasattr(data,"_dates"): + tslog.debug("__new__: data has _series and _dates") + tslog.debug("__new__: setting basedates",) + cls._basedates = data._dates + tslog.debug("__new__: setting basedates done",) + if (not copy) and (dtype == data.dtype): + return N.asarray(data).view(cls) + else: + return N.array(data, dtype=dtype).view(cls) + #.......... + dsize = N.size(data) + tslog.debug("__new__: args dates type %s, %s" % (type(dates), dates),) + if dates is None: + _dates = TimeArray(fake_dates(N.size(data))) + tslog.debug("__new__: args dates FAKED type %s, %s, %i" % \ + (type(dates), _dates, _dates.size),) + else: + _dates = TimeArray(dates) + tslog.debug("__new__: dates set to %s" % _dates,) + if _dates.size != dsize: + msg = "Incompatible sizes between dates (%i) and data (%i) !" + raise ValueError, msg % (_dates.size, dsize) + _dates.shape = N.shape(data) + cls._basedates = _dates + return N.array(data, copy=copy, dtype=dtype).view(cls) + #.................................. + def __array_wrap__(self, obj): + return TimeSeries(obj, dates=self._dates) + #.................................. + def __array_finalize__(self,obj): + if not hasattr(self,"_series"): + try: + self._series = obj._series + tslog.debug("__array_finalize__: obj._data => : %s - %s" % \ + (id(self._series), self._series.ravel() ),) + except AttributeError: + self._series = obj + tslog.debug("__array_finalize__: obj => : %s - %s" % \ + (id(self._series), self._series.ravel() ),) + if not hasattr(self,"_dates"): + self._dates = self._basedates + tslog.debug("__array_finalize__: dates set! => : %s - %s" % \ + (id(self._dates), self._dates.ravel() )) + return + #........................ + def _get_flat(self): + """Calculate the flat value. + """ + return self.__class__(self._series.ravel(), + dates = self._dates.ravel(), copy=False) + #.... + def _set_flat (self, value): + "x.flat = value" + y = self.ravel() + y[:] = value + flat = property(fget=_get_flat,fset=_set_flat,doc='Access array in flat form.') + #........................ + def _get_shape(self): + "Return the current shape." + return self._series.shape + #.... + def _set_shape (self, newshape): + "Set the array's shape." + self._series.shape = self._dates.shape = newshape + #.... + shape = property(fget=_get_shape, fset=_set_shape, doc="Array shape") + #.... + @property + def ndim(self): + """Returns the number of dimensions.""" + return self._series.ndim + @property + def size(self): + """Returns the total number of elements.""" + return self._series.size + #........................ + def __getitem__(self, i): + "Get item described by i. Not a copy as in previous versions." + (tout, dout) = (self._dates[i], self._series[i]) + return self.__class__(dout, dates=tout) + #.... + def __setitem__(self, index, value): + "Gets item described by i. Not a copy as in previous versions." + self._series[index] = value + return self + #........................ + def __getslice__(self, i, j): + "Gets slice described by i, j" + (tout, dout) = (self._dates[i:j], self._series[i:j]) + return self.__class__(dout, dates=tout,) + #.... + def __setslice__(self, i, j, value): + "Gets item described by i. Not a copy as in previous versions." + #TODO: Here, we should have a better test for self._dates==value._dates + if hasattr(value,"_dates"): + tslog.debug("__setslice__: value: %s" % str(value)) + tslog.debug("__setslice__: dates: %s" % str(value._dates),) + if not (self._dates == value._dates).all(): + raise TimeSeriesError,"Can't force a change of dates !" + self._series[i:j] = value + return self + #........................ + def ravel (self): + """Returns a 1-D view of self.""" + return self.__class__(self._series.ravel(), + dates=self._dates.ravel()) + #........................ + def __len__(self): + if self.ndim == 0: + return 0 + return ndarray.__len__(self) + def __str__(self): + """Returns a string representation of self (w/o the dates...)""" + return str(self._series) + def __repr__(self): + """Calculates the repr representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + desc = """\ +timeseries(data = + %(data)s, + dates = + %(time)s, ) +""" + desc_short = """\ +timeseries(data = %(data)s, + dates = %(time)s,) +""" + if self.ndim <= 1: + return desc_short % { + 'data': str(self._series), + 'time': str(self.dates), + } + return desc % { + 'data': str(self._series), + 'time': str(self.dates), + } + + def ids (self): + """Return the ids of the data, dates and mask areas""" + return (id(self._series), id(self.dates),) + + @property + def series(self): + "Returnhs the series." + return self._series + + #------------------------------------------------------ + @property + def dates(self): + """Returns the dates""" + return self._dates +### def _set_dates(self, object): +### """Returns the dates""" +### self._dates = object +### dates = property(fget=_get_dates, fset=_set_dates, doc="Dates") + @property + def years(self): + """Returns the corresponding years.""" + return self.dates.years + @property + def months(self): + """Returns the corresponding months.""" + return self._dates.months + @property + def yeardays(self): + """Returns the corresponding days of yuear.""" + return self._dates.yeardays + + def has_missing_dates(self): + """Returns whether there's a date gap in the series.""" + return self._dates.has_missing_dates() + +#### -------------------------------------------------------------------------- +#--- ... Additional methods ... +#### -------------------------------------------------------------------------- +class _tsmathmethod(object): + """Defines a wrapper for arithmetic array methods (add, mul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + _dates = instance._dates + tslog.debug("_tsmathmethod: series: %s" % instance,) + tslog.debug("_tsmathmethod: other : %s" % other,) + func = getattr(instance._series, self.f) + if hasattr(instance,"_dates") and hasattr(other,"_dates"): + tslog.debug("_tsmathmethod: instance : %s" % instance,) + tslog.debug("_tsmathmethod: other : %s" % other,) + if N.any(instance._dates != other._dates): + tslog.debug("_tsmathmethod %s on %s and %s" % \ + (self.f, instance, other),) + raise TimeSeriesError, "Method %s not yet implemented !" % self.f + return instance.__class__(func(other, *args), dates=_dates) +#...................................... +TimeSeries.__add__ = _tsmathmethod('__add__') +TimeSeries.__radd__ = _tsmathmethod('__add__') +TimeSeries.__sub__ = _tsmathmethod('__sub__') +TimeSeries.__rsub__ = _tsmathmethod('__rsub__') +TimeSeries.__pow__ = _tsmathmethod('__pow__') +TimeSeries.__mul__ = _tsmathmethod('__mul__') +TimeSeries.__rmul__ = _tsmathmethod('__mul__') +TimeSeries.__div__ = _tsmathmethod('__div__') +TimeSeries.__rdiv__ = _tsmathmethod('__rdiv__') +TimeSeries.__truediv__ = _tsmathmethod('__truediv__') +TimeSeries.__rtruediv__ = _tsmathmethod('__rtruediv__') +TimeSeries.__floordiv__ = _tsmathmethod('__floordiv__') +TimeSeries.__rfloordiv__ = _tsmathmethod('__rfloordiv__') +#................................................ +class _tsarraymethod(object): + """Defines a wrapper for basic array methods. +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +If `ondates` is True, the same operation is performed on the `_dates`. +If `ondates` is False, the `_dates` part remains unchanged. + """ + def __init__ (self, methodname, ondates=False): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + self._ondates = ondates + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args): + "Execute the call behavior." + _name = self._name + instance = self.obj + func_series = getattr(instance._series, _name) + if self._ondates: + func_dates = getattr(instance._dates, _name) + return instance.__class__(func_series(*args), + dates=func_dates(*args)) + else: + return instance.__class__(func_series(*args), + dates=instance._dates) +#...................................... +class _tsaxismethod(object): + """Defines a wrapper for array methods working on an axis (mean...). +When called, returns a ndarray, as the result of the method applied on the original series. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + "Execute the call behavior." + func = getattr(self.obj._series, self._name) + return func(*args, **params) +#....................................... +TimeSeries.astype = _tsarraymethod('astype') +TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) +TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) +TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) +TimeSeries.copy = _tsarraymethod('copy', ondates=True) +TimeSeries.compress = _tsarraymethod('compress', ondates=True) +# +TimeSeries.sum = _tsaxismethod('sum') +TimeSeries.cumsum = _tsaxismethod('cumsum') +TimeSeries.prod = _tsaxismethod('prod') +TimeSeries.cumprod = _tsaxismethod('cumprod') +TimeSeries.mean = _tsaxismethod('mean') +TimeSeries.var = _tsaxismethod('var') +TimeSeries.varu = _tsaxismethod('varu') +TimeSeries.std = _tsaxismethod('std') +TimeSeries.stdu = _tsaxismethod('stdu') + + +#.............................................................................. +def concatenate(arrays, axis=0): + """Concatenates a sequence of time series.""" + concatenate.__doc__ = N.concatenate.__doc__ + for a in arrays: + if hasattr(a,"_dates"): + raise TimeSeriesError, "Not yet implemented for TimeSeries !" + +#### --------------------------------------------------------------------------- +#--- ... Pickling ... +#### --------------------------------------------------------------------------- +#FIXME: We're kinda stuck with forcing the mask to have the same shape as the data +def _tsreconstruct(baseclass, datesclass, baseshape, basetype): + """Internal function that builds a new MaskedArray from the information stored +in a pickle.""" + _series = ndarray.__new__(ndarray, baseshape, basetype) + _dates = ndarray.__new__(datesclass, baseshape, basetype) + return TimeSeries.__new__(baseclass, _series, dates=_dates, dtype=basetype) + +def _tsgetstate(a): + "Returns the internal state of the TimeSeries, for pickling purposes." + #TODO: We should prolly go through a recarray here as well. + state = (1, + a.shape, + a.dtype, + a.flags.fnc, + (a._series).__reduce__()[-1][-1], + (a._dates).__reduce__()[-1][-1]) + return state + +def _tssetstate(a, 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 + - a binary string for the data + - a binary string for the mask. + """ + (ver, shp, typ, isf, raw, dti) = state + (a._series).__setstate__((shp, typ, isf, raw)) + (a._dates).__setstate__((shp, N.dtype('|O8'), isf, dti)) + (a._dates)._asstrings = None + +def _tsreduce(a): + """Returns a 3-tuple for pickling a MaskedArray.""" + return (_tsreconstruct, + (a.__class__, a._dates.__class__, (0,), 'b', ), + a.__getstate__()) + +TimeSeries.__getstate__ = _tsgetstate +TimeSeries.__setstate__ = _tssetstate +TimeSeries.__reduce__ = _tsreduce +TimeSeries.__dump__ = dump +TimeSeries.__dumps__ = dumps + +#................................................ +def tofile(self, output, sep='\t', format='%s', format_dates=None): + """Writes the TimeSeries to a file. + +:Parameters: + - `output` (String) : Name or handle of the output file. + - `sep` (String) : Column separator *['\t']*. + - `format` (String) : Data format *['%s']*. + """ + if not hasattr(output, 'writeline'): + ofile = open(output,'w') + else: + ofile = output + oformat = "%%s%s%s" % (sep,format) + for (_dates,_data) in N.broadcast(self._dates.ravel().asstrings(), + filled(self)): + ofile.write('%s\n' % sep.join([oformat % (_dates, _data) ])) + ofile.close() +TimeSeries.tofile = tofile + +#### -------------------------------------------------------------------------- +#--- ... Shortcuts ... +#### -------------------------------------------------------------------------- +def isTimeSeries(x): + """Checks whether `x` is a time series (an instance of `TimeSeries` ).""" + return isinstance(x, TimeSeries) + +#### -------------------------------------------------------------------------- +#--- ... MaskedTimeSeries class ... +#### -------------------------------------------------------------------------- +class MaskedTimeSeries(MaskedArray, TimeSeries): + """Base class for the definition of time series. +A time series is here defined as the combination of two arrays: + + - an array storing the time information (as a `TimeArray` instance); + - an array storing the data (as a `MaskedArray` instance. + """ + def __new__(cls, data, dates=None, mask=nomask, + dtype=None, copy=True, fill_value=-9999): + mtslog.log(5, "__new__: data types %s, %s" % (type(data), dtype)) +# if isinstance(data, TimeSeries): + #.................... + if isinstance(data, TimeSeries): + if isinstance(data, MaskedTimeSeries): + _data = data._data + else: + _data = data + _dates = data._dates + _series = data._series + mtslog.log(5, "__new__ from TS: data %i - %s - %s" % \ + (id(_data._series), type(_data._series), _data.ravel())) + mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ + (id(_dates), type(_dates), _dates.ravel())) + elif isinstance(data, recarray): + assert(data.dtype.names == ('_dates', '_series', '_mask'), + "Invalid fields names (got %s)" % (data.dtype.names,)) + _dates = data['_dates'] + _series = data['_series'] + _mask = data['_mask'] + else: + if hasattr(data, "_data"): + _data = TimeSeries(data._data, dates=dates, + dtype=dtype, copy=copy) + else: + _data = TimeSeries(data, dates=dates, + dtype=dtype, copy=copy) + _dates = _data._dates + _series = _data._series + mtslog.log(5,"__new__ from scratch: data %i - %s - %s" % \ + (id(_data._series), type(_data._series), _data.ravel())) + mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ + (id(_dates), type(_dates), _dates.ravel())) + #..................... + if mask is nomask: + if hasattr(data, "_mask"): + _mask = data._mask + else: + _mask = nomask + else: + _mask = make_mask(mask, copy=copy, flag=True) + #....Check shapes compatibility + if _mask is not nomask: + (nd, nm) = (_data.size, _mask.size) + if (nm != nd): + if nm == 1: + _mask = N.resize(_mask, _data.shape) + elif nd == 1: + _data = N.resize(_data, _mask.shape) + else: + msg = "Mask and data not compatible (size issues: %i & %i)." + raise MAError, msg % (nm, nd) + elif (_mask.shape != _data.shape): + mtslog.log(5,"__new__ from scratch: force _mask shape %s > %s" % \ + (_mask.shape, _data.shape)) + _mask.shape = _data.shape + #.... + cls._fill_value = fill_value + cls._basemask = _mask + cls._basedates = _dates + cls._baseseries = _series + return _data.view(cls) +# return _series.view(cls) + #.............. + def __array_wrap__(self, obj, context=None): + """Special hook for ufuncs. +Wraps the numpy array and sets the mask according to context. + """ +# return MaskedArray.__array_wrap__(obj, context=None) + return MaskedTimeSeries(obj, dates=self._dates, mask=self._mask, + fill_value=self._fill_value) + + #.............. + def __array_finalize__(self,obj): + mtslog.log(5, "__array_finalize__: obj is %s" % (type(obj), )) + if not hasattr(self, "_data"): + self._data = obj + if not hasattr(self, "_dates"): + self._dates = self._basedates + mtslog.log(5, "__array_finalize__: set dates to: %s - %s" % \ + (id(self._dates), self._dates.ravel() )) + if not hasattr(self, "_mask"): + self._mask = self._basemask + mtslog.log(5, "__array_finalize__: set mask to: %s - %s" % \ + (id(self._mask), self._mask.ravel() )) + if not hasattr(self, "_series"): + if hasattr(obj, "_series"): + self._series = obj._series + else: + self._series = obj + self.fill_value = self._fill_value + return + + #------------------------------------------------------ +# def __mul__(self): + #------------------------------------------------------ + def __str__(self): + """Calculate the str representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + if masked_print_option.enabled(): + f = masked_print_option + # XXX: Without the following special case masked + # XXX: would print as "[--]", not "--". Can we avoid + # XXX: checks for masked by choosing a different value + # XXX: for the masked singleton? 2005-01-05 -- sasha + if self is masked: + return str(f) + m = self._mask + if m is nomask: + res = self._data + else: + if m.shape == () and m: + return str(f) + # convert to object array to make filled work + res = (self._series).astype("|O8") + res[self._mask] = f + else: + res = self.filled(self.fill_value) + return str(res) + + def __repr__(self): + """Calculate the repr representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + desc = """\ +timeseries(data = + %(data)s, + mask = + %(mask)s, + date = + %(time)s, ) +""" + desc_short = """\ +timeseries(data = %(data)s, + mask = %(mask)s, + date = %(time)s,) +""" +# if (self._mask is nomask) and (not self._mask.any()): +# if self.ndim <= 1: +# return without_mask1 % {'data':str(self.filled()), +# 'time':str(self._dates.asstrings())} +# return without_mask % {'data':str(self.filled()), +# 'time':str(self._dates.asstrings())} +# else: + if self.ndim <= 1: + return desc_short % { + 'data': str(self), + 'mask': str(self._mask), + 'time': str(self.dates), + } + return desc % { + 'data': str(self), + 'mask': str(self._mask), + 'time': str(self.dates), + } + #............................................ + def ids (self): + """Return the ids of the data, dates and mask areas""" + return (id(self._series), id(self.dates), id(self._mask)) + #............................................ + @property + def maskedseries(self): + """Returns a masked array of the series (dates are omitteed).""" + return masked_array(self._series, mask=self._mask) + _mseries = maskedseries + #............................................ + def filled(self, fill_value=None): + """A numeric array with masked values filled. If fill_value is None, + use self.fill_value(). + + If mask is nomask, copy data only if not contiguous. + Result is always a contiguous, numeric array. +# Is contiguous really necessary now? + """ + (d, m) = (self._data, self._mask) + if m is nomask: + return d + # + if fill_value is None: + value = self._fill_value + else: + value = fill_value + # + if self is masked_singleton: + return numeric.array(value) + # + result = d.copy() + try: + result.__setitem__(m, value) + except (TypeError, AttributeError): + #ok, can't put that value in here + value = numeric.array(value, dtype=object) + d = d.astype(object) + result = fromnumeric.choose(m, (d, value)) + except IndexError: + #ok, if scalar + if d.shape: + raise + elif m: + result = numeric.array(value, dtype=d.dtype) + else: + result = d + return result + #............................................ + def sum(self, axis=None, dtype=None): + """a.sum(axis=None, dtype=None) +Sums the array `a` over the given axis `axis`. +Masked values are set to 0. +If `axis` is None, applies to a flattened version of the array. + """ + if self._mask is nomask: + return self._data.sum(axis, dtype=dtype) + else: + if axis is None: + return self.filled(0).sum(None, dtype=dtype) + return MaskedArray(self.filled(0).sum(axis, dtype=dtype), + mask=self._mask.all(axis)) + + def cumsum(self, axis=None, dtype=None): + """a.cumprod(axis=None, dtype=None) +Returns the cumulative sum of the elements of array `a` along the given axis `axis`. +Masked values are set to 0. +If `axis` is None, applies to a flattened version of the array. + """ + if self._mask is nomask: + return self._data.cumsum(axis=axis, dtype=dtype) + else: + if axis is None: + return self.filled(0).cumsum(None, dtype=dtype) + return MaskedArray(self.filled(0).cumsum(axis=axis, dtype=dtype), + mask=self._mask) + + def prod(self, axis=None, dtype=None): + """a.prod(axis=None, dtype=None) +Returns the product of the elements of array `a` along the given axis `axis`. +Masked elements are set to 1. +If `axis` is None, applies to a flattened version of the array. + """ + if self._mask is nomask: + return self._data.prod(axis=axis, dtype=dtype) + else: + if axis is None: + return self.filled(1).prod(None, dtype=dtype) + return MaskedArray(self.filled(1).prod(axis=axis, dtype=dtype), + mask=self._mask.all(axis)) + product = prod + + def cumprod(self, axis=None, dtype=None): + """a.cumprod(axis=None, dtype=None) +Returns the cumulative product of ethe lements of array `a` along the given axis `axis`. +Masked values are set to 1. +If `axis` is None, applies to a flattened version of the array. + """ + if self._mask is nomask: + return self._data.cumprod(axis=axis, dtype=dtype) + else: + if axis is None: + return self.filled(1).cumprod(None, dtype=dtype) + return MaskedArray(self.filled(1).cumprod(axis=axis, dtype=dtype), + mask=self._mask) + + def mean(self, axis=None, dtype=None): + """mean(a, axis=None, dtype=None) +Returns the arithmetic mean. + +The mean is the sum of the elements divided by the number of elements. + """ + if self._mask is nomask: + return self._data.mean(axis=axis, dtype=dtype) + else: + sum = N.sum(self.filled(0), axis=axis, dtype=dtype) + cnt = self.count(axis=axis) + if axis is None: + if self._mask.all(None): + return masked + else: + return sum*1./cnt + return MaskedArray(sum*1./cnt, mask=self._mask.all(axis)) + + def anom(self, axis=None, dtype=None): + """a.anom(axis=None, dtype=None) +Returns the anomalies, or deviation from the average. + """ + m = self.mean(axis, dtype) + if not axis: + return (self - m) + else: + return (self - N.expand_dims(m,axis)) + + def var(self, axis=None, dtype=None): + """a.var(axis=None, dtype=None) +Returns the variance, a measure of the spread of a distribution. + +The variance is the average of the squared deviations from the mean, +i.e. var = mean((x - x.mean())**2). + """ + if self._mask is nomask: + return MaskedArray(self._data.var(axis=axis, dtype=dtype), + mask=nomask) + else: + cnt = self.count(axis=axis) + anom = self.anom(axis=axis, dtype=dtype) + anom *= anom + dvar = anom.sum(axis) + dvar /= cnt + if axis is None: + return dvar + return MaskedArray(dvar, mask=mask_or(self._mask.all(axis), (cnt==1))) + + def std(self, axis=None, dtype=None): + """a.std(axis=None, dtype=None) +Returns the standard deviation, a measure of the spread of a distribution. + +The standard deviation is the square root of the average of the squared +deviations from the mean, i.e. std = sqrt(mean((x - x.mean())**2)). + """ + var = self.var(axis,dtype) + if axis is None: + if var is masked: + return masked + else: + return N.sqrt(var) + return MaskedArray(N.sqrt(var._data), mask=var._mask) + + def varu(self, axis=None, dtype=None): + """a.var(axis=None, dtype=None) +Returns an unbiased estimate of the variance. + +Instead of dividing the sum of squared anomalies by n, the number of elements, +this sum is divided by n-1. + """ + cnt = self.count(axis=axis) + anom = self.anom(axis=axis, dtype=dtype) + anom *= anom + var = anom.sum(axis) + var /= (cnt-1) + if axis is None: + return var + return MaskedArray(var, mask=mask_or(self._mask.all(axis), (cnt==1))) + + def stdu(self, axis=None, dtype=None): + """a.var(axis=None, dtype=None) +Returns an unbiased estimate of the standard deviation. + """ + var = self.varu(axis,dtype) + if axis is None: + if var is masked: + return masked + else: + return N.sqrt(var) + return MaskedArray(N.sqrt(var._data), mask=var._mask) + #............................................ + def asrecords(self): + """Returns the masked time series as a recarray. +Fields are `_dates`, `_data` and _`mask`. + """ + desctype = [('_dates','|O8'), ('_series',self.dtype), ('_mask',N.bool_)] + flat = self.ravel() + if flat.size > 0: + return recfromarrays([flat._dates, flat._series, getmaskarray(flat)], + dtype=desctype, + shape = (flat.size,), + ) + else: + return recfromarrays([[], [], []], dtype=desctype, + shape = (flat.size,), + ) + + +# def reshape (self, *s): +# """This array reshaped to shape s""" +# self._data = self._data.reshape(*s) +# self._dates = self._dates.reshape(*s) +# if self._mask is not nomask: +# self._mask = self._mask.reshape(*s) +# return self.view() +#### -------------------------------------------------------------------------- +#--- ... Pickling ... +#### -------------------------------------------------------------------------- +def _mtsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): + """Internal function that builds a new MaskedArray from the information stored +in a pickle.""" +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + _series = ndarray.__new__(ndarray, baseshape, basetype) + _dates = ndarray.__new__(datesclass, baseshape, '|O8') + _mask = ndarray.__new__(ndarray, baseshape, '|O8') + return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, + dtype=basetype, fill_value=fill_value) +# +def _mtsgetstate(a): + "Returns the internal state of the TimeSeries, for pickling purposes." +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + records = a.asrecords() + state = (1, + a.shape, + a.dtype, + records.flags.fnc, + a.fill_value, + records + ) + return state +# +def _mtssetstate(a, 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 + - a binary string for the data + - a binary string for the mask. + """ + (ver, shp, typ, isf, flv, rec) = state + a.fill_value = flv + a._data._series = a._series = N.asarray(rec['_series']) + a._data._series.shape = a._series.shape = shp + a._data._dates = a._dates = a._dates.__class__(rec['_dates']) + a._data._dates.shape = a._dates.shape = shp + (a._dates)._asstrings = None + a._mask = N.array(rec['_mask'], dtype=MA.MaskType) + a._mask.shape = shp +# +def _mtsreduce(a): + """Returns a 3-tuple for pickling a MaskedArray.""" + return (_mtsreconstruct, + (a.__class__, a.dates.__class__, (0,), 'b', -9999), + a.__getstate__()) +# +MaskedTimeSeries.__getstate__ = _mtsgetstate +MaskedTimeSeries.__setstate__ = _mtssetstate +MaskedTimeSeries.__reduce__ = _mtsreduce +MaskedTimeSeries.__dump__ = dump +MaskedTimeSeries.__dumps__ = dumps + +##### ------------------------------------------------------------------------- +#---- --- TimeSeries creator --- +##### ------------------------------------------------------------------------- +def time_series(data, dates=None, mask=nomask, copy=False, fill_value=None): + """Creates a TimeSeries object + +:Parameters: + `dates` : ndarray + Array of dates. + `data` : + Array of data. + """ + if isinstance(data, MaskedTimeSeries): + if not copy: + data._mask = mask_or(data._mask, mask) + return data + _data = data._data + _mask = mask_or(data._mask, mask) + _dates = _data.dates + elif isinstance(data, TimeSeries): + _data = data._series + _mask = make_mask(mask) + _dates = data.dates + else: + data = masked_array(data, copy=False) + _data = data._data + _mask = mask_or(data._mask, mask) + if dates is None: + _dates = fake_dates(data.size) + else: + _dates = time_array(dates) + return MaskedTimeSeries(_data, dates=_dates, mask=_mask, copy=copy, + fill_value=fill_value) + + +# + +#### -------------------------------------------------------------------------- +#--- ... Additional functions ... +#### -------------------------------------------------------------------------- +def check_dates(a,b): + """Returns the array of dates from the two objects `a` or `b` (or None).""" + if isTimeSeries(a): + if isTimeSeries(b) and (a._dates == b._dates).all() is False: + raise ValueError, "Incompatible dates !" + return a._dates + elif isTimeSeries(b): + return b._dates + else: + return + +def parse_period(period): + """Returns a TimeArray couple (starting date; ending date) from the arguments.""" +#### print "........DEBUG PARSE DATES: period %s is %s" % (period, type(period)) +# if isinstance(period,TimeArray) or isinstance(period,Dates): +#### print "........DEBUG PARSE_PERIOD: OK" + if isinstance(period,TimeArray): + return (period[0],period[-1]) + elif hasattr(period,"__len__"): + if not isinstance(period[0], TimeArray): + tstart = TimeArray(period[0]) + else: + tstart = period[0] + if not isinstance(period[-1], TimeArray): + tend = TimeArray(period[-1]) + else: + tend = period[-1] + return (tstart, tend) + else: + p = N.asarray(period) + if N.all(p < 9999): + p = N.array(period,dtype="|S4") + p = time_array(p) + return (p[0], p[-1]) + +def where_period(period, dates, *choices): + """Returns choices fro True/False, whether dates fall during a given period. +If no choices are given, outputs the array indices for the dates falling in the +period. + +:Parameters: + `period` : Sequence + Selection period, as a sequence (starting date, ending date). + `dates` : TimeArray + Array of dates. + `choices` : *(optional)* + Arrays to select from when the condition is True/False. + """ + (tstart, tend) = parse_period(period) + condition = ascondition((dates>=tstart)&(dates<=tend)) + condition = (dates>=tstart)&(dates<=tend) + return N.where(condition, *choices) + +def masked_inside_period(data, period, dates=None): + """Returns x as an array masked where dates fall inside the selection period, +as well as where data are initially missing (masked).""" + (tstart, tend) = parse_period(period) + # Get dates .................. + if hasattr(data, "_dates"): + dates = data._dates + elif dates is None: + raise ValueError,"Undefined dates !" + else: + assert(N.size(dates)==N.size(data), + "Inconsistent data and dates sizes!") + # where_period yields True inside the period, when mask should yield False + condition = ascondition(N.logical_and((dates>=tstart), (dates<=tend))) + cm = filled(condition,True).reshape(data.shape) + mask = mask_or(MA.getmaskarray(data), cm, copy=True) + if isinstance(data, MaskedTimeSeries): + return data.__class__(data._data, dates=dates, mask=mask, copy=True) + if isinstance(data, TimeSeries): + return MaskedTimeSeries(data, dates=dates, mask=mask, copy=True) + else: + return masked_array(data, mask=mask, copy=True) + +def masked_outside_period(data, period, dates=None): + """Returns x as an array masked where dates fall outside the selection period, +as well as where data are initially missing (masked).""" + (tstart, tend) = parse_period(period) + if hasattr(data, "_dates"): + dates = data._dates + elif dates is None: + raise ValueError,"Undefined dates !" + else: + assert(N.size(dates)==N.size(data), + "Inconsistent data and dates sizes!") + #................ + condition = ascondition(N.logical_or((datestend))) + cm = filled(condition,True).reshape(data.shape) + mask = mask_or(MA.getmaskarray(data), cm, copy=True) + if isinstance(data, MaskedTimeSeries): + return data.__class__(data._data, dates=dates, mask=mask, copy=True) + if isinstance(data, TimeSeries): + return MaskedTimeSeries(data, dates=dates, mask=mask, copy=True) + else: + return masked_array(data, mask=mask, copy=True) + +#.............................................................................. +def fill_missing_dates(dates,data,resolution=None,fill_value=None): + """Finds and fills the missing dates in a time series, and allocates a +default filling value to the data corresponding to the newly added dates. + +:Parameters: + `dates` + Initial array of dates. + `data` + Initial array of data. + `resolution` : float *[None]* + New date resolutions, in years. For example, a value of 1/365.25 indicates + a daily resolution. If *None*, the initial resolution is used instead. + `fill_value` : float + Default value for missing data. + """ + if not isinstance(dates, TimeArray): + print "DEBUG FILL_MISSING_DATES: dates was %s" % type(dates) + dates = TimeArray(dates) + print "DEBUG FILL_MISSING_DATES: dates is %s" % type(dates) + dflat = dates.ravel() + n = len(dflat) + # Get data ressolution ....... + if resolution is None: + resolution = dflat.resolution + if resolution >= 28 and resolution <= 31: + resolution = 30 + else: + resolution = int(1./float(resolution)) + # Find on what to fill ....... + if resolution == 1: + (resol, freq, refdelta) = (DAILY, 1, dtmdelta.relativedelta(days=+1)) + elif resolution == 7: + (resol, freq, refdelta) = (WEEKLY, 1, dtmdelta.relativedelta(days=+7)) + elif resolution == 30: + (resol, freq, refdelta) = (MONTHLY, 1, dtmdelta.relativedelta(months=+1)) + elif resolution == 365: + (resol, freq, refdelta) = (YEARLY, 1, dtmdelta.relativedelta(years=+1)) + else: + raise ValueError,\ + "Unable to define a proper date resolution (found %s)." % resolution + # ...and now, fill it ! ...... + (tstart, tend) = dflat.asobjects()[[0,-1]].tolist() + gaprule = dtmrule.rrule(resol, interval=freq, dtstart=tstart, until=tend) + newdates = dates.__class__(list(gaprule)) + #............................. + # Get the steps between consecutive data. We need relativedelta to deal w/ months + delta = N.array([dtmdelta.relativedelta(b,a) + for (b,a) in N.broadcast(dflat[1:],dflat[:-1])]) + dOK = N.equal(delta,refdelta) + slcid = N.r_[[0,], N.arange(1,n).compress(-dOK), [n,]] + oldslc = N.array([slice(i,e) for (i,e) in N.broadcast(slcid[:-1],slcid[1:])]) + if resolution == 1: + addidx = N.cumsum([d.days for d in N.diff(dflat).compress(-dOK)]) + elif resolution == 30: + addidx = N.cumsum([d.years*12+d.months for d in delta.compress(-dOK)]) + elif resolution == 365: + addidx = N.cumsum([d.years for d in delta.compress(-dOK)]) + addidx -= N.arange(len(addidx)) + newslc = N.r_[[oldslc[0]], + [slice(i+d-1,e+d-1) for (i,e,d) in \ + N.broadcast(slcid[1:-1],slcid[2:],addidx)] + ] +# misslc = [slice(i,i+d-1) +# for (i,d) in N.broadcast(slcid[1:-1],addidx)] + #............................. + # Just a quick check + for (osl,nsl) in zip(oldslc,newslc): + assert N.equal(dflat[osl],newdates[nsl]).all(),\ + "Slicing mishap ! Please check %s (old) and %s (new)" % (osl,nsl) + #............................. + data = MA.asarray(data) + oldmask = MA.getmaskarray(data) + newdata = N.empty(newdates.size,data.dtype) + newmask = N.ones(newdates.size, bool_) + if fill_value is None: + if hasattr(data,'fill_value'): + fill_value = data.fill_value + else: + fill_value = MA.default_fill_value(data) + data = data.filled(fill_value) + newdata.fill(fill_value) + #.... + for (new,old) in zip(newslc,oldslc): + newdata[new] = data[old] + newmask[new] = oldmask[old] +# for mis in misslc: +# newdata[mis].fill(fill_value) + # Get new shape .............. + if data.ndim == 1: + nshp = (newdates.size,) + else: + nshp = tuple([-1,] + list(data.shape[1:])) + return MaskedTimeSeries(newdata.reshape(nshp), + dates=newdates.reshape(nshp), + mask=newmask.reshape(nshp), + fill_value=fill_value) + +######-------------------------------------------------------------------------- +##---- --- Archiving --- +######-------------------------------------------------------------------------- +#import iodata.iotools as iotools +#def archive(timeseries,filename,compression=None): +# data = timeseries.asrecords() +# iotools.archive(data, filename, compression) +# +#def unarchive(filename): +# raise NotImplementedError + + +############################################################################### \ No newline at end of file Added: trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,159 @@ +import numpy +import maskedarray as MA + + +#####--------------------------------------------------------------------------- +#---- --- Generic functions --- +#####--------------------------------------------------------------------------- +def first_unmasked_val(a): + "Returns the first unmasked value in a 1d maskedarray." + (i,j) = MA.extras.flatnotmasked_edges(a) + return a[i] + +def last_unmasked_val(a): + "Returns the last unmasked value in a 1d maskedarray." + (i,j) = MA.extras.flatnotmasked_edges(a) + return a[j] + +def reverse_dict(d): + "Reverses the keys and values of a dictionary." + alt = [] + tmp = [alt.extend([(w,k) for w in v]) for (k,v) in d.iteritems()] + return dict(alt) + + + +#####--------------------------------------------------------------------------- +#---- --- Option conversion --- +#####--------------------------------------------------------------------------- +obs_dict = {"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 +# +def fmtObserv(obStr): + "Converts a possible 'Observed' string into acceptable values." + if obStr is None: + return None + elif obStr.upper() in obs_dict.keys(): + return obStr.upper() + else: + raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) + + +fmtfreq_dict = {'A': ['ANNUAL','ANNUALLY','YEAR','YEARLY'], + 'B': ['BUSINESS','BUSINESSLYT'], + 'D': ['DAY','DAILY',], + 'H': ['HOUR','HOURLY',], + 'M': ['MONTH','MONTHLY',], + 'Q': ['QUARTER','QUARTERLY',], + 'S': ['SECOND','SECONDLY',], + 'T': ['MINUTE','MINUTELY',], + 'W': ['WEEK','WEEKLY',], + 'U': ['UNDEF','UNDEFINED'], + } +fmtfreq_revdict = reverse_dict(fmtfreq_dict) + +def fmtFreq (freqStr): + "Converts a possible 'frequency' string to acceptable values." + if freqStr is None: + return None + elif freqStr.upper() in fmtfreq_dict.keys(): + return freqStr[0].upper() + elif freqStr.upper() in fmtfreq_revdict.keys(): + return fmtfreq_revdict[freqStr.upper()] + else: + raise ValueError("Invalid frequency: %s " % str(freqStr)) + +class DateSpec: + "Fake data type for date variables." + def __init__(self, freq): + self.freq = fmtFreq(freq) + + def __hash__(self): + return hash(self.freq) + + def __eq__(self, other): + if hasattr(other, "freq"): + return self.freq == other.freq + else: + return False + def __str__(self): + return "Date(%s)" % str(self.freq) + + + +# define custom numpy types. +# Note: A more robust approach would register these as actual valid numpy types +# this is just a hack for now +numpy.dateA = DateSpec("Annual") +numpy.dateB = DateSpec("Business") +numpy.dateD = DateSpec("Daily") +numpy.dateH = DateSpec("Hourly") +numpy.dateM = DateSpec("Monthly") +numpy.dateQ = DateSpec("Quarterly") +numpy.dateS = DateSpec("Secondly") +numpy.dateT = DateSpec("Minutely") +numpy.dateW = DateSpec("Weekly") +numpy.dateU = DateSpec("Undefined") + + +freq_type_mapping = {'A': numpy.dateA, + 'B': numpy.dateB, + 'D': numpy.dateD, + 'H': numpy.dateH, + 'M': numpy.dateM, + 'Q': numpy.dateQ, + 'S': numpy.dateS, + 'T': numpy.dateT, + 'W': numpy.dateW, + 'U': numpy.dateU, + } + +def freqToType(freq): + return freq_type_mapping[fmtFreq(freq)] + +def isDateType(dtype): + #TODO: That looks messy. We should simplify that + if len([x for x in freq_type_mapping.values() if x == dtype]) > 0: + return True + else: + return False + +#####--------------------------------------------------------------------------- +#---- --- Misc functions --- +#####--------------------------------------------------------------------------- +#def flatten(listOfLists): +# return list(chain(*listOfLists)) +#http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348 +def flatten(iterable): + """Flattens a compound of nested iterables.""" + itm = iter(iterable) + for elm in itm: + if hasattr(elm,'__iter__') and not isinstance(elm, basestring): + for f in flatten(elm): + yield f + else: + yield elm + +def flatargs(*args): + "Flattens the arguments." + if not hasattr(args, '__iter__'): + return args + else: + return flatten(args) + + Added: trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,1054 @@ +""" +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + +import datetime +import itertools +import warnings + + +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 maskedarray as MA +#reload(MA) + +import tscore as corelib +#reload(corelib) +from tscore import isDateType + +#from corelib import fmtFreq, freqToType +import mx.DateTime as mxD +from mx.DateTime.Parser import DateFromString as mxDFromString + + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) +daflog = logging.getLogger('darray_from') +dalog = logging.getLogger('DateArray') + +#TODO: - it's possible to change the freq on the fly, e.g. mydateD.freq = 'A' +#TODO: ...We can prevent that by making freq a readonly property, or call dateOf +#TODO: ...or decide it's OK +#TODO: - Do we still need dateOf, or should we call cseries.convert instead ? +#TODO: - It'd be really nice if cseries.convert could accpt an array, +#TODO: ...that way, we could call it instead of looping in asfreq + +secondlyOriginDate = mxD.Date(1980) - mxD.DateTimeDeltaFrom(seconds=1) +minutelyOriginDate = mxD.Date(1980) - mxD.DateTimeDeltaFrom(minute=1) +hourlyOriginDate = mxD.Date(1980) - mxD.DateTimeDeltaFrom(hour=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 `mxDate` keyword with an existing mx.DateTime.DateTime object, or + even a datetime.datetime object. + + >>> td.Date('D', mxDate=mx.DateTime.now()) + >>> td.Date('D', mxDate=datetime.datetime.now()) + """ + def __init__(self, freq, year=None, month=None, day=None, quarter=None, + hours=None, minutes=None, seconds=None, + mxDate=None, value=None, string=None): + + if hasattr(freq, 'freq'): + self.freq = corelib.fmtFreq(freq.freq) + else: + self.freq = corelib.fmtFreq(freq) + self.type = corelib.freqToType(self.freq) + + if value is not None: + if self.freq == 'A': + self.mxDate = mxD.Date(value, -1, -1) + elif self.freq == 'B': + value -= 1 + self.mxDate = mxD.DateTimeFromAbsDays(value + (value//5)*7 - (value//5)*5) + elif self.freq in ['D','U']: + self.mxDate = mxD.DateTimeFromAbsDays(value-1) + elif self.freq == 'H': + self.mxDate = hourlyOriginDate + mxD.DateTimeDeltaFrom(hours=value) + elif self.freq == 'M': + self.mxDate = mxD.Date(0) + \ + mxD.RelativeDateTime(months=value-1, day=-1) + elif self.freq == 'Q': + self.mxDate = mxD.Date(0) + \ + mxD.RelativeDateTime(years=(value // 4), + month=((value * 3) % 12), day=-1) + elif self.freq == 'S': + self.mxDate = secondlyOriginDate + mxD.DateTimeDeltaFromSeconds(value) + elif self.freq == 'T': + self.mxDate = minutelyOriginDate + mxD.DateTimeDeltaFrom(minutes=value) + elif self.freq == 'W': + self.mxDate = mxD.Date(0) + \ + mxD.RelativeDateTime(weeks=value-5./7-1) + + elif string is not None: + self.mxDate = mxDFromString(string) + + elif mxDate is not None: + if isinstance(mxDate, datetime.datetime): + mxDate = mxD.strptime(mxDate.isoformat()[:19], "%Y-%m-%dT%H:%M:%S") + self.mxDate = mxDate + + else: + # First, some basic checks..... + if year is None: + raise InsufficientDateError + if self.freq in ('B', 'D', 'W'): + if month is None or day is None: + raise InsufficientDateError + elif self.freq == 'M': + if month is None: + raise InsufficientDateError + day = -1 + elif self.freq == 'Q': + if quarter is None: + raise InsufficientDateError + month = quarter * 3 + day = -1 + elif self.freq == 'A': + month = -1 + day = -1 + elif self.freq == 'S': + if month is None or day is None or seconds is None: + raise InsufficientDateError + + if self.freq in ['A','B','D','M','Q','W']: + self.mxDate = mxD.Date(year, month, day) + if self.freq == 'B': + if self.mxDate.day_of_week in [5,6]: + raise ValueError("Weekend passed as business day") + elif self.freq in ['H','S','T']: + if not hours: + if not minutes: + if not seconds: + hours = 0 + else: + hours = seconds//3600 + else: + hours = minutes // 60 + if not minutes: + if not seconds: + minutes = 0 + else: + minutes = (seconds-hours*3600)//60 + if not seconds: + seconds = 0 + else: + seconds = seconds % 60 + self.mxDate = mxD.Date(year, month, day, hours, minutes, seconds) + self.value = self.__value() + # FIXME: Shall we set them as properties ? + def day(self): + "Returns the day of month." + return self.mxDate.day + def day_of_week(self): + "Returns the day of week." + return self.mxDate.day_of_week + def day_of_year(self): + "Returns the day of year." + return self.mxDate.day_of_year + def month(self): + "Returns the month." + return self.mxDate.month + def quarter(self): + "Returns the quarter." + return monthToQuarter(self.mxDate.month) + def year(self): + "Returns the year." + return self.mxDate.year + def second(self): + "Returns the seconds." + return int(self.mxDate.second) + def minute(self): + "Returns the minutes." + return int(self.mxDate.minute) + def hour(self): + "Returns the hour." + return int(self.mxDate.hour) + def week(self): + "Returns the week." + return self.mxDate.iso_week[1] + + def __add__(self, other): + if isinstance(other, Date): + raise FrequencyDateError("Cannot add dates", self.freq, other.freq) + 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.freq, other.freq) + 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 subtract dates", \ + self.freq, other.freq) + return int(self) == int(other) + + def __cmp__(self, other): + if not hasattr(other, 'freq'): + return False + elif self.freq != other.freq: + raise FrequencyDateError("Cannot subtract dates", \ + self.freq, other.freq) + 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.freq == 'A': + val = int(self.mxDate.year) + # Business days. + elif self.freq == 'B': + days = self.mxDate.absdate + weeks = days // 7 + val = int((weeks*5) + (days - weeks*7)) + # Daily/undefined + elif self.freq in ['D', 'U']: + val = self.mxDate.absdate + # Hourly........ + elif self.freq == 'H': + val = int((self.mxDate - hourlyOriginDate).hours) + # Monthly....... + elif self.freq == 'M': + val = self.mxDate.year*12 + self.mxDate.month + # Quarterly..... + elif self.freq == 'Q': + val = int(self.mxDate.year*4 + self.mxDate.month/3) + # Secondly...... + elif self.freq == 'S': + val = int((self.mxDate - secondlyOriginDate).seconds) + # Minutely...... + elif self.freq == 'T': + val = int((self.mxDate - minutelyOriginDate).minutes) + # Weekly........ + elif self.freq == 'W': + val = int(self.mxDate.year*365.25/7.-1) + self.mxDate.iso_week[1] + return val + #...................................................... + def default_fmtstr(self): + "Defines the default formats for printing Dates." + if self.freq == "A": + fmt = "%Y" + elif self.freq in ("B","D"): + fmt = "%d-%b-%y" + elif self.freq == "M": + fmt = "%b-%Y" + elif self.freq == "Q": + fmt = "%YQ%q" + elif self.freq in ("H","S","T"): + fmt = "%d-%b-%Y %H:%M:%S" + elif self.freq == "W": + fmt = "%YW%W" + else: + fmt = "%d-%b-%y" + return fmt + + def strfmt(self, fmt): + "Formats the date" + qFmt = fmt.replace("%q", "XXXX") + tmpStr = self.mxDate.strftime(qFmt) + return tmpStr.replace("XXXX", str(self.quarter())) + + def __str__(self): + return self.strfmt(self.default_fmtstr()) + + def __repr__(self): + return "<%s : %s>" % (str(self.freq), str(self)) + #...................................................... + def toordinal(self): + "Returns the date as an ordinal." + return self.mxDate.absdays + + def fromordinal(self, ordinal): + "Returns the date as an ordinal." + return Date(self.freq, mxDate=mxD.DateTimeFromAbsDays(ordinal)) + + def tostring(self): + "Returns the date as a string." + return str(self) + + def toobject(self): + "Returns the date as itself." + return self + + def asfreq(self, toFreq, relation='before'): + """Converts the date to a new frequency.""" + return dateOf(self, toFreq, relation) + + 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 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.fmtFreq(freq) + tempDate = mxD.now() + # if it is Saturday or Sunday currently, freq==B, then we want to use Friday + if freq == 'B' and tempDate.day_of_week >= 5: + tempDate -= (tempDate.day_of_week - 4) + if freq in ('B','D','H','S','T','W'): + return Date(freq, mxDate=tempDate) + elif freq == 'M': + return Date(freq, year=tempDate.year, month=tempDate.month) + elif freq == 'Q': + return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) + elif freq == '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 = mxD.localtime() + 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 dateOf(date, toFreq, relation="BEFORE"): + """Returns a date converted to another frequency `toFreq`, according to the + relation `relation` .""" + toFreq = corelib.fmtFreq(toFreq) + _rel = relation.upper()[0] + if _rel not in ['B', 'A']: + msg = "Invalid relation '%s': Should be in ['before', 'after']" + raise ValueError, msg % relation + elif _rel == 'B': + before = True + else: + before = False + + if not isDateType(date): + raise DateError, "Date should be a valid Date instance!" + + if date.freq == toFreq: + return date + # Convert to annual .................... + elif toFreq == 'A': + return Date(freq='A', year=date.year()) + # Convert to quarterly ................. + elif toFreq == 'Q': + if date.freq == 'A': + if before: + return Date(freq='A', year=date.year(), quarter=1) + else: + return Date(freq='A', year=date.year(), quarter=4) + else: + return Date(freq='Q', year=date.year(), quarter=date.quarter()) + # Convert to monthly.................... + elif toFreq == 'M': + if date.freq == 'A': + if before: + return Date(freq='M', year=date.year(), month=1) + else: + return Date(freq='M', year=date.year(), month=12) + elif date.freq == 'Q': + if before: + return dateOf(date-1, 'M', "AFTER")+1 + else: + return Date(freq='M', year=date.year(), month=date.month()) + else: + return Date(freq='M', year=date.year(), month=date.month()) + # Convert to weekly .................... + elif toFreq == 'W': + if date.freq == 'A': + if before: + return Date(freq='W', year=date.year(), month=1, day=1) + else: + return Date(freq='W', year=date.year(), month=12, day=-1) + elif date.freq in ['Q','M']: + if before: + return dateOf(date-1, 'W', "AFTER")+1 + else: + return Date(freq='W', year=date.year(), month=date.month()) + else: + val = date.weeks() + int(date.year()*365.25/7.-1) + return Date(freq='W', value=val) + # Convert to business days.............. + elif toFreq == 'B': + if date.freq in ['A','Q','M','W']: + if before: + return dateOf(dateOf(date, 'D'), 'B', "AFTER") + else: + return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") + elif date.freq == 'D': + # BEFORE result: preceeding Friday if date is a weekend, same day otherwise + # AFTER result: following Monday if date is a weekend, same day otherwise + tempDate = date.mxDate + if before: + if tempDate.day_of_week >= 5: + tempDate -= (tempDate.day_of_week - 4) + else: + if tempDate.day_of_week >= 5: + tempDate += 7 - tempDate.day_of_week + return Date(freq='B', mxDate=tempDate) + else: + if before: + return dateOf(dateOf(date, 'D'), 'B', "BEFORE") + else: + return dateOf(dateOf(date, 'D'), 'B', "AFTER") + # Convert to day ....................... + elif toFreq == 'D': + # ...from annual + if date.freq == 'A': + if before: + return Date(freq='D', year=date.year(), month=1, day=1) + else: + return Date(freq='D', year=date.year(), month=12, day=31) + # ...from quarter + elif date.freq == 'Q': + if before: + return dateOf(date-1, 'D', "AFTER")+1 + else: + return Date(freq='D', year=date.year(), month=date.month(), + day=date.day()) + # ...from month + elif date.freq == 'M': + if before: + return Date(freq='D', year=date.year(), month=date.month(), day=1) + else: + (mm,yy) = (date.month(), date.year()) + if date.month() == 12: + (mm, yy) = (1, yy + 1) + else: + mm = mm + 1 + return Date('D', year=yy, month=mm, day=1)-1 + # ...from week + elif date.freq == 'W': + if before: + return Date(freq='D', year=date.year(), month=date.month(), + day=date.day()) + else: + ndate = date + 1 + return Date(freq='D', year=ndate.year(), month=ndate.month(), + day=ndate.day()) + # ...from a lower freq + else: + return Date('D', year=date.year(), month=date.month(), day=date.day()) + #Convert to hour........................ + elif toFreq == 'H': + if date.freq in ['A','Q','M','W']: + if before: + return dateOf(dateOf(date, 'D', "BEFORE"), 'H', "BEFORE") + else: + return dateOf(dateOf(date, 'D', "AFTER"), 'H', "AFTER") + if date.freq in ['B','D']: + if before: + return Date(freq='H', year=date.year(), month=date.month(), + day=date.day(), hours=0) + else: + return Date(freq='H', year=date.year(), month=date.month(), + day=date.day(), hours=23) + else: + return Date(freq='H', year=date.year(), month=date.month(), + day=date.day(), hours=date.hour()) + #Convert to second...................... + elif toFreq == 'T': + if date.freq in ['A','Q','M','W']: + if before: + return dateOf(dateOf(date, 'D', "BEFORE"), 'T', "BEFORE") + else: + return dateOf(dateOf(date, 'D', "AFTER"), 'T', "AFTER") + elif date.freq in ['B','D','H']: + if before: + return Date(freq='T', year=date.year(), month=date.month(), + day=date.day(), minutes=0) + else: + return Date(freq='T', year=date.year(), month=date.month(), + day=date.day(), minutes=24*60-1) + else: + return Date(freq='H', year=date.year(), month=date.month(), + day=date.day(), hours=date.hour(), minutes=date.minute()) + #Convert to minute...................... + elif toFreq == 'S': + if date.freq in ['A','Q','M','W']: + if before: + return dateOf(dateOf(date, 'D', "BEFORE"), 'S', "BEFORE") + else: + return dateOf(dateOf(date, 'D', "AFTER"), 'S', "AFTER") + elif date.freq in ['B','D']: + if before: + return Date(freq='S', year=date.year(), month=date.month(), + day=date.day(), seconds=0) + else: + return Date(freq='S', year=date.year(), month=date.month(), + day=date.day(), seconds=24*60*60-1) + +def isDate(data): + "Returns whether `data` is an instance of Date." + return isinstance(data, Date) + + +#####--------------------------------------------------------------------------- +#---- --- DateArray --- +#####--------------------------------------------------------------------------- +ufunc_dateOK = ['add','subtract', + 'equal','not_equal','less','less_equal', 'greater','greater_equal', + 'isnan'] + +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. + """ + def __new__(cls, dates=None, freq='U', copy=False): + #dalog.info("__new__ received %s [%i]" % (type(dates), numpy.size(dates))) + if isinstance(dates, DateArray): + #dalog.info("__new__ sends %s as %s" % (type(dates), cls)) + cls.__defaultfreq = dates.freq + if not copy: + return dates.view(cls) + return dates.copy().view(cls) + else: + _dates = numeric.asarray(dates, dtype=int_) + if copy: + _dates = _dates.copy() + #dalog.info("__new__ sends %s as %s" % (type(_dates), cls)) + if freq is None: + freq = 'U' + cls.__defaultfreq = corelib.fmtFreq(freq) + (cls.__toobj, cls.__toord, cls.__tostr) = (None, None, None) + (cls.__steps, cls.__full, cls.__hasdups) = (None, None, None) + return _dates.view(cls) + + 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): + #dalog.info("__array_finalize__ received %s" % type(obj)) + if hasattr(obj, 'freq'): + self.freq = obj.freq + else: + self.freq = self.__defaultfreq + #dalog.info("__array_finalize__ sends %s" % type(self)) + + def __getitem__(self, index): + #dalog.info("__getitem__ got index %s (%s)"%(index, type(index))) + if isDateType(index): + index = self.find_dates(index) + elif numeric.asarray(index).dtype.kind == 'O': + try: + index = self.find_dates(index) + except AttributeError: + pass + r = ndarray.__getitem__(self, index) + if r.size == 1: + # Only one element, and it's not a scalar: we have a DateArray of size 1 + if len(r.shape) > 0: + r = r.item() + return Date(self.freq, value=r) + else: + return r + + def __repr__(self): + return ndarray.__repr__(self) + #...................................................... + @property + def years(self): + "Returns the years." + return numeric.asarray([d.year() for d in self], dtype=int_) + @property + def months(self): + "Returns the months." + return numeric.asarray([d.month() for d in self], dtype=int_) + @property + def day_of_year(self): + "Returns the days of years." + return numeric.asarray([d.day_of_year() for d in self], dtype=int_) + yeardays = day_of_year + @property + def day_of_week(self): + "Returns the days of week." + return numeric.asarray([d.day_of_week() for d in self], dtype=int_) + #.... Conversion methods .................... +# def toobject(self): +# "Converts the dates from ordinals to Date objects." +# # Note: we better try to cache the result +# if self.__toobj is None: +## toobj = numeric.empty(self.size, dtype=object_) +## toobj[:] = [Date(self.freq, value=d) for d in self] +## self.__toobj = toobj +# self.__toobj = self +# return self.__toobj + # + 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.__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.__toord = toord + return self.__toord + # + def tostring(self): + "Converts the dates to strings." + # Note: we better cache the result + if self.__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.__tostr = tostr + return self.__tostr + # + def asfreq(self, freq=None): + "Converts the dates to another frequency." + # Note: As we define a new object, we don't need caching + if freq is None: + return self + freq = corelib.fmtFreq(freq) + if freq == self.freq: + return self + if self.isvalid(): + new = numeric.arange(self.size, dtype=int_) + new += self[0].asfreq(freq).value + else: + new = numpy.fromiter((d.asfreq(freq).value for d in self), + dtype=float_) + 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 ValueError, "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 ValueError, "Date out of bounds!" + return index + else: + index_asarray = (self == date.value).nonzero() + if fromnumeric.size(index_asarray) == 0: + raise ValueError, "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 daily!") + if self.__steps is None: + steps = numeric.asarray(numpy.diff(self)) + if steps.size > 0: + if self.__full is None: + self.__full = (steps.max() == 1) + if self.__hasdups is None: + self.__hasdups = (steps.min() == 0) + else: + self.__full = True + self.__hasdups = False + self.__steps = steps + return self.__steps + + def has_missing_dates(self): + "Returns whether the DateArray have missing dates." + if self.__full is None: + steps = self.get_steps() + return not(self.__full) + + def isfull(self): + "Returns whether the DateArray has no missing dates." + if self.__full is None: + steps = self.get_steps() + return self.__full + + def has_duplicated_dates(self): + "Returns whether the DateArray has duplicated dates." + if self.__hasdups is None: + steps = self.get_steps() + return self.__hasdups + + def isvalid(self): + "Returns whether the DateArray is valid: no missing/duplicated dates." + return (self.isfull() and not self.has_duplicated_dates()) + #...................................................... +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 + #dalog.info('__datearithmetics got method %s' % methodname) + # + 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' + #dalog.info('__datearithmetics got other %s' % type(other)) + method = getattr(super(DateArray,instance), self.methodname) + if isinstance(other, DateArray): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) +# other = + elif isDateType(other): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) + other = other.value + #dalog.info('__datearithmetics got other %s' % type(other)) + 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) +#............................ +DateArray.__add__ = _datearithmetics('__add__', asdates=True) +DateArray.__radd__ = _datearithmetics('__add__', asdates=True) +DateArray.__sub__ = _datearithmetics('__sub__', asdates=True) +DateArray.__rsub__ = _datearithmetics('__rsub__', asdates=True) +DateArray.__le__ = _datearithmetics('__le__', asdates=False) +DateArray.__lt__ = _datearithmetics('__lt__', asdates=False) +DateArray.__ge__ = _datearithmetics('__ge__', asdates=False) +DateArray.__gt__ = _datearithmetics('__gt__', asdates=False) +DateArray.__eq__ = _datearithmetics('__eq__', asdates=False) +DateArray.__ne__ = _datearithmetics('__ne__', asdates=False) + +#####--------------------------------------------------------------------------- +#---- --- 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() + # Case #1: dates as strings ................. + if dlist.dtype.kind == 'S': + #...construct a list of ordinals + ords = numpy.fromiter((mxDFromString(s).absdays 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 ['i','f']: + #...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 isDateType(template): + dates = numpy.fromiter((d.value for d in dlist), float_) + #...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, mxDate=m) for m in dlist] + #...as datetime objects + elif hasattr(dlist[0], 'toordinal'): + ords = numpy.fromiter((d.toordinal() for d in dlist), float_) + if freq is None: + freq = guess_freq(ords) + dates = [Date(freq, mxDate=mxD.DateTimeFromAbsDays(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.fmtFreq(freq) + # Case #1: we have a list ................... + if dlist is not None: + # Already a DateArray.................... + if isinstance(dlist, DateArray): + if freq != dlist.freq: + return dlist.asfreq(freq) + else: + return dlist + return _listparser(dlist, freq) + # Case #2: we have a starting date .......... + if start_date is None: + raise InsufficientDateError + if not isDateType(start_date): + raise DateError, "Starting date should be a valid Date instance!" + # Check if we have an end_date + if end_date is None: + if length is None: + raise ValueError,"No length precised!" + else: + assert(isDateType(end_date), + "Starting date should be a valid Date instance!") + length = 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: + 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') + + +################################################################################ +if __name__ == '__main__': +# from maskedarray.testutils import assert_equal + import datetime + if 1: + # get the last day of this year, at daily frequency + dLastDayOfYear = dateOf(thisday('A'),'D','AFTER') + if 0: + # get the first day of this year, at business frequency + bFirstDayOfYear = dateOf(thisday('A'),'B','BEFORE') + # get the last day of the previous quarter, business frequency + bLastDayOfLastQuarter = dateOf(thisday('Q')-1,'B','AFTER') + # dateOf can also go from high frequency to low frequency. In this case, the third parameter has no impact + aTrueValue = (thisday('Q') == dateOf(thisday('b'),'Q')) + # dates of the same frequency can be subtracted (but not added obviously) + numberOfBusinessDaysPassedThisYear = thisday('b') - bFirstDayOfYear + + # integers can be added/substracted to/from dates + fiveDaysFromNow = thisday('d') + 5 + + # get the previous business day, where business day is considered to + # end at day_end_hour and day_end_min + pbd = prevbusday(day_end_hour=18,day_end_min=0) + + # construct a date object explicitly + myDateQ = Date(freq='Q',year=2004,quarter=3) + myDateD = Date(freq='D',year=1985,month=10,day=4) + + #------------------------------------------------ Added: trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-02 17:39:21 UTC (rev 2475) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-02 17:54:31 UTC (rev 2476) @@ -0,0 +1,1506 @@ +# 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. + +These two classes were liberally adapted from `MaskedArray` class. + + + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + + +import logging +import weakref + + +import numpy +from numpy.core import bool_, float_, int_ +import numpy.core.fromnumeric as fromnumeric +import numpy.core.numeric as numeric +import numpy.core.umath as umath +from numpy import ndarray +from numpy.core.records import recarray +from numpy.core.records import fromarrays as recfromarrays + +#from cPickle import dump, dumps + +import maskedarray as MA +#import numpy.core.ma as MA +reload(MA) +#MaskedArray = MA.MaskedArray +from maskedarray.core import MaskedArray +masked = MA.masked +nomask = MA.nomask +MAError = MA.MAError +masked_array = MA.masked_array +filled = MA.filled +getmask = MA.getmask +getmaskarray = MA.getmaskarray +make_mask_none = MA.make_mask_none +mask_or = MA.mask_or +make_mask = MA.make_mask + +oldma = (MA.__name__ == 'numpy.core.ma') + +import tscore as corelib +#reload(corelib) +from tscore import * + +import tsdate +reload(tsdate) +from tsdate import DateError, InsufficientDateError +from tsdate import Date, isDate, DateArray, isDateArray, \ + date_array, date_array_fromlist, date_array_fromrange, thisday + +import cseries +reload(cseries) + +#............................................................................... +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) +talog = logging.getLogger('log.TimeArray') +tslog = logging.getLogger('TimeSeries') +btslog = logging.getLogger('BaseTimeSeries') + +ufunc_domain = {} +ufunc_fills = {} + +#### -------------------------------------------------------------------------- +#--- ... TimeSeriesError class ... +#### -------------------------------------------------------------------------- +class TimeSeriesError(Exception): + "Class for TS related errors." + def __init__ (self, args=None): + "Creates an exception." + Exception.__init__(self) + self.args = args + def __str__(self): + "Calculates the string representation." + return str(self.args) + __repr__ = __str__ + +class TimeSeriesCompatibilityError(TimeSeriesError): + """Defines the exception raised when series are incompatible.""" + def __init__(self, mode, first, second): + if mode == 'freq': + msg = "Incompatible time steps! (%s <> %s)" + elif mode == 'start_date': + msg = "Incompatible starting dates! (%s <> %s)" + elif mode == 'size': + msg = "Incompatible sizes! (%s <> %s)" + msg = msg % (first, second) + TimeSeriesError.__init__(self, msg) + + +#def _compatibilitycheck(a, b): +def _timeseriescompat(a, b): + """Checks the date compatibility of two TimeSeries object. + Returns True if everything's fine, or raises an exception.""" + if not (hasattr(a,'freq') and hasattr(b, 'freq')): + return True + if a.freq != b.freq: + raise TimeSeriesCompatibilityError('freq', a.freq, b.freq) + elif a.start_date() != b.start_date(): + raise TimeSeriesCompatibilityError('start_date', a.start_date(), b.start_date()) + elif a.shape != b.shape: + raise TimeSeriesCompatibilityError('size', str(a.shape), str(b.shape)) + return True + +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.""" + # If there's only 1 element, the date is a Date object, which has no size... + tsize = numeric.size(dates) + dsize = data.size + # Only one data + if dsize == tsize: + return True + elif data.ndim > 1: + dsize = numeric.asarray(data.shape[1:]).prod() + if dsize == tsize: + return True + raise TimeSeriesCompatibilityError('size', dsize, tsize) + + +##### -------------------------------------------------------------------------- +##--- ... Time Series ... +##### -------------------------------------------------------------------------- +if oldma: + parentclass = ndarray +else: + parentclass = MaskedArray +# +class TimeSeries(parentclass, 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. + """ + def __new__(cls, data, dates=None, mask=nomask, + freq=None, observed=None, start_date=None, + dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False): + #tslog.info("__new__: received data types %s, %s" % (type(data), data)) + options = dict(copy=copy, dtype=dtype, fill_value=fill_value, + keep_mask=keep_mask, small_mask=small_mask, + hard_mask=hard_mask, ) + if isinstance(data, TimeSeries): + # Check dates ........ + if dates is None: + newdates = data._dates + else: + if not hasattr(dates,'freq'): + raise DateError, "Invalid Dates!" + newdates = dates + data._dates = newdates + if hasattr(data, '_data') and hasattr(data._data, '_dates'): + data._data._dates = newdates + cls._defaultdates = newdates + # Check frequency...... + if freq is not None: + freq = corelib.fmtFreq(freq) + if freq != newdates.freq: + _dates = newdates.tofreq(freq) + else: + freq = newdates.freq + # Check observed....... + if observed is not None: + observed = data._observed + cls._defaultobserved = observed + _data = data._series + else: + # Check dates ........ + if dates is None: + if numeric.ndim(data) >= 2: + length = numeric.asarray(numeric.shape(data))[1:].prod() + else: + length = numeric.size(data) + newdates = date_array(start_date=start_date, length=length, + freq=freq) + elif not hasattr(dates, 'freq'): + newdates = date_array(dlist=dates, freq=freq) + else: + newdates = dates + _data = data + if hasattr(data, '_mask') : + mask = mask_or(data._mask, mask) + cls._defaultdates = newdates + cls._defaultobserved = observed +# if oldma: +# newdata = MaskedArray(data, mask=mask, dtype=dtype, +# copy=copy,fill_value=fill_value) +# cls._defaultmask = newdata._mask +# cls._defaulthardmask = True +# cls._fill_value = newdata._fill_value +# assert(_datadatescompat(newdata,dates)) +# return ndarray.__new__(cls,shape=newdata.shape,dtype=newdata.dtype, +# buffer=newdata._data) +# _data = data +# newdata = MaskedArray.__new__(cls, data=_data, mask=mask, **options) + newdata = super(TimeSeries,cls).__new__(cls, _data, mask=mask, + **options) + assert(_datadatescompat(data,newdates)) + return newdata + + #.................................. + def __array_wrap__(self, obj, context=None): +# if oldma: +# tmpself = MaskedArray(self._data, mask=self._mask) +# return TimeSeries(MaskedArray.__array_wrap__(tmpself, obj, context), +# dates=self._dates) +# print "__array_wrap__" + return TimeSeries(super(TimeSeries,self).__array_wrap__(obj, context), + dates=self._dates) + #............................................ + def __array_finalize__(self,obj): + #tslog.info("__array_finalize__ received %s" % type(obj)) + if isinstance(obj, TimeSeries): + self._dates = obj._dates + self._data = obj._series._data + self._mask = obj._series._mask + self._series = obj._series + self._hardmask = obj._series._hardmask + self.observed = obj.observed + self._fill_value = obj._fill_value + else: + self._dates = self._defaultdates + self.observed = self._defaultobserved + self._series = MA.array(obj, mask=self._defaultmask, + copy=False, hard_mask=self._defaulthardmask) + self._mask = self._defaultmask + self._data = obj + self._hardmask = self._defaulthardmask + self.fill_value = self._fill_value + self._mask = self._series._mask + self._data = self._series._data + self._hardmask = self._series._hardmask + #tslog.info("__array_finalize__ sends %s" % type(self)) + return + #............................................ + def __getattribute__(self,attr): + "Returns a given attribute." + # Here, we need to be smart: _mask should call _series._mask... + if attr in ['_data','_mask','_hardmask']: + return getattr(self._series,attr) + return super(TimeSeries, self).__getattribute__(attr) + def __setattribute__(self,attr, value): + """Sets an attribute to a given value.""" + # Same thing here: if we modify ._mask, we need to modify _series._mask + # ...as well + super(TimeSeries, self).__setattribute__(attr, value) + if attr in ['_data','_mask','_hardmask']: + super(self._series.__class__, self._series).__setattribute__(attr, value) + setattr(self._series, attr, value) + #............................................ + def __checkindex(self, index): + "Checks the validity of an index." + if isinstance(index, int): + return index + if isinstance(index, str): + return self._dates.date_to_index(Date(self._dates.freq, string=index)) + elif isDate(index) or isDateArray(index): + return self._dates.date_to_index(index) + elif isinstance(index,slice): + slice_start = self.__checkindex(index.start) + slice_stop = self.__checkindex(index.stop) + return slice(slice_start, slice_stop, index.step) + elif isTimeSeries(index): + index = index._series + if getmask(index) is not nomask: + msg = "Masked arrays must be filled before they can be used as indices!" + raise IndexError, msg + return index + + def __getitem__(self, index): + """x.__getitem__(y) <==> x[y] +Returns the item described by i. Not a copy as in previous versions. + """ + index = self.__checkindex(index) + data = self._series[index] + date = self._dates[index] + m = self._mask + scalardata = (len(numeric.shape(data))==0) + # + if m is nomask: + if scalardata: + return TimeSeries(data, dates=date) + else: + return TimeSeries(data, dates=date, mask=nomask, keep_mask=True, + copy=False) + #.... + mi = m[index] + if mi.size == 1: + if mi: + return TimeSeries(data, dates=date, mask=True) + return TimeSeries(data, dates=date, mask=nomask) + else: + return TimeSeries(data, dates=date, mask=mi) + #........................ + def __setitem__(self, index, value): + """x.__setitem__(i, y) <==> x[i]=y +Sets item described by index. If value is masked, masks those locations. + """ + if self is masked: + raise MAError, 'Cannot alter the masked element.' + index = self.__checkindex(index) + #.... + if isinstance(value, TimeSeries): + assert(_timeseriescompat(self[index], value)) + self._series[index] = value._series + else: + self._series[index] = value + # Don't forget to update the mask ! + self._mask = self._series._mask + + #........................ + def __getslice__(self, i, j): + "Gets slice described by i, j" + i = self.__checkindex(i) + j = self.__checkindex(j) + (data, date) = (self._series[i:j], self._dates[i:j]) + return TimeSeries(data, dates=date, copy=False) + #.... + def __setslice__(self, i, j, value): + "Gets item described by i. Not a copy as in previous versions." + i = self.__checkindex(i) + j = self.__checkindex(j) + #.... + data = self._series[i:j] + if isinstance(value, TimeSeries): + assert(_timeseriescompat(self[i:j], value)) + self._series[i:j] = value._series + else: + self._series[i:j] = value + # Don't forget to update the mask ! + self._mask = self._series._mask + #...................................................... + def __len__(self): + if self.ndim == 0: + return 0 + return ndarray.__len__(self) + #...................................................... + def __str__(self): + """Returns a string representation of self (w/o the dates...)""" + return str(self._series) + def __repr__(self): + """Calculates the repr representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + desc = """\ +timeseries(data = + %(data)s, + dates = + %(time)s, + freq = %(freq)s) +""" + desc_short = """\ +timeseries(data = %(data)s, + dates = %(time)s, + freq = %(freq)s) +""" + if numeric.size(self._dates) > 2 and self.isvalid(): + timestr = "[%s ... %s]" % (str(self._dates[0]),str(self._dates[-1])) + else: + timestr = str(self.dates) + + if self.ndim <= 1: + return desc_short % {'data': str(self._series), + 'time': timestr, + 'freq': self.freq, } + return desc % {'data': str(self._series), + 'time': timestr, + 'freq': self.freq, } + #............................................ + def _get_mask(self): + """Returns the current mask.""" + return self._series._mask + def _set_mask(self, mask): + """Sets the mask to `mask`.""" + mask = make_mask(mask, copy=False, small_mask=True) + if mask is not nomask: + if mask.size != self._data.size: + raise ValueError, "Inconsistent shape between data and mask!" + if mask.shape != self._data.shape: + mask.shape = self._data.shape + self._series._mask = mask + else: + self._series._mask = nomask + mask = property(fget=_get_mask, fset=_set_mask, doc="Mask") + + def ids (self): + """Return the ids of the data, dates and mask areas""" + return (id(self._series), id(self.dates),) + + def copy(self): + "Returns a copy of the TimeSeries." + return TimeSeries(self, copy=True) + + #------------------------------------------------------ + @property + def series(self): + "Returns the series." + return self._series + @property + def dates(self): + """Returns the dates""" + return self._dates + @property + def freq(self): + """Returns the corresponding frequency.""" + return self._dates.freq +# @property + def years(self): + """Returns the corresponding years.""" + return self._dates.years +# @property + def months(self): + """Returns the corresponding months.""" + return self._dates.months +# @property + def yeardays(self): + """Returns the corresponding days of year.""" + return self._dates.yeardays + day_of_year = yeardays +# @property + def weekdays(self): + """Returns the corresponding days of weeks.""" + return self._dates.day_of_week + day_of_week = weekdays + + def start_date(self): + """Returns the first date of the series.""" + return self._dates[0] +# + def end_date(self): + """Returns the last date of the series.""" + return self._dates[-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) + #..................................................... + 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', interp=None): + "Converts the dates to another frequency, and adapt the data." + return convert(self, freq, func=func, position=position, interp=interp) + +##### -------------------------------------------------------------------------- +##--- ... Additional methods ... +##### -------------------------------------------------------------------------- +class _inplacemethod(object): + """Defines a wrapper for inplace arithmetic array methods (iadd, imul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + self.obj = None + # + def __get__(self, obj, objtype=None): + "Gets the calling object." + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + assert(_timeseriescompat(instance,other)) + func = getattr(instance._series, self.f) + func(other, *args) + return instance +#...................................... +TimeSeries.__iadd__ = _inplacemethod('__iadd__') +TimeSeries.__iand__ = _inplacemethod('__iand__') +TimeSeries.__idiv__ = _inplacemethod('__idiv__') +TimeSeries.__isub__ = _inplacemethod('__isub__') +TimeSeries.__imul__ = _inplacemethod('__imul__') + + +class _tsmathmethod(object): + """Defines a wrapper for arithmetic array methods (add, mul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + # + def __get__(self, obj, objtype=None): + "Gets the calling object." + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + _dates = instance._dates + #tslog.info("_tsmathmethod: series: %s" % instance,) + #tslog.info("_tsmathmethod: other : %s" % other,) + func = getattr(instance._series, self.f) + if isinstance(other, TimeSeries): + assert(_timeseriescompat(instance, other)) + return instance.__class__(func(other, *args), dates=_dates,) +#...................................... +TimeSeries.__add__ = _tsmathmethod('__add__') +TimeSeries.__radd__ = _tsmathmethod('__add__') +TimeSeries.__sub__ = _tsmathmethod('__sub__') +TimeSeries.__rsub__ = _tsmathmethod('__rsub__') +TimeSeries.__pow__ = _tsmathmethod('__pow__') +TimeSeries.__mul__ = _tsmathmethod('__mul__') +TimeSeries.__rmul__ = _tsmathmethod('__mul__') +TimeSeries.__div__ = _tsmathmethod('__div__') +TimeSeries.__rdiv__ = _tsmathmethod('__rdiv__') +TimeSeries.__truediv__ = _tsmathmethod('__truediv__') +TimeSeries.__rtruediv__ = _tsmathmethod('__rtruediv__') +TimeSeries.__floordiv__ = _tsmathmethod('__floordiv__') +TimeSeries.__rfloordiv__ = _tsmathmethod('__rfloordiv__') +TimeSeries.__eq__ = _tsmathmethod('__eq__') +TimeSeries.__ne__ = _tsmathmethod('__ne__') +TimeSeries.__lt__ = _tsmathmethod('__lt__') +TimeSeries.__le__ = _tsmathmethod('__le__') +TimeSeries.__gt__ = _tsmathmethod('__gt__') +TimeSeries.__ge__ = _tsmathmethod('__ge__') +#................................................ +class _tsarraymethod(object): + """Defines a wrapper for basic array methods. +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +If `ondates` is True, the same operation is performed on the `_dates`. +If `ondates` is False, the `_dates` part remains unchanged. + """ + def __init__ (self, methodname, ondates=False): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + self._ondates = ondates + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args): + "Execute the call behavior." + _name = self._name + instance = self.obj + func_series = getattr(instance._series, _name) + if self._ondates: + func_dates = getattr(instance._dates, _name) + return instance.__class__(func_series(*args), + dates=func_dates(*args)) + else: + return instance.__class__(func_series(*args), + dates=instance._dates) +#TimeSeries.astype = _tsarraymethod('astype') +TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) +TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) +TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) +TimeSeries.copy = _tsarraymethod('copy', ondates=True) +TimeSeries.compress = _tsarraymethod('compress', ondates=True) +TimeSeries.filled = _tsarraymethod('filled', ondates=False) +TimeSeries.cumsum = _tsarraymethod('cumsum',ondates=False) +TimeSeries.cumprod = _tsarraymethod('cumprod',ondates=False) +TimeSeries.anom = _tsarraymethod('anom',ondates=False) + +#...................................... +class _tsaxismethod(object): + """Defines a wrapper for array methods working on an axis (mean...). +When called, returns a ndarray, as the result of the method applied on the series. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + "Execute the call behavior." + (_dates, _series) = (self.obj._dates, self.obj._series) + func = getattr(_series, self._name) + result = func(*args, **params) + if _series.ndim < 2 or _dates.size == _series.size: + return result + else: + try: + axis = params.get('axis', args[0]) + if axis == 0: + result = TimeSeries(result, dates=_dates) + except IndexError: + pass + return result +#....................................... +TimeSeries.sum = _tsaxismethod('sum') +TimeSeries.prod = _tsaxismethod('prod') +TimeSeries.mean = _tsaxismethod('mean') +TimeSeries.var = _tsaxismethod('var') +TimeSeries.varu = _tsaxismethod('varu') +TimeSeries.std = _tsaxismethod('std') +TimeSeries.stdu = _tsaxismethod('stdu') + +#####--------------------------------------------------------------------------- +#---- --- 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(TimeSeries, self._methodname).__doc__ + except: + 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') +# +##### --------------------------------------------------------------------------- +#---- ... Additional methods ... +##### --------------------------------------------------------------------------- +def tofile(self, output, sep='\t', format='%s', format_dates=None): + """Writes the TimeSeries to a file. + +:Parameters: + - `output` (String) : Name or handle of the output file. + - `sep` (String) : Column separator *['\t']*. + - `format` (String) : Data format *['%s']*. + """ + if not hasattr(output, 'writeline'): + ofile = open(output,'w') + else: + ofile = output + 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(), + filled(self)): + ofile.write('%s\n' % sep.join([oformat % (_dates, _data) ])) + ofile.close() +TimeSeries.tofile = tofile + +##### --------------------------------------------------------------------------- +##--- ... Pickling ... +##### --------------------------------------------------------------------------- +##FIXME: We're kinda stuck with forcing the mask to have the same shape as the data +#def _tsreconstruct(baseclass, datesclass, baseshape, basetype): +# """Internal function that builds a new MaskedArray from the information stored +#in a pickle.""" +# _series = ndarray.__new__(ndarray, baseshape, basetype) +# _dates = ndarray.__new__(datesclass, baseshape, basetype) +# return TimeSeries.__new__(baseclass, _series, dates=_dates, dtype=basetype) +# +#def _tsgetstate(a): +# "Returns the internal state of the TimeSeries, for pickling purposes." +# #TODO: We should prolly go through a recarray here as well. +# state = (1, +# a.shape, +# a.dtype, +# a.flags.fnc, +# (a._series).__reduce__()[-1][-1], +# (a._dates).__reduce__()[-1][-1]) +# return state +# +#def _tssetstate(a, 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 +# - a binary string for the data +# - a binary string for the mask. +# """ +# (ver, shp, typ, isf, raw, dti) = state +# (a._series).__setstate__((shp, typ, isf, raw)) +# (a._dates).__setstate__((shp, N.dtype('|O8'), isf, dti)) +# (a._dates)._asstrings = None +# +#def _tsreduce(a): +# """Returns a 3-tuple for pickling a MaskedArray.""" +# return (_tsreconstruct, +# (a.__class__, a._dates.__class__, (0,), 'b', ), +# a.__getstate__()) +# +#TimeSeries.__getstate__ = _tsgetstate +#TimeSeries.__setstate__ = _tssetstate +#TimeSeries.__reduce__ = _tsreduce +#TimeSeries.__dump__ = dump +#TimeSeries.__dumps__ = dumps +# +##................................................ + +# +##### -------------------------------------------------------------------------- +##--- ... Shortcuts ... +##### -------------------------------------------------------------------------- +#def isTimeSeries(x): +# """Checks whether `x` is a time series (an instance of `TimeSeries` ).""" +# return isinstance(x, TimeSeries) +# +##### -------------------------------------------------------------------------- +##--- ... MaskedTimeSeries class ... +##### -------------------------------------------------------------------------- +#class MaskedTimeSeries(MaskedArray, TimeSeries): +# """Base class for the definition of time series. +#A time series is here defined as the combination of two arrays: +# +# - an array storing the time information (as a `TimeArray` instance); +# - an array storing the data (as a `MaskedArray` instance. +# """ +# def __new__(cls, data, dates=None, mask=nomask, +# dtype=None, copy=True, fill_value=-9999): +# mtslog.log(5, "__new__: data types %s, %s" % (type(data), dtype)) +## if isinstance(data, TimeSeries): +# #.................... +# if isinstance(data, TimeSeries): +# if isinstance(data, MaskedTimeSeries): +# _data = data._data +# else: +# _data = data +# _dates = data._dates +# _series = data._series +# mtslog.log(5, "__new__ from TS: data %i - %s - %s" % \ +# (id(_data._series), type(_data._series), _data.ravel())) +# mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ +# (id(_dates), type(_dates), _dates.ravel())) +# elif isinstance(data, recarray): +# assert(data.dtype.names == ('_dates', '_series', '_mask'), +# "Invalid fields names (got %s)" % (data.dtype.names,)) +# _dates = data['_dates'] +# _series = data['_series'] +# _mask = data['_mask'] +# else: +# if hasattr(data, "_data"): +# _data = TimeSeries(data._data, dates=dates, +# dtype=dtype, copy=copy) +# else: +# _data = TimeSeries(data, dates=dates, +# dtype=dtype, copy=copy) +# _dates = _data._dates +# _series = _data._series +# mtslog.log(5,"__new__ from scratch: data %i - %s - %s" % \ +# (id(_data._series), type(_data._series), _data.ravel())) +# mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ +# (id(_dates), type(_dates), _dates.ravel())) +# #..................... +# if mask is nomask: +# if hasattr(data, "_mask"): +# _mask = data._mask +# else: +# _mask = nomask +# else: +# _mask = make_mask(mask, copy=copy, flag=True) +# #....Check shapes compatibility +# if _mask is not nomask: +# (nd, nm) = (_data.size, _mask.size) +# if (nm != nd): +# if nm == 1: +# _mask = N.resize(_mask, _data.shape) +# elif nd == 1: +# _data = N.resize(_data, _mask.shape) +# else: +# msg = "Mask and data not compatible (size issues: %i & %i)." +# raise MAError, msg % (nm, nd) +# elif (_mask.shape != _data.shape): +# mtslog.log(5,"__new__ from scratch: force _mask shape %s > %s" % \ +# (_mask.shape, _data.shape)) +# _mask.shape = _data.shape +# #.... +# cls._fill_value = fill_value +# cls._basemask = _mask +# cls._basedates = _dates +# cls._baseseries = _series +# return _data.view(cls) +## return _series.view(cls) +# #.............. +# def __array_wrap__(self, obj, context=None): +# """Special hook for ufuncs. +#Wraps the numpy array and sets the mask according to context. +# """ +## return MaskedArray.__array_wrap__(obj, context=None) +# return MaskedTimeSeries(obj, dates=self._dates, mask=self._mask, +# fill_value=self._fill_value) +# +# #.............. +# def __array_finalize__(self,obj): +# mtslog.log(5, "__array_finalize__: obj is %s" % (type(obj), )) +# if not hasattr(self, "_data"): +# self._data = obj +# if not hasattr(self, "_dates"): +# self._dates = self._basedates +# mtslog.log(5, "__array_finalize__: set dates to: %s - %s" % \ +# (id(self._dates), self._dates.ravel() )) +# if not hasattr(self, "_mask"): +# self._mask = self._basemask +# mtslog.log(5, "__array_finalize__: set mask to: %s - %s" % \ +# (id(self._mask), self._mask.ravel() )) +# if not hasattr(self, "_series"): +# if hasattr(obj, "_series"): +# self._series = obj._series +# else: +# self._series = obj +# self.fill_value = self._fill_value +# return +# #------------------------------------------------------ +# def __str__(self): +# """Calculate the str representation, using masked for fill if +# it is enabled. Otherwise fill with fill value. +# """ +# if masked_print_option.enabled(): +# f = masked_print_option +# # XXX: Without the following special case masked +# # XXX: would print as "[--]", not "--". Can we avoid +# # XXX: checks for masked by choosing a different value +# # XXX: for the masked singleton? 2005-01-05 -- sasha +# if self is masked: +# return str(f) +# m = self._mask +# if m is nomask: +# res = self._data +# else: +# if m.shape == () and m: +# return str(f) +# # convert to object array to make filled work +# res = (self._series).astype("|O8") +# res[self._mask] = f +# else: +# res = self.filled(self.fill_value) +# return str(res) +# #............................................ +# def ids (self): +# """Return the ids of the data, dates and mask areas""" +# return (id(self._series), id(self.dates), id(self._mask)) +# #............................................ +# @property +# def maskedseries(self): +# """Returns a masked array of the series (dates are omitteed).""" +# return masked_array(self._series, mask=self._mask) +# _mseries = maskedseries +# #............................................ +# def filled(self, fill_value=None): +# """A numeric array with masked values filled. If fill_value is None, +# use self.fill_value(). +# +# If mask is nomask, copy data only if not contiguous. +# Result is always a contiguous, numeric array. +## Is contiguous really necessary now? +# """ +# (d, m) = (self._data, self._mask) +# if m is nomask: +# return d +# # +# if fill_value is None: +# value = self._fill_value +# else: +# value = fill_value +# # +# if self is masked_singleton: +# return numeric.array(value) +# # +# result = d.copy() +# try: +# result.__setitem__(m, value) +# except (TypeError, AttributeError): +# #ok, can't put that value in here +# value = numeric.array(value, dtype=object) +# d = d.astype(object) +# result = fromnumeric.choose(m, (d, value)) +# except IndexError: +# #ok, if scalar +# if d.shape: +# raise +# elif m: +# result = numeric.array(value, dtype=d.dtype) +# else: +# result = d +# return result +# #............................................ + +# #............................................ +# def asrecords(self): +# """Returns the masked time series as a recarray. +#Fields are `_dates`, `_data` and _`mask`. +# """ +# desctype = [('_dates','|O8'), ('_series',self.dtype), ('_mask',N.bool_)] +# flat = self.ravel() +# if flat.size > 0: +# return recfromarrays([flat._dates, flat._series, getmaskarray(flat)], +# dtype=desctype, +# shape = (flat.size,), +# ) +# else: +# return recfromarrays([[], [], []], dtype=desctype, +# shape = (flat.size,), +# ) +# +# +## def reshape (self, *s): +## """This array reshaped to shape s""" +## self._data = self._data.reshape(*s) +## self._dates = self._dates.reshape(*s) +## if self._mask is not nomask: +## self._mask = self._mask.reshape(*s) +## return self.view() +##### -------------------------------------------------------------------------- +##--- ... Pickling ... +##### -------------------------------------------------------------------------- +#def _mtsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): +# """Internal function that builds a new MaskedArray from the information stored +#in a pickle.""" +## raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" +# _series = ndarray.__new__(ndarray, baseshape, basetype) +# _dates = ndarray.__new__(datesclass, baseshape, '|O8') +# _mask = ndarray.__new__(ndarray, baseshape, '|O8') +# return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, +# dtype=basetype, fill_value=fill_value) +## +#def _mtsgetstate(a): +# "Returns the internal state of the TimeSeries, for pickling purposes." +## raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" +# records = a.asrecords() +# state = (1, +# a.shape, +# a.dtype, +# records.flags.fnc, +# a.fill_value, +# records +# ) +# return state +## +#def _mtssetstate(a, 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 +# - a binary string for the data +# - a binary string for the mask. +# """ +# (ver, shp, typ, isf, flv, rec) = state +# a.fill_value = flv +# a._data._series = a._series = N.asarray(rec['_series']) +# a._data._series.shape = a._series.shape = shp +# a._data._dates = a._dates = a._dates.__class__(rec['_dates']) +# a._data._dates.shape = a._dates.shape = shp +# (a._dates)._asstrings = None +# a._mask = N.array(rec['_mask'], dtype=MA.MaskType) +# a._mask.shape = shp +## +#def _mtsreduce(a): +# """Returns a 3-tuple for pickling a MaskedArray.""" +# return (_mtsreconstruct, +# (a.__class__, a.dates.__class__, (0,), 'b', -9999), +# a.__getstate__()) +## +#MaskedTimeSeries.__getstate__ = _mtsgetstate +#MaskedTimeSeries.__setstate__ = _mtssetstate +#MaskedTimeSeries.__reduce__ = _mtsreduce +#MaskedTimeSeries.__dump__ = dump +#MaskedTimeSeries.__dumps__ = dumps + + +##### ------------------------------------------------------------------------- +#---- --- TimeSeries creator --- +##### ------------------------------------------------------------------------- +def time_series(data, dates=None, freq=None, observed=None, + start_date=None, end_date=None, length=None, include_last=True, + mask=nomask, + 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` : + Array of data. + """ + if dates is None: + if numeric.ndim(data) >= 2: + length = numeric.asarray(numeric.shape(data))[1:].prod() + else: + length = numeric.size(data) + dates = date_array(start_date=start_date, end_date=end_date, + length=length, include_last=include_last, 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, + hard_mask=hard_mask,) + + +def isTimeSeries(series): + "Returns whether the series is a valid TimeSeries object." + return isinstance(series, TimeSeries) + +##### -------------------------------------------------------------------------- +##--- ... Additional functions ... +##### -------------------------------------------------------------------------- +#def check_dates(a,b): +# """Returns the array of dates from the two objects `a` or `b` (or None).""" +# if isTimeSeries(a): +# if isTimeSeries(b) and (a._dates == b._dates).all() is False: +# raise ValueError, "Incompatible dates !" +# return a._dates +# elif isTimeSeries(b): +# return b._dates +# else: +# return +# +#def parse_period(period): +# """Returns a TimeArray couple (starting date; ending date) from the arguments.""" +##### print "........DEBUG PARSE DATES: period %s is %s" % (period, type(period)) +## if isinstance(period,TimeArray) or isinstance(period,Dates): +##### print "........DEBUG PARSE_PERIOD: OK" +# if isinstance(period,TimeArray): +# return (period[0],period[-1]) +# elif hasattr(period,"__len__"): +# if not isinstance(period[0], TimeArray): +# tstart = TimeArray(period[0]) +# else: +# tstart = period[0] +# if not isinstance(period[-1], TimeArray): +# tend = TimeArray(period[-1]) +# else: +# tend = period[-1] +# return (tstart, tend) +# else: +# p = N.asarray(period) +# if N.all(p < 9999): +# p = N.array(period,dtype="|S4") +# p = time_array(p) +# return (p[0], p[-1]) +# +#def where_period(period, dates, *choices): +# """Returns choices fro True/False, whether dates fall during a given period. +#If no choices are given, outputs the array indices for the dates falling in the +#period. +# +#:Parameters: +# `period` : Sequence +# Selection period, as a sequence (starting date, ending date). +# `dates` : TimeArray +# Array of dates. +# `choices` : *(optional)* +# Arrays to select from when the condition is True/False. +# """ +# (tstart, tend) = parse_period(period) +# condition = ascondition((dates>=tstart)&(dates<=tend)) +# condition = (dates>=tstart)&(dates<=tend) +# return N.where(condition, *choices) +# +#def masked_inside_period(data, period, dates=None): +# """Returns x as an array masked where dates fall inside the selection period, +#as well as where data are initially missing (masked).""" +# (tstart, tend) = parse_period(period) +# # Get dates .................. +# if hasattr(data, "_dates"): +# dates = data._dates +# elif dates is None: +# raise ValueError,"Undefined dates !" +# else: +# assert(N.size(dates)==N.size(data), +# "Inconsistent data and dates sizes!") +# # where_period yields True inside the period, when mask should yield False +# condition = ascondition(N.logical_and((dates>=tstart), (dates<=tend))) +# cm = filled(condition,True).reshape(data.shape) +# mask = mask_or(MA.getmaskarray(data), cm, copy=True) +# if isinstance(data, MaskedTimeSeries): +# return data.__class__(data._data, dates=dates, mask=mask, copy=True) +# if isinstance(data, TimeSeries): +# return MaskedTimeSeries(data, dates=dates, mask=mask, copy=True) +# else: +# return masked_array(data, mask=mask, copy=True) +# +def mask_period(data, start_date=None, end_date=None, + inside=True, include_edges=True, inplace=True): + """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 + `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]* + Whether the dates inside the range should be masked. If not, masks outside. + `include_edges` : Boolean *[True]* + Whether the starting and ending dates should be masked. + `inplace` : Boolean *[True]* + Whether the data mask should be modified in place. If not, returns a new + TimeSeries. +""" + if not isTimeSeries(data): + raise ValueError,"Data should be a valid TimeSeries!" + # Check the starting date .............. + if start_date is None: + start_date = data._dates[0] + elif isinstance(start_date, str): + start_date = Date(data.freq, string=start_date) + elif not isDateType(start_date): + raise DateError,"Starting date should be a valid date!" + start_date = max(start_date, data.dates[0]) + # Check the ending date ................ + if end_date is None: + end_date = data._dates[-1] + elif isinstance(end_date, str): + end_date = Date(data.freq, string=end_date) + elif not isDateType(end_date): + raise DateError,"Starting date should be a valid date!" + end_date = min(end_date, data.dates[-1]) + # Constructs the selection mask ......... + if inside: + if include_edges: + selection = (data.dates >= start_date) & (data.dates <= end_date) + else: + selection = (data.dates > start_date) & (data.dates < end_date) + else: + if include_edges: + selection = (data.dates <= start_date) | (data.dates >= end_date) + 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 + else: + return TimeSeries(data, mask=selection, keep_mask=True) + return data + +def mask_inside_period(data, start_date=None, end_date=None, + include_edges=True, inplace=True): + """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): + """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) + +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, + the new series is NOT a copy. + """ + # Series validity tests ..................... + if not isinstance(a, TimeSeries): + raise TypeError,"Argument should be a valid TimeSeries object!" + if a.freq == 'U': + raise TimeSeriesError, \ + "Cannot adjust a series with 'Undefined' frequency." + if not a.dates.isvalid(): + raise TimeSeriesError, \ + "Cannot adjust a series with missing or duplicated dates." + # Dates validity checks .,................... + msg = "%s should be a valid Date instance! (got %s instead)" + (dstart, dend) = a.dates[[0,-1]] + if start_date is None: + start_date = dstart + start_lag = 0 + else: + if not isDateType(start_date): + raise TypeError, msg % ('start_date', type(start_date)) + start_lag = start_date - dstart + + if end_date is None: + end_date = dend + end_lag = 0 + else: + if not isDateType(end_date): + raise TypeError, msg % ('end_date', type(end_date)) + end_lag = end_date - dend + if start_lag >= 0: + if end_lag == 0: + return a[start_lag:] + elif end_lag < 0: + return a[start_lag:end_lag] + + newdates = date_array(start_date=start_date, end_date=end_date) + newshape = list(a.shape) + newshape[0] = len(newdates) + newshape = tuple(newshape) + + newdata = masked_array(numeric.empty(newshape, dtype=a.dtype), mask=True) + newseries = TimeSeries(newdata, newdates) + start_date = max(start_date, dstart) + end_date = min(end_date, dend) + 1 + newseries[start_date:end_date] = a[start_date:end_date] + return newseries + + +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. + """ + if len(series) < 2: + return series + + unique_freqs = numpy.unique([x.freq for x in series]) + try: + common_freq = unique_freqs.item() + except ValueError: + raise TimeSeriesError, \ + "All series must have same frequency!" + if common_freq == 'U': + raise TimeSeriesError, \ + "Cannot adjust a series with 'Undefined' frequency." + 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])) + if isinstance(start_date,str): + start_date = Date(common_freq, string=start_date) + end_date = kwargs.pop('end_date', max([x.end_date() for x in series])) + 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', interp=None): + """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 + appropriate function is determined based on the observed attribute + 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 + placed at the end of the month). Interp is the method that will be used + to fill in the gaps. Valid values are "CUBIC", "LINEAR", "CONSTANT", "DIVIDED", + and None. + + Note: interp currently not implemented + """ + if not isinstance(series,TimeSeries): + raise TypeError, "The argument should be a valid TimeSeries!" + if not series.isvalid(): + raise TimeSeriesError, \ + "Cannot adjust a series with missing or duplicated dates." + + if position.upper() not in ('END','START'): + raise ValueError("invalid value for position argument: (%s)",str(position)) + + toFreq = corelib.fmtFreq(freq) + fromFreq = series.freq + start_date = series._dates[0] + + if fromFreq == toFreq: + return series.copy() + + if series.size == 0: + return TimeSeries(series, freq=toFreq, + start_date=start_date.asfreq(toFreq)) + if func == 'auto': + func = corelib.obs_dict[series.observed] + + tempData = series._series.filled() + tempMask = getmaskarray(series) + + cRetVal = cseries.reindex(tempData, fromFreq, toFreq, position, + int(start_date), tempMask) + _values = cRetVal['values'] + _mask = cRetVal['mask'] + + tempData = masked_array(_values, mask=_mask) + + if tempData.ndim == 2: +# tempData = tempData.T + if func is not None: + tempData = MA.apply_along_axis(func, 1, tempData) + else: + tempData = tempData.T + + #startIndex = cseries.convert(start_date, fromFreq, toFreq) + newStart = series._dates[0].asfreq(toFreq, "BEFORE") + newEnd = series._dates[-1].asfreq(toFreq, "AFTER") + + newseries = TimeSeries(tempData, freq=toFreq, + observed=series.observed, + start_date=newStart) + return newseries +# return adjust_endpoints(newseries, end_date=newEnd) +# return (tempData, newStart, toFreq, newseries, _values, _mask) + + +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 +`fill_value`. + +:Parameters: + `data` + Initial array of data. + `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 = corelib.fmtFreq(freq) +# if freq == 'U': +# raise ValueError,\ +# "Unable to define a proper date resolution (found %s)." % freq + if dates is None: + if not isTimeSeries(data): + raise InsufficientDateError + dates = data._dates + data = data._series + freq = dates.freq + elif not isinstance(dates, DateArray): + dates = DateArray(dates, freq) + dflat = dates.ravel().asfreq(freq) + n = len(dflat) + if not dflat.has_missing_dates(): + return time_series(data, dflat) + + # ...and now, fill it ! ...... + (tstart, tend) = dflat[[0,-1]] + newdates = date_array(start_date=tstart, end_date=tend, include_last=True) + nsize = newdates.size + #............................. + # Get the steps between consecutive data. We need relativedelta to deal w/ months + delta = dflat.get_steps()-1 + gap = delta.nonzero() + slcid = numpy.r_[[0,], numpy.arange(1,n)[gap], [n,]] + 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]], + [slice(i+d,e+d) for (i,e,d) in \ + numpy.broadcast(slcid[1:-1],slcid[2:],addidx)] + ] + #............................. + # Just a quick check + for (osl,nsl) in zip(oldslc,newslc): + assert numpy.equal(dflat[osl],newdates[nsl]).all(),\ + "Slicing mishap ! Please check %s (old) and %s (new)" % (osl,nsl) + #............................. + data = MA.asarray(data) + newdata = MA.masked_array(numeric.empty(nsize, data.dtype), + mask=numeric.ones(nsize, bool_)) + if fill_value is None: + if hasattr(data,'fill_value'): + fill_value = data.fill_value + else: + fill_value = MA.default_fill_value(data) + #data = data.filled(fill_value) + #.... + for (new,old) in zip(newslc,oldslc): + newdata[new] = data[old] + # Get new shape .............. + if data.ndim == 1: + nshp = (newdates.size,) + else: + nshp = tuple([-1,] + list(data.shape[1:])) + return time_series(newdata.reshape(nshp), newdates) + + +#######-------------------------------------------------------------------------- +###---- --- Archiving --- +#######-------------------------------------------------------------------------- + + + + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + from maskedarray.testutils import assert_equal + if 0: + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array(dlist) + data = masked_array(numeric.arange(15, dtype=float_), mask=[1,0,0,0,0]*3) +# btseries = BaseTimeSeries(data._data, dates) + tseries = time_series(data, dlist) + dseries = numpy.log(tseries) + if 1: + mlist = ['2005-%02i' % i for i in range(1,13)] + mlist += ['2006-%02i' % i for i in range(1,13)] + mdata = numpy.arange(24) + mser1 = time_series(mdata, mlist, observed='SUMMED') + # + mlist2 = ['2004-%02i' % i for i in range(1,13)] + mlist2 += ['2005-%02i' % i for i in range(1,13)] + mser2 = time_series(mdata, mlist2, observed='SUMMED') + # + today = thisday('m') + (malg1,malg2) = aligned(mser1, mser2) + + C = convert(mser2,'A') + D = convert(mser2,'A',func=None) + + if 0: + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array(dlist) + print "."*50+"\ndata" + data = masked_array(numeric.arange(15)-6, mask=[1,0,0,0,0]*3) + print "."*50+"\nseries" + tseries = time_series(data, dlist) + + if 1: + mser3 = time_series(MA.mr_[malg1._series, malg2._series].reshape(2,-1), + dates=malg1.dates) + + From scipy-svn at scipy.org Tue Jan 2 22:37:40 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 21:37:40 -0600 (CST) Subject: [Scipy-svn] r2477 - trunk/Lib/interpolate Message-ID: <20070103033740.5FB6F39C00D@new.scipy.org> Author: timl Date: 2007-01-02 21:37:35 -0600 (Tue, 02 Jan 2007) New Revision: 2477 Modified: trunk/Lib/interpolate/__fitpack.h Log: apply the patch from #248 Modified: trunk/Lib/interpolate/__fitpack.h =================================================================== --- trunk/Lib/interpolate/__fitpack.h 2007-01-02 17:54:31 UTC (rev 2476) +++ trunk/Lib/interpolate/__fitpack.h 2007-01-03 03:37:35 UTC (rev 2477) @@ -140,6 +140,7 @@ PyObject *x_py = NULL,*y_py = NULL,*z_py = NULL,*w_py = NULL,\ *tx_py = NULL,*ty_py = NULL; PyObject *wrk_py=NULL; + PyObject *ret=NULL; nx=ny=ier=nxo=nyo=0; if (!PyArg_ParseTuple(args, "OOOOddddiiiddOOiiOii",\ &x_py,&y_py,&z_py,&w_py,&xb,&xe,\ @@ -224,10 +225,17 @@ Py_DECREF(ap_y); Py_DECREF(ap_z); Py_DECREF(ap_w); - return Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),\ - PyArray_Return(ap_ty),PyArray_Return(ap_c),\ - "wrk",PyArray_Return(ap_wrk),\ - "ier",ier,"fp",fp); + ret = Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),\ + PyArray_Return(ap_ty),PyArray_Return(ap_c),\ + "wrk",PyArray_Return(ap_wrk),\ + "ier",ier,"fp",fp); + Py_DECREF(ap_tx); + Py_DECREF(ap_ty); + Py_DECREF(ap_c); + Py_DECREF(ap_wrk); + + return ret; + fail: if (wa) free(wa); Py_XDECREF(ap_x); From scipy-svn at scipy.org Tue Jan 2 23:08:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 22:08:57 -0600 (CST) Subject: [Scipy-svn] r2478 - trunk/Lib/sparse Message-ID: <20070103040857.4C01639C00D@new.scipy.org> Author: timl Date: 2007-01-02 22:08:53 -0600 (Tue, 02 Jan 2007) New Revision: 2478 Modified: trunk/Lib/sparse/sparse.py Log: remove unneeded return in __init__ Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-03 03:37:35 UTC (rev 2477) +++ trunk/Lib/sparse/sparse.py 2007-01-03 04:08:53 UTC (rev 2478) @@ -1643,7 +1643,6 @@ assert M == int(M) and M > 0 assert N == int(N) and N > 0 self.shape = (int(M), int(N)) - return except (TypeError, ValueError, AssertionError): raise TypeError, "dimensions must be a 2-tuple of positive"\ " integers" From scipy-svn at scipy.org Tue Jan 2 23:20:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 2 Jan 2007 22:20:26 -0600 (CST) Subject: [Scipy-svn] r2479 - trunk/Lib/sparse Message-ID: <20070103042026.92C4F39C00D@new.scipy.org> Author: timl Date: 2007-01-02 22:20:22 -0600 (Tue, 02 Jan 2007) New Revision: 2479 Modified: trunk/Lib/sparse/sparse.py Log: clean up long lines and remove unused variables Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-03 04:08:53 UTC (rev 2478) +++ trunk/Lib/sparse/sparse.py 2007-01-03 04:20:22 UTC (rev 2479) @@ -647,7 +647,8 @@ if (nnz2 == 0): nnz2 = 1 data1, data2 = _convert_data(self.data[:nnz1], ocs.data[:nnz2], dtypechar) func = getattr(sparsetools, _transtabl[dtypechar]+'cscadd') - c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, data2, ocs.rowind[:nnz2], ocs.indptr) + c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, + data2, ocs.rowind[:nnz2], ocs.indptr) if ierr: raise RuntimeError, "ran out of space" M, N = self.shape @@ -672,7 +673,8 @@ if (nnz2 == 0): nnz2=1 data1, data2 = _convert_data(self.data[:nnz1], ocs.data[:nnz2], dtypechar) func = getattr(sparsetools, _transtabl[dtypechar]+'cscadd') - c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, data2, ocs.rowind[:nnz2], ocs.indptr) + c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, + data2, ocs.rowind[:nnz2], ocs.indptr) if ierr: raise RuntimeError, "ran out of space" M, N = self.shape @@ -870,14 +872,15 @@ rowb = other.rowind ptrb = other.indptr a, b = _convert_data(a, b, dtypechar) - newshape = (M, N) ptrc = zeros((N+1,), intc) nnzc = 2*max(ptra[-1], ptrb[-1]) c = zeros((nnzc,), dtypechar) rowc = zeros((nnzc,), intc) ierr = irow = kcol = 0 while True: # loop in case first call runs out of memory. - c, rowc, ptrc, irow, kcol, ierr = func(M, a, rowa, ptra, b, rowb, ptrb, c, rowc, ptrc, irow, kcol, ierr) + c, rowc, ptrc, irow, kcol, ierr = func(M, a, rowa, ptra, b, + rowb, ptrb, c, rowc, + ptrc, irow, kcol, ierr) if (ierr==0): break # otherwise we were too small and must resize arrays # calculations continue where they left off... @@ -1230,7 +1233,8 @@ dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] data1, data2 = _convert_data(self.data, ocs.data, dtypechar) func = getattr(sparsetools, _transtabl[dtypechar]+'cscadd') - c, colc, ptrc, ierr = func(data1, self.colind, self.indptr, data2, ocs.colind, ocs.indptr) + c, colc, ptrc, ierr = func(data1, self.colind, self.indptr, data2, + ocs.colind, ocs.indptr) if ierr: raise RuntimeError, "ran out of space" M, N = self.shape @@ -1290,7 +1294,8 @@ dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] data1, data2 = _convert_data(self.data, ocs.data, dtypechar) func = getattr(sparsetools, _transtabl[dtypechar]+'cscmul') - c, colc, ptrc, ierr = func(data1, self.colind, self.indptr, data2, ocs.colind, ocs.indptr) + c, colc, ptrc, ierr = func(data1, self.colind, self.indptr, data2, + ocs.colind, ocs.indptr) if ierr: raise RuntimeError, "ran out of space" M, N = self.shape @@ -2052,7 +2057,6 @@ base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) - N = len(cols_or_rows) if indx: for key in self: num = searchsorted(cols_or_rows, key[1]) @@ -2128,7 +2132,6 @@ ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey0 != current_row: - N = ikey0-current_row row_ptr[current_row+1:ikey0+1] = k current_row = ikey0 data[k] = dict.__getitem__(self, key) @@ -2161,7 +2164,6 @@ ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey1 != current_col: - N = ikey1-current_col col_ptr[current_col+1:ikey1+1] = k current_col = ikey1 data[k] = self[key] From scipy-svn at scipy.org Wed Jan 3 01:08:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 3 Jan 2007 00:08:27 -0600 (CST) Subject: [Scipy-svn] r2480 - trunk/Lib/io Message-ID: <20070103060827.A444A39C173@new.scipy.org> Author: timl Date: 2007-01-03 00:08:11 -0600 (Wed, 03 Jan 2007) New Revision: 2480 Modified: trunk/Lib/io/array_import.py Log: apply patch from #274 Modified: trunk/Lib/io/array_import.py =================================================================== --- trunk/Lib/io/array_import.py 2007-01-03 04:20:22 UTC (rev 2479) +++ trunk/Lib/io/array_import.py 2007-01-03 06:08:11 UTC (rev 2480) @@ -90,8 +90,12 @@ return linelist def get_open_file(fileobject, mode='rb'): - if isinstance(fileobject, types.StringType): + try: + # this is the duck typing check: if fileobject + # can be used is os.path.expanduser, it is a string + # otherwise it is a fileobject fileobject = os.path.expanduser(fileobject) + if mode[0]=='r' and not os.path.exists(fileobject): raise IOError, (2, 'No such file or directory: ' + fileobject) @@ -103,7 +107,9 @@ if type(details) == type(()): details = details + (fileobject,) raise IOError, details - else: + except AttributeError: + # it is assumed that the fileobject is a python + # file object if it can not be used in os.path.expanduser file = fileobject return file From scipy-svn at scipy.org Wed Jan 3 03:12:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 3 Jan 2007 02:12:13 -0600 (CST) Subject: [Scipy-svn] r2481 - trunk/Lib/sandbox/timeseries/mtimeseries Message-ID: <20070103081213.F2A1039C03D@new.scipy.org> Author: pierregm Date: 2007-01-03 02:12:10 -0600 (Wed, 03 Jan 2007) New Revision: 2481 Added: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG Removed: trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py Modified: trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py Log: cf changelog Added: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-03 06:08:11 UTC (rev 2480) +++ trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-03 08:12:10 UTC (rev 2481) @@ -0,0 +1,6 @@ +#2007-01-03 : tseries +# : - Allowed endpoints adjustment after convert +# : - Put the estimation of the data length in its own function. +# : - Added a timestep compatibility check. +# : - The variables in a multi-series correspond now to the last axis. +# : - Blocked transpose/swapaxes, temporarily. \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py 2007-01-03 06:08:11 UTC (rev 2480) +++ trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py 2007-01-03 08:12:10 UTC (rev 2481) @@ -266,6 +266,14 @@ mask = mask_period(tseries, 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]) + # + def pickling(self): + "Tests pickling/unpickling" + (tseries, data, dates) = self.d + tmp = maskedarray.loads(tseries.dumps()) + assert_equal(tmp._data, tseries._data) + assert_equal(tmp._dates, tseries._dates) + assert_equal(tmp._mask, tseries._mask) ############################################################################### #------------------------------------------------------------------------------ Deleted: trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py 2007-01-03 06:08:11 UTC (rev 2480) +++ trunk/Lib/sandbox/timeseries/mtimeseries/timeseries_ini.py 2007-01-03 08:12:10 UTC (rev 2481) @@ -1,1494 +0,0 @@ -# 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. - -These two classes were liberally adapted from `MaskedArray` class. - - -:author: Pierre GF Gerard-Marchant -:contact: pierregm_at_uga_edu -:date: $Date: 2006-12-05 20:40:46 -0500 (Tue, 05 Dec 2006) $ -:version: $Id: timeseries.py 25 2006-12-06 01:40:46Z backtopop $ -""" -__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" -__version__ = '1.0' -__revision__ = "$Revision: 25 $" -__date__ = '$Date: 2006-12-05 20:40:46 -0500 (Tue, 05 Dec 2006) $' - - -#import numpy as N - -#from numpy.core import bool_, float_, int_ -import numpy.core.umath as umath -import numpy.core.fromnumeric as fromnumeric -import numpy.core.numeric as numeric -from numpy import ndarray -from numpy.core.records import recarray -from numpy.core.records import fromarrays as recfromarrays - -#from cPickle import dump, dumps - -import core -reload(core) -from core import * - - -import maskedarray as MA -#reload(MA) -from maskedarray.core import domain_check_interval, \ - domain_greater_equal, domain_greater, domain_safe_divide, domain_tan -from maskedarray.core import MaskedArray, MAError, masked_array, isMaskedArray,\ - getmask, getmaskarray, filled, mask_or, make_mask -from maskedarray.core import convert_typecode, masked_print_option, \ - masked_singleton -from maskedarray.core import load, loads, dump, dumps - -import addons.numpyaddons -reload(addons.numpyaddons) -from addons.numpyaddons import ascondition - -#............................................................................... -talog = logging.getLogger('TimeArray') -tslog = logging.getLogger('TimeSeries') -mtslog = logging.getLogger('MaskedTimeSeries') - -nomask = MA.nomask -masked = MA.masked -masked_array = MA.masked_array -ufunc_domain = {} -ufunc_fills = {} - - -#### -------------------------------------------------------------------------- -#--- ... Date Tools ... -#### -------------------------------------------------------------------------- -dtmdefault = dtm.datetime(2001,1,1) - -def isDate(obj): - """Returns *True* if the argument is a `datetime.date` or `datetime.datetime` -instance.""" - return isinstance(obj,dtm.date) or isinstance(obj,dtm.datetime) - -def fake_dates(count, start=dtmdefault): - """fake_dates(count, start=dtmdefault) -Returns a *count x 1* array of daily `datetime` objects. -:Parameters: - - `count` (Integer) : Number of dates to output - - `start` (datetime object) : Starting date *[NOW]*.""" - dobj = list(dtmrule.rrule(DAILY,count=count,dtstart=start)) - return N.array(dobj) - -#### -------------------------------------------------------------------------- -#--- ... TimeArray class ... -#### -------------------------------------------------------------------------- -class TimeArrayError(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 TimeArray(ndarray): - """Stores datetime.dateime objects in an array.""" - def __new__(subtype, series, copy=False): - vlev = 3 - if isinstance(series, TimeArray): -# verbose.report("DA __new__: data isDA types %s, %s, %i" % \ -# (type(series), series, len(series)), vlev) - if not copy: - return series - else: - return series.copy() - else: - data = N.array(series) - if data.dtype.str == "|O8": - new = data #.view(subtype) - talog.debug("__new__: data isnotDA types %s, %s, %s, %i" % \ - (type(series), data.dtype, series, data.size),) - else: - new = N.empty(data.shape, dtype="|O8") - newflat = new.flat - talog.debug("DA __new__: data isnotDA types %s, %s, %s, %i" % \ - (type(series), data.dtype, series, data.size),) - # Forces years (as integers) to be read as characters - if N.all(data < 9999): - data = data.astype("|S4") - # Parse dates as characters - if data.dtype.char == "S": - for (k,s) in enumerate(data.flat): - newflat[k] = dtmparser.parse(s, default=dtmdefault) - else: - # Parse dates as ordinals - try: - for k,s in enumerate(data.flat): - newflat[k] = dtm.datetime.fromordinal(s) - except TypeError: - raise TypeError, "unable to process series !" - subtype._asobject = new - return new.view(subtype) -# #............................................ -# def __array_wrap__(self, obj): -# return TimeArray(obj) - #............................................ - def __array_finalize__(self, obj): - self._resolution = None - (self._years, self._months, self._days, self._yeardays) = [None]*4 - self._asobjects = None - self._asstrings = None - self._asordinals = None - return - #............................................ - def __len__(self): - "Returns the length of the object. Or zero if it fails." - if self.ndim == 0: - return 0 - return ndarray.__len__(self) - - - def __getitem__(self,i): - # Force a singleton to DateArray - try: - obj = ndarray.__getitem__(self,i) - except IndexError: - obj = self - return TimeArray(obj) -# if isDate(obj): -# return DateArray(obj) -# else: -# return obj - #............................................ - def __eq__(self, other): - return N.asarray(self).__eq__(N.asarray(other)) - - def __add__(self, other): - if not isinstance(other, dtm.timedelta): - raise TypeError, "Unsupported type for add operation" - return TimeArray(N.asarray(self).__add__(other)) - - def __sub__(self, other): - if not isinstance(other, dtm.timedelta) and \ - not isinstance(other, TimeArray): - raise TypeError, "Unsupported type for sub operation" - return N.asarray(self).__sub__(N.asarray(other)) - - def __mul__(self, other): - raise TimeArrayError, "TimeArray objects cannot be multiplied!" - __rmul__ = __mul__ - __imul__ = __mul__ -# def shape(self): -# if self.size == 1: -# return (1,) -# else: -# return self._data.shape - #............................................ - def __str__(self): - """x.__str__() <=> str(x)""" - return str(self.asstrings()) - def __repr__(self): - """Calculate the repr representation, using masked for fill if - it is enabled. Otherwise fill with fill value. - """ - template = """\ -timearray( - %(data)s,)""" - template_short = """\ -timearray(%(data)s)""" - if self.ndim <= 1: - return template_short % {'data': str(self)} - else: - return template % {'data': str(self)} - #............................................ - @property - def resolution(self): - """Calculates the initial resolution, as the smallest difference -between consecutive values (in days).""" - if self._resolution is None: - self._resolution = N.diff(self.asordinals().ravel()).min() - if self._resolution <= 3: - self._resolution = 1 - elif self._resolution <= 10: - self._resolution = 7 - elif self._resolution <= 270: - self._resolution = 30 - else: - self._resolution = 365 - return self._resolution - timestep = resolution - #............................................ - def has_missing_dates(self, resolution=None): - """Returns *True* there's a gap in the series, assuming a regular series -with a constant timestep of `resolution`. -If `resolution` is None, uses the default resolution of `self`. -""" - if self.size < 2: - return False - dt = N.diff(self.asordinals().ravel()) - if resolution is None: - resolution = self.resolution - if resolution == 1: - return (dt.max() > 1) - elif resolution == 30: - return (dt.max() > 31) - elif resolution == 365: - return (dt.max() > 730) - else: - #FIXME: OK, there's probly something wrong here... - return True - #............................................ - def asobjects(self): - """Transforms an array of ordinal dates to an array of date objects.""" - if self._asobjects is None: - if self.size == 1: - self._asobjects = self.item() - else: - self._asobjects = self - return self._asobjects - #............................................ - def asordinals(self): - """Transforms an array of dates to an array of date objects.""" - if self._asordinals is None: - # Build list of datetime objects - self._asordinals = N.empty(self.shape,dtype=int_) - _asordinalsflat = self._asordinals.flat - if self.size == 0: - self._asordinals = dtm.datetime.toordinal(dtmdefault) - elif self.size == 1: - self._asordinals = dtm.datetime.toordinal(self.item()) - else: - itr = (dtm.datetime.toordinal(val) for val in self.flat) - self._asordinals = N.fromiter(itr, float_) - return self._asordinals - #............................................ - def asstrings(self, stringsize=10): - """Transforms a *N*-array of ordinal dates to a *N*-list of -datestrings `YYYY-MM-DD`. - -:Parameters: - `stringsize` : Integer *[10]* - String size. - - - `< 4' outputs 4 - - `< 8' outputs 8 - - anything else outputs 10. - """ - if not stringsize: - strsize = 10 - elif stringsize <= 4: - strsize = 4 - elif stringsize <= 8: - strsize = 7 - else: - strsize = 10 - if self._asstrings is None: - deftype = "|S10" - if self.size == 0: - self._asstrings = N.array(dtmdefault.isoformat(), dtype=deftype) - elif self.size == 1: - self._asstrings = N.array(self.item().isoformat(), dtype=deftype) - else: - itr = (val.isoformat() for val in self.flat) - self._asstrings = N.fromiter(itr,dtype=deftype).reshape(self.shape) - return self._asstrings.getfield('S%i' % strsize) - #............................................ - def astype(self, newtype): - """Outputs the array in the type provided in argument.""" - newtype = N.dtype(newtype) - if newtype.type == int_: - return self.asordinals() - elif newtype.type == str_: - n = newtype.itemsize - if n > 0 : - return self.asstrings(stringsize=n) - else: - return self.asstrings(stringsize=n) - elif newtype.type == object_: - return self - else: - raise ValueError, "Invalid type: %s" % newtype - #------------------------------------------------------ - @property - def years(self): - """Returns the corresponding year (as integer).""" - if self._years is None: - self._years = self.asstrings(1).astype(int_) - return self._years - @property - def months(self): - """Returns the corresponding month (as integer).""" - if self._months is None: - self._months = N.empty(self.shape, dtype=int_) - _monthsflat = self._months.flat - if self.size == 1: - try: - _monthsflat[:] = self.asobjects().month - except AttributeError: - _monthsflat[:] = 1 - else: - for (k,val) in enumerate(self.asobjects().flat): - _monthsflat[k] = val.month - return self._months - @property - def days(self): - """Returns the corresponding day of month (as integer).""" - if self._days is None: - self._days = N.empty(self.shape, dtype=int_) - _daysflat = self._days.flat - if self.size == 1: - try: - _daysflat[:] = self.asobjects().day - except AttributeError: - _daysflat[:] = 1 - else: - for (k,val) in enumerate(self.asobjects().flat): - _daysflat[k] = val.day - return self._days - @property - def yeardays(self): - """Returns the corresponding day of year (as integer).""" - if self._yeardays is None: - self._yeardays = N.empty(self.size, dtype=int_) - _doyflat = self._yeardays.flat - for (k,val,yyy) in N.broadcast(N.arange(len(self)), - self.asordinals(), - self.years.flat): - _doyflat[k] = val - dtm.datetime(yyy-1,12,31).toordinal() - self._yeardays.reshape(self.shape).astype(int_) - return self._yeardays -#................................................ -def isTimeArray(x): - """Checks whether `x` is n array of times/dates (an instance of `TimeArray` ).""" - return isinstance(x,TimeArray) - -def time_array(t, copy=False): - """Creates a date array from the series `t`. - """ - if isinstance(t,TimeArray): - dobj = t - else: - t = N.asarray(t) - if t.dtype.str == "|O8": - dobj = t - else: - dobj = N.empty(t.shape, dtype="|O8") - dobjflat = dobj.flat - if t.dtype.char == 'S': - for k,s in enumerate(t.flat): - dobjflat[k] = dtmparser.parse(s) - else: - try: - for k,s in enumerate(t.flat): - dobjflat[k] = dtm.datetime.fromordinal(s) - except TypeError: - raise TypeError, "unable to process series !" - return TimeArray(dobj, copy=copy) - -#### -------------------------------------------------------------------------- -#--- ... Time Series ... -#### -------------------------------------------------------------------------- -class TimeSeriesError(Exception): - "Class for TS related errors." - def __init__ (self, args=None): - "Creates an exception." - Exception.__init__(self) - self.args = args - def __str__(self): - "Calculates the string representation." - return str(self.args) - __repr__ = __str__ -#...................................... -#TODO: __eq__, __cmp__ classes -class TimeSeries(ndarray, object): - """Base class for the definition of time series. -A time series is here defined as the combination of two arrays: - - - an array storing the time information (as a `TimeArray` instance); - - an array storing the data (as a `MaskedArray` instance. - """ - def __new__(cls, data, dates=None, dtype=None, copy=True): - tslog.debug("__new__: data types %s, %s" % (type(data), dtype)) -# if isinstance(data, TimeSeries): - if hasattr(data,"_series") and hasattr(data,"_dates"): - tslog.debug("__new__: data has _series and _dates") - tslog.debug("__new__: setting basedates",) - cls._basedates = data._dates - tslog.debug("__new__: setting basedates done",) - if (not copy) and (dtype == data.dtype): - return N.asarray(data).view(cls) - else: - return N.array(data, dtype=dtype).view(cls) - #.......... - dsize = N.size(data) - tslog.debug("__new__: args dates type %s, %s" % (type(dates), dates),) - if dates is None: - _dates = TimeArray(fake_dates(N.size(data))) - tslog.debug("__new__: args dates FAKED type %s, %s, %i" % \ - (type(dates), _dates, _dates.size),) - else: - _dates = TimeArray(dates) - tslog.debug("__new__: dates set to %s" % _dates,) - if _dates.size != dsize: - msg = "Incompatible sizes between dates (%i) and data (%i) !" - raise ValueError, msg % (_dates.size, dsize) - _dates.shape = N.shape(data) - cls._basedates = _dates - return N.array(data, copy=copy, dtype=dtype).view(cls) - #.................................. - def __array_wrap__(self, obj): - return TimeSeries(obj, dates=self._dates) - #.................................. - def __array_finalize__(self,obj): - if not hasattr(self,"_series"): - try: - self._series = obj._series - tslog.debug("__array_finalize__: obj._data => : %s - %s" % \ - (id(self._series), self._series.ravel() ),) - except AttributeError: - self._series = obj - tslog.debug("__array_finalize__: obj => : %s - %s" % \ - (id(self._series), self._series.ravel() ),) - if not hasattr(self,"_dates"): - self._dates = self._basedates - tslog.debug("__array_finalize__: dates set! => : %s - %s" % \ - (id(self._dates), self._dates.ravel() )) - return - #........................ - def _get_flat(self): - """Calculate the flat value. - """ - return self.__class__(self._series.ravel(), - dates = self._dates.ravel(), copy=False) - #.... - def _set_flat (self, value): - "x.flat = value" - y = self.ravel() - y[:] = value - flat = property(fget=_get_flat,fset=_set_flat,doc='Access array in flat form.') - #........................ - def _get_shape(self): - "Return the current shape." - return self._series.shape - #.... - def _set_shape (self, newshape): - "Set the array's shape." - self._series.shape = self._dates.shape = newshape - #.... - shape = property(fget=_get_shape, fset=_set_shape, doc="Array shape") - #.... - @property - def ndim(self): - """Returns the number of dimensions.""" - return self._series.ndim - @property - def size(self): - """Returns the total number of elements.""" - return self._series.size - #........................ - def __getitem__(self, i): - "Get item described by i. Not a copy as in previous versions." - (tout, dout) = (self._dates[i], self._series[i]) - return self.__class__(dout, dates=tout) - #.... - def __setitem__(self, index, value): - "Gets item described by i. Not a copy as in previous versions." - self._series[index] = value - return self - #........................ - def __getslice__(self, i, j): - "Gets slice described by i, j" - (tout, dout) = (self._dates[i:j], self._series[i:j]) - return self.__class__(dout, dates=tout,) - #.... - def __setslice__(self, i, j, value): - "Gets item described by i. Not a copy as in previous versions." - #TODO: Here, we should have a better test for self._dates==value._dates - if hasattr(value,"_dates"): - tslog.debug("__setslice__: value: %s" % str(value)) - tslog.debug("__setslice__: dates: %s" % str(value._dates),) - if not (self._dates == value._dates).all(): - raise TimeSeriesError,"Can't force a change of dates !" - self._series[i:j] = value - return self - #........................ - def ravel (self): - """Returns a 1-D view of self.""" - return self.__class__(self._series.ravel(), - dates=self._dates.ravel()) - #........................ - def __len__(self): - if self.ndim == 0: - return 0 - return ndarray.__len__(self) - def __str__(self): - """Returns a string representation of self (w/o the dates...)""" - return str(self._series) - def __repr__(self): - """Calculates the repr representation, using masked for fill if - it is enabled. Otherwise fill with fill value. - """ - desc = """\ -timeseries(data = - %(data)s, - dates = - %(time)s, ) -""" - desc_short = """\ -timeseries(data = %(data)s, - dates = %(time)s,) -""" - if self.ndim <= 1: - return desc_short % { - 'data': str(self._series), - 'time': str(self.dates), - } - return desc % { - 'data': str(self._series), - 'time': str(self.dates), - } - - def ids (self): - """Return the ids of the data, dates and mask areas""" - return (id(self._series), id(self.dates),) - - @property - def series(self): - "Returnhs the series." - return self._series - - #------------------------------------------------------ - @property - def dates(self): - """Returns the dates""" - return self._dates -### def _set_dates(self, object): -### """Returns the dates""" -### self._dates = object -### dates = property(fget=_get_dates, fset=_set_dates, doc="Dates") - @property - def years(self): - """Returns the corresponding years.""" - return self.dates.years - @property - def months(self): - """Returns the corresponding months.""" - return self._dates.months - @property - def yeardays(self): - """Returns the corresponding days of yuear.""" - return self._dates.yeardays - - def has_missing_dates(self): - """Returns whether there's a date gap in the series.""" - return self._dates.has_missing_dates() - -#### -------------------------------------------------------------------------- -#--- ... Additional methods ... -#### -------------------------------------------------------------------------- -class _tsmathmethod(object): - """Defines a wrapper for arithmetic array methods (add, mul...). -When called, returns a new TimeSeries object, with the new series the result of -the method applied on the original series. -The `_dates` part remains unchanged. - """ - def __init__ (self, binop): - """abfunc(fillx, filly) must be defined. - abinop(x, filly) = x for all x to enable reduce. - """ - self.f = binop - # - def __get__(self, obj, objtype=None): - self.obj = obj - return self - # - def __call__ (self, other, *args): - "Execute the call behavior." - instance = self.obj - _dates = instance._dates - tslog.debug("_tsmathmethod: series: %s" % instance,) - tslog.debug("_tsmathmethod: other : %s" % other,) - func = getattr(instance._series, self.f) - if hasattr(instance,"_dates") and hasattr(other,"_dates"): - tslog.debug("_tsmathmethod: instance : %s" % instance,) - tslog.debug("_tsmathmethod: other : %s" % other,) - if N.any(instance._dates != other._dates): - tslog.debug("_tsmathmethod %s on %s and %s" % \ - (self.f, instance, other),) - raise TimeSeriesError, "Method %s not yet implemented !" % self.f - return instance.__class__(func(other, *args), dates=_dates) -#...................................... -TimeSeries.__add__ = _tsmathmethod('__add__') -TimeSeries.__radd__ = _tsmathmethod('__add__') -TimeSeries.__sub__ = _tsmathmethod('__sub__') -TimeSeries.__rsub__ = _tsmathmethod('__rsub__') -TimeSeries.__pow__ = _tsmathmethod('__pow__') -TimeSeries.__mul__ = _tsmathmethod('__mul__') -TimeSeries.__rmul__ = _tsmathmethod('__mul__') -TimeSeries.__div__ = _tsmathmethod('__div__') -TimeSeries.__rdiv__ = _tsmathmethod('__rdiv__') -TimeSeries.__truediv__ = _tsmathmethod('__truediv__') -TimeSeries.__rtruediv__ = _tsmathmethod('__rtruediv__') -TimeSeries.__floordiv__ = _tsmathmethod('__floordiv__') -TimeSeries.__rfloordiv__ = _tsmathmethod('__rfloordiv__') -#................................................ -class _tsarraymethod(object): - """Defines a wrapper for basic array methods. -When called, returns a new TimeSeries object, with the new series the result of -the method applied on the original series. -If `ondates` is True, the same operation is performed on the `_dates`. -If `ondates` is False, the `_dates` part remains unchanged. - """ - def __init__ (self, methodname, ondates=False): - """abfunc(fillx, filly) must be defined. - abinop(x, filly) = x for all x to enable reduce. - """ - self._name = methodname - self._ondates = ondates - # - def __get__(self, obj, objtype=None): - self.obj = obj - return self - # - def __call__ (self, *args): - "Execute the call behavior." - _name = self._name - instance = self.obj - func_series = getattr(instance._series, _name) - if self._ondates: - func_dates = getattr(instance._dates, _name) - return instance.__class__(func_series(*args), - dates=func_dates(*args)) - else: - return instance.__class__(func_series(*args), - dates=instance._dates) -#...................................... -class _tsaxismethod(object): - """Defines a wrapper for array methods working on an axis (mean...). -When called, returns a ndarray, as the result of the method applied on the original series. - """ - def __init__ (self, methodname): - """abfunc(fillx, filly) must be defined. - abinop(x, filly) = x for all x to enable reduce. - """ - self._name = methodname - # - def __get__(self, obj, objtype=None): - self.obj = obj - return self - # - def __call__ (self, *args, **params): - "Execute the call behavior." - func = getattr(self.obj._series, self._name) - return func(*args, **params) -#....................................... -TimeSeries.astype = _tsarraymethod('astype') -TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) -TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) -TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) -TimeSeries.copy = _tsarraymethod('copy', ondates=True) -TimeSeries.compress = _tsarraymethod('compress', ondates=True) -# -TimeSeries.sum = _tsaxismethod('sum') -TimeSeries.cumsum = _tsaxismethod('cumsum') -TimeSeries.prod = _tsaxismethod('prod') -TimeSeries.cumprod = _tsaxismethod('cumprod') -TimeSeries.mean = _tsaxismethod('mean') -TimeSeries.var = _tsaxismethod('var') -TimeSeries.varu = _tsaxismethod('varu') -TimeSeries.std = _tsaxismethod('std') -TimeSeries.stdu = _tsaxismethod('stdu') - - -#.............................................................................. -def concatenate(arrays, axis=0): - """Concatenates a sequence of time series.""" - concatenate.__doc__ = N.concatenate.__doc__ - for a in arrays: - if hasattr(a,"_dates"): - raise TimeSeriesError, "Not yet implemented for TimeSeries !" - -#### --------------------------------------------------------------------------- -#--- ... Pickling ... -#### --------------------------------------------------------------------------- -#FIXME: We're kinda stuck with forcing the mask to have the same shape as the data -def _tsreconstruct(baseclass, datesclass, baseshape, basetype): - """Internal function that builds a new MaskedArray from the information stored -in a pickle.""" - _series = ndarray.__new__(ndarray, baseshape, basetype) - _dates = ndarray.__new__(datesclass, baseshape, basetype) - return TimeSeries.__new__(baseclass, _series, dates=_dates, dtype=basetype) - -def _tsgetstate(a): - "Returns the internal state of the TimeSeries, for pickling purposes." - #TODO: We should prolly go through a recarray here as well. - state = (1, - a.shape, - a.dtype, - a.flags.fnc, - (a._series).__reduce__()[-1][-1], - (a._dates).__reduce__()[-1][-1]) - return state - -def _tssetstate(a, 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 - - a binary string for the data - - a binary string for the mask. - """ - (ver, shp, typ, isf, raw, dti) = state - (a._series).__setstate__((shp, typ, isf, raw)) - (a._dates).__setstate__((shp, N.dtype('|O8'), isf, dti)) - (a._dates)._asstrings = None - -def _tsreduce(a): - """Returns a 3-tuple for pickling a MaskedArray.""" - return (_tsreconstruct, - (a.__class__, a._dates.__class__, (0,), 'b', ), - a.__getstate__()) - -TimeSeries.__getstate__ = _tsgetstate -TimeSeries.__setstate__ = _tssetstate -TimeSeries.__reduce__ = _tsreduce -TimeSeries.__dump__ = dump -TimeSeries.__dumps__ = dumps - -#................................................ -def tofile(self, output, sep='\t', format='%s', format_dates=None): - """Writes the TimeSeries to a file. - -:Parameters: - - `output` (String) : Name or handle of the output file. - - `sep` (String) : Column separator *['\t']*. - - `format` (String) : Data format *['%s']*. - """ - if not hasattr(output, 'writeline'): - ofile = open(output,'w') - else: - ofile = output - oformat = "%%s%s%s" % (sep,format) - for (_dates,_data) in N.broadcast(self._dates.ravel().asstrings(), - filled(self)): - ofile.write('%s\n' % sep.join([oformat % (_dates, _data) ])) - ofile.close() -TimeSeries.tofile = tofile - -#### -------------------------------------------------------------------------- -#--- ... Shortcuts ... -#### -------------------------------------------------------------------------- -def isTimeSeries(x): - """Checks whether `x` is a time series (an instance of `TimeSeries` ).""" - return isinstance(x, TimeSeries) - -#### -------------------------------------------------------------------------- -#--- ... MaskedTimeSeries class ... -#### -------------------------------------------------------------------------- -class MaskedTimeSeries(MaskedArray, TimeSeries): - """Base class for the definition of time series. -A time series is here defined as the combination of two arrays: - - - an array storing the time information (as a `TimeArray` instance); - - an array storing the data (as a `MaskedArray` instance. - """ - def __new__(cls, data, dates=None, mask=nomask, - dtype=None, copy=True, fill_value=-9999): - mtslog.log(5, "__new__: data types %s, %s" % (type(data), dtype)) -# if isinstance(data, TimeSeries): - #.................... - if isinstance(data, TimeSeries): - if isinstance(data, MaskedTimeSeries): - _data = data._data - else: - _data = data - _dates = data._dates - _series = data._series - mtslog.log(5, "__new__ from TS: data %i - %s - %s" % \ - (id(_data._series), type(_data._series), _data.ravel())) - mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ - (id(_dates), type(_dates), _dates.ravel())) - elif isinstance(data, recarray): - assert(data.dtype.names == ('_dates', '_series', '_mask'), - "Invalid fields names (got %s)" % (data.dtype.names,)) - _dates = data['_dates'] - _series = data['_series'] - _mask = data['_mask'] - else: - if hasattr(data, "_data"): - _data = TimeSeries(data._data, dates=dates, - dtype=dtype, copy=copy) - else: - _data = TimeSeries(data, dates=dates, - dtype=dtype, copy=copy) - _dates = _data._dates - _series = _data._series - mtslog.log(5,"__new__ from scratch: data %i - %s - %s" % \ - (id(_data._series), type(_data._series), _data.ravel())) - mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ - (id(_dates), type(_dates), _dates.ravel())) - #..................... - if mask is nomask: - if hasattr(data, "_mask"): - _mask = data._mask - else: - _mask = nomask - else: - _mask = make_mask(mask, copy=copy, flag=True) - #....Check shapes compatibility - if _mask is not nomask: - (nd, nm) = (_data.size, _mask.size) - if (nm != nd): - if nm == 1: - _mask = N.resize(_mask, _data.shape) - elif nd == 1: - _data = N.resize(_data, _mask.shape) - else: - msg = "Mask and data not compatible (size issues: %i & %i)." - raise MAError, msg % (nm, nd) - elif (_mask.shape != _data.shape): - mtslog.log(5,"__new__ from scratch: force _mask shape %s > %s" % \ - (_mask.shape, _data.shape)) - _mask.shape = _data.shape - #.... - cls._fill_value = fill_value - cls._basemask = _mask - cls._basedates = _dates - cls._baseseries = _series - return _data.view(cls) -# return _series.view(cls) - #.............. - def __array_wrap__(self, obj, context=None): - """Special hook for ufuncs. -Wraps the numpy array and sets the mask according to context. - """ -# return MaskedArray.__array_wrap__(obj, context=None) - return MaskedTimeSeries(obj, dates=self._dates, mask=self._mask, - fill_value=self._fill_value) - - #.............. - def __array_finalize__(self,obj): - mtslog.log(5, "__array_finalize__: obj is %s" % (type(obj), )) - if not hasattr(self, "_data"): - self._data = obj - if not hasattr(self, "_dates"): - self._dates = self._basedates - mtslog.log(5, "__array_finalize__: set dates to: %s - %s" % \ - (id(self._dates), self._dates.ravel() )) - if not hasattr(self, "_mask"): - self._mask = self._basemask - mtslog.log(5, "__array_finalize__: set mask to: %s - %s" % \ - (id(self._mask), self._mask.ravel() )) - if not hasattr(self, "_series"): - if hasattr(obj, "_series"): - self._series = obj._series - else: - self._series = obj - self.fill_value = self._fill_value - return - - #------------------------------------------------------ -# def __mul__(self): - #------------------------------------------------------ - def __str__(self): - """Calculate the str representation, using masked for fill if - it is enabled. Otherwise fill with fill value. - """ - if masked_print_option.enabled(): - f = masked_print_option - # XXX: Without the following special case masked - # XXX: would print as "[--]", not "--". Can we avoid - # XXX: checks for masked by choosing a different value - # XXX: for the masked singleton? 2005-01-05 -- sasha - if self is masked: - return str(f) - m = self._mask - if m is nomask: - res = self._data - else: - if m.shape == () and m: - return str(f) - # convert to object array to make filled work - res = (self._series).astype("|O8") - res[self._mask] = f - else: - res = self.filled(self.fill_value) - return str(res) - - def __repr__(self): - """Calculate the repr representation, using masked for fill if - it is enabled. Otherwise fill with fill value. - """ - desc = """\ -timeseries(data = - %(data)s, - mask = - %(mask)s, - date = - %(time)s, ) -""" - desc_short = """\ -timeseries(data = %(data)s, - mask = %(mask)s, - date = %(time)s,) -""" -# if (self._mask is nomask) and (not self._mask.any()): -# if self.ndim <= 1: -# return without_mask1 % {'data':str(self.filled()), -# 'time':str(self._dates.asstrings())} -# return without_mask % {'data':str(self.filled()), -# 'time':str(self._dates.asstrings())} -# else: - if self.ndim <= 1: - return desc_short % { - 'data': str(self), - 'mask': str(self._mask), - 'time': str(self.dates), - } - return desc % { - 'data': str(self), - 'mask': str(self._mask), - 'time': str(self.dates), - } - #............................................ - def ids (self): - """Return the ids of the data, dates and mask areas""" - return (id(self._series), id(self.dates), id(self._mask)) - #............................................ - @property - def maskedseries(self): - """Returns a masked array of the series (dates are omitteed).""" - return masked_array(self._series, mask=self._mask) - _mseries = maskedseries - #............................................ - def filled(self, fill_value=None): - """A numeric array with masked values filled. If fill_value is None, - use self.fill_value(). - - If mask is nomask, copy data only if not contiguous. - Result is always a contiguous, numeric array. -# Is contiguous really necessary now? - """ - (d, m) = (self._data, self._mask) - if m is nomask: - return d - # - if fill_value is None: - value = self._fill_value - else: - value = fill_value - # - if self is masked_singleton: - return numeric.array(value) - # - result = d.copy() - try: - result.__setitem__(m, value) - except (TypeError, AttributeError): - #ok, can't put that value in here - value = numeric.array(value, dtype=object) - d = d.astype(object) - result = fromnumeric.choose(m, (d, value)) - except IndexError: - #ok, if scalar - if d.shape: - raise - elif m: - result = numeric.array(value, dtype=d.dtype) - else: - result = d - return result - #............................................ - def sum(self, axis=None, dtype=None): - """a.sum(axis=None, dtype=None) -Sums the array `a` over the given axis `axis`. -Masked values are set to 0. -If `axis` is None, applies to a flattened version of the array. - """ - if self._mask is nomask: - return self._data.sum(axis, dtype=dtype) - else: - if axis is None: - return self.filled(0).sum(None, dtype=dtype) - return MaskedArray(self.filled(0).sum(axis, dtype=dtype), - mask=self._mask.all(axis)) - - def cumsum(self, axis=None, dtype=None): - """a.cumprod(axis=None, dtype=None) -Returns the cumulative sum of the elements of array `a` along the given axis `axis`. -Masked values are set to 0. -If `axis` is None, applies to a flattened version of the array. - """ - if self._mask is nomask: - return self._data.cumsum(axis=axis, dtype=dtype) - else: - if axis is None: - return self.filled(0).cumsum(None, dtype=dtype) - return MaskedArray(self.filled(0).cumsum(axis=axis, dtype=dtype), - mask=self._mask) - - def prod(self, axis=None, dtype=None): - """a.prod(axis=None, dtype=None) -Returns the product of the elements of array `a` along the given axis `axis`. -Masked elements are set to 1. -If `axis` is None, applies to a flattened version of the array. - """ - if self._mask is nomask: - return self._data.prod(axis=axis, dtype=dtype) - else: - if axis is None: - return self.filled(1).prod(None, dtype=dtype) - return MaskedArray(self.filled(1).prod(axis=axis, dtype=dtype), - mask=self._mask.all(axis)) - product = prod - - def cumprod(self, axis=None, dtype=None): - """a.cumprod(axis=None, dtype=None) -Returns the cumulative product of ethe lements of array `a` along the given axis `axis`. -Masked values are set to 1. -If `axis` is None, applies to a flattened version of the array. - """ - if self._mask is nomask: - return self._data.cumprod(axis=axis, dtype=dtype) - else: - if axis is None: - return self.filled(1).cumprod(None, dtype=dtype) - return MaskedArray(self.filled(1).cumprod(axis=axis, dtype=dtype), - mask=self._mask) - - def mean(self, axis=None, dtype=None): - """mean(a, axis=None, dtype=None) -Returns the arithmetic mean. - -The mean is the sum of the elements divided by the number of elements. - """ - if self._mask is nomask: - return self._data.mean(axis=axis, dtype=dtype) - else: - sum = N.sum(self.filled(0), axis=axis, dtype=dtype) - cnt = self.count(axis=axis) - if axis is None: - if self._mask.all(None): - return masked - else: - return sum*1./cnt - return MaskedArray(sum*1./cnt, mask=self._mask.all(axis)) - - def anom(self, axis=None, dtype=None): - """a.anom(axis=None, dtype=None) -Returns the anomalies, or deviation from the average. - """ - m = self.mean(axis, dtype) - if not axis: - return (self - m) - else: - return (self - N.expand_dims(m,axis)) - - def var(self, axis=None, dtype=None): - """a.var(axis=None, dtype=None) -Returns the variance, a measure of the spread of a distribution. - -The variance is the average of the squared deviations from the mean, -i.e. var = mean((x - x.mean())**2). - """ - if self._mask is nomask: - return MaskedArray(self._data.var(axis=axis, dtype=dtype), - mask=nomask) - else: - cnt = self.count(axis=axis) - anom = self.anom(axis=axis, dtype=dtype) - anom *= anom - dvar = anom.sum(axis) - dvar /= cnt - if axis is None: - return dvar - return MaskedArray(dvar, mask=mask_or(self._mask.all(axis), (cnt==1))) - - def std(self, axis=None, dtype=None): - """a.std(axis=None, dtype=None) -Returns the standard deviation, a measure of the spread of a distribution. - -The standard deviation is the square root of the average of the squared -deviations from the mean, i.e. std = sqrt(mean((x - x.mean())**2)). - """ - var = self.var(axis,dtype) - if axis is None: - if var is masked: - return masked - else: - return N.sqrt(var) - return MaskedArray(N.sqrt(var._data), mask=var._mask) - - def varu(self, axis=None, dtype=None): - """a.var(axis=None, dtype=None) -Returns an unbiased estimate of the variance. - -Instead of dividing the sum of squared anomalies by n, the number of elements, -this sum is divided by n-1. - """ - cnt = self.count(axis=axis) - anom = self.anom(axis=axis, dtype=dtype) - anom *= anom - var = anom.sum(axis) - var /= (cnt-1) - if axis is None: - return var - return MaskedArray(var, mask=mask_or(self._mask.all(axis), (cnt==1))) - - def stdu(self, axis=None, dtype=None): - """a.var(axis=None, dtype=None) -Returns an unbiased estimate of the standard deviation. - """ - var = self.varu(axis,dtype) - if axis is None: - if var is masked: - return masked - else: - return N.sqrt(var) - return MaskedArray(N.sqrt(var._data), mask=var._mask) - #............................................ - def asrecords(self): - """Returns the masked time series as a recarray. -Fields are `_dates`, `_data` and _`mask`. - """ - desctype = [('_dates','|O8'), ('_series',self.dtype), ('_mask',N.bool_)] - flat = self.ravel() - if flat.size > 0: - return recfromarrays([flat._dates, flat._series, getmaskarray(flat)], - dtype=desctype, - shape = (flat.size,), - ) - else: - return recfromarrays([[], [], []], dtype=desctype, - shape = (flat.size,), - ) - - -# def reshape (self, *s): -# """This array reshaped to shape s""" -# self._data = self._data.reshape(*s) -# self._dates = self._dates.reshape(*s) -# if self._mask is not nomask: -# self._mask = self._mask.reshape(*s) -# return self.view() -#### -------------------------------------------------------------------------- -#--- ... Pickling ... -#### -------------------------------------------------------------------------- -def _mtsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): - """Internal function that builds a new MaskedArray from the information stored -in a pickle.""" -# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" - _series = ndarray.__new__(ndarray, baseshape, basetype) - _dates = ndarray.__new__(datesclass, baseshape, '|O8') - _mask = ndarray.__new__(ndarray, baseshape, '|O8') - return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, - dtype=basetype, fill_value=fill_value) -# -def _mtsgetstate(a): - "Returns the internal state of the TimeSeries, for pickling purposes." -# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" - records = a.asrecords() - state = (1, - a.shape, - a.dtype, - records.flags.fnc, - a.fill_value, - records - ) - return state -# -def _mtssetstate(a, 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 - - a binary string for the data - - a binary string for the mask. - """ - (ver, shp, typ, isf, flv, rec) = state - a.fill_value = flv - a._data._series = a._series = N.asarray(rec['_series']) - a._data._series.shape = a._series.shape = shp - a._data._dates = a._dates = a._dates.__class__(rec['_dates']) - a._data._dates.shape = a._dates.shape = shp - (a._dates)._asstrings = None - a._mask = N.array(rec['_mask'], dtype=MA.MaskType) - a._mask.shape = shp -# -def _mtsreduce(a): - """Returns a 3-tuple for pickling a MaskedArray.""" - return (_mtsreconstruct, - (a.__class__, a.dates.__class__, (0,), 'b', -9999), - a.__getstate__()) -# -MaskedTimeSeries.__getstate__ = _mtsgetstate -MaskedTimeSeries.__setstate__ = _mtssetstate -MaskedTimeSeries.__reduce__ = _mtsreduce -MaskedTimeSeries.__dump__ = dump -MaskedTimeSeries.__dumps__ = dumps - -##### ------------------------------------------------------------------------- -#---- --- TimeSeries creator --- -##### ------------------------------------------------------------------------- -def time_series(data, dates=None, mask=nomask, copy=False, fill_value=None): - """Creates a TimeSeries object - -:Parameters: - `dates` : ndarray - Array of dates. - `data` : - Array of data. - """ - if isinstance(data, MaskedTimeSeries): - if not copy: - data._mask = mask_or(data._mask, mask) - return data - _data = data._data - _mask = mask_or(data._mask, mask) - _dates = _data.dates - elif isinstance(data, TimeSeries): - _data = data._series - _mask = make_mask(mask) - _dates = data.dates - else: - data = masked_array(data, copy=False) - _data = data._data - _mask = mask_or(data._mask, mask) - if dates is None: - _dates = fake_dates(data.size) - else: - _dates = time_array(dates) - return MaskedTimeSeries(_data, dates=_dates, mask=_mask, copy=copy, - fill_value=fill_value) - - -# - -#### -------------------------------------------------------------------------- -#--- ... Additional functions ... -#### -------------------------------------------------------------------------- -def check_dates(a,b): - """Returns the array of dates from the two objects `a` or `b` (or None).""" - if isTimeSeries(a): - if isTimeSeries(b) and (a._dates == b._dates).all() is False: - raise ValueError, "Incompatible dates !" - return a._dates - elif isTimeSeries(b): - return b._dates - else: - return - -def parse_period(period): - """Returns a TimeArray couple (starting date; ending date) from the arguments.""" -#### print "........DEBUG PARSE DATES: period %s is %s" % (period, type(period)) -# if isinstance(period,TimeArray) or isinstance(period,Dates): -#### print "........DEBUG PARSE_PERIOD: OK" - if isinstance(period,TimeArray): - return (period[0],period[-1]) - elif hasattr(period,"__len__"): - if not isinstance(period[0], TimeArray): - tstart = TimeArray(period[0]) - else: - tstart = period[0] - if not isinstance(period[-1], TimeArray): - tend = TimeArray(period[-1]) - else: - tend = period[-1] - return (tstart, tend) - else: - p = N.asarray(period) - if N.all(p < 9999): - p = N.array(period,dtype="|S4") - p = time_array(p) - return (p[0], p[-1]) - -def where_period(period, dates, *choices): - """Returns choices fro True/False, whether dates fall during a given period. -If no choices are given, outputs the array indices for the dates falling in the -period. - -:Parameters: - `period` : Sequence - Selection period, as a sequence (starting date, ending date). - `dates` : TimeArray - Array of dates. - `choices` : *(optional)* - Arrays to select from when the condition is True/False. - """ - (tstart, tend) = parse_period(period) - condition = ascondition((dates>=tstart)&(dates<=tend)) - condition = (dates>=tstart)&(dates<=tend) - return N.where(condition, *choices) - -def masked_inside_period(data, period, dates=None): - """Returns x as an array masked where dates fall inside the selection period, -as well as where data are initially missing (masked).""" - (tstart, tend) = parse_period(period) - # Get dates .................. - if hasattr(data, "_dates"): - dates = data._dates - elif dates is None: - raise ValueError,"Undefined dates !" - else: - assert(N.size(dates)==N.size(data), - "Inconsistent data and dates sizes!") - # where_period yields True inside the period, when mask should yield False - condition = ascondition(N.logical_and((dates>=tstart), (dates<=tend))) - cm = filled(condition,True).reshape(data.shape) - mask = mask_or(MA.getmaskarray(data), cm, copy=True) - if isinstance(data, MaskedTimeSeries): - return data.__class__(data._data, dates=dates, mask=mask, copy=True) - if isinstance(data, TimeSeries): - return MaskedTimeSeries(data, dates=dates, mask=mask, copy=True) - else: - return masked_array(data, mask=mask, copy=True) - -def masked_outside_period(data, period, dates=None): - """Returns x as an array masked where dates fall outside the selection period, -as well as where data are initially missing (masked).""" - (tstart, tend) = parse_period(period) - if hasattr(data, "_dates"): - dates = data._dates - elif dates is None: - raise ValueError,"Undefined dates !" - else: - assert(N.size(dates)==N.size(data), - "Inconsistent data and dates sizes!") - #................ - condition = ascondition(N.logical_or((datestend))) - cm = filled(condition,True).reshape(data.shape) - mask = mask_or(MA.getmaskarray(data), cm, copy=True) - if isinstance(data, MaskedTimeSeries): - return data.__class__(data._data, dates=dates, mask=mask, copy=True) - if isinstance(data, TimeSeries): - return MaskedTimeSeries(data, dates=dates, mask=mask, copy=True) - else: - return masked_array(data, mask=mask, copy=True) - -#.............................................................................. -def fill_missing_dates(dates,data,resolution=None,fill_value=None): - """Finds and fills the missing dates in a time series, and allocates a -default filling value to the data corresponding to the newly added dates. - -:Parameters: - `dates` - Initial array of dates. - `data` - Initial array of data. - `resolution` : float *[None]* - New date resolutions, in years. For example, a value of 1/365.25 indicates - a daily resolution. If *None*, the initial resolution is used instead. - `fill_value` : float - Default value for missing data. - """ - if not isinstance(dates, TimeArray): - print "DEBUG FILL_MISSING_DATES: dates was %s" % type(dates) - dates = TimeArray(dates) - print "DEBUG FILL_MISSING_DATES: dates is %s" % type(dates) - dflat = dates.ravel() - n = len(dflat) - # Get data ressolution ....... - if resolution is None: - resolution = dflat.resolution - if resolution >= 28 and resolution <= 31: - resolution = 30 - else: - resolution = int(1./float(resolution)) - # Find on what to fill ....... - if resolution == 1: - (resol, freq, refdelta) = (DAILY, 1, dtmdelta.relativedelta(days=+1)) - elif resolution == 7: - (resol, freq, refdelta) = (WEEKLY, 1, dtmdelta.relativedelta(days=+7)) - elif resolution == 30: - (resol, freq, refdelta) = (MONTHLY, 1, dtmdelta.relativedelta(months=+1)) - elif resolution == 365: - (resol, freq, refdelta) = (YEARLY, 1, dtmdelta.relativedelta(years=+1)) - else: - raise ValueError,\ - "Unable to define a proper date resolution (found %s)." % resolution - # ...and now, fill it ! ...... - (tstart, tend) = dflat.asobjects()[[0,-1]].tolist() - gaprule = dtmrule.rrule(resol, interval=freq, dtstart=tstart, until=tend) - newdates = dates.__class__(list(gaprule)) - #............................. - # Get the steps between consecutive data. We need relativedelta to deal w/ months - delta = N.array([dtmdelta.relativedelta(b,a) - for (b,a) in N.broadcast(dflat[1:],dflat[:-1])]) - dOK = N.equal(delta,refdelta) - slcid = N.r_[[0,], N.arange(1,n).compress(-dOK), [n,]] - oldslc = N.array([slice(i,e) for (i,e) in N.broadcast(slcid[:-1],slcid[1:])]) - if resolution == 1: - addidx = N.cumsum([d.days for d in N.diff(dflat).compress(-dOK)]) - elif resolution == 30: - addidx = N.cumsum([d.years*12+d.months for d in delta.compress(-dOK)]) - elif resolution == 365: - addidx = N.cumsum([d.years for d in delta.compress(-dOK)]) - addidx -= N.arange(len(addidx)) - newslc = N.r_[[oldslc[0]], - [slice(i+d-1,e+d-1) for (i,e,d) in \ - N.broadcast(slcid[1:-1],slcid[2:],addidx)] - ] -# misslc = [slice(i,i+d-1) -# for (i,d) in N.broadcast(slcid[1:-1],addidx)] - #............................. - # Just a quick check - for (osl,nsl) in zip(oldslc,newslc): - assert N.equal(dflat[osl],newdates[nsl]).all(),\ - "Slicing mishap ! Please check %s (old) and %s (new)" % (osl,nsl) - #............................. - data = MA.asarray(data) - oldmask = MA.getmaskarray(data) - newdata = N.empty(newdates.size,data.dtype) - newmask = N.ones(newdates.size, bool_) - if fill_value is None: - if hasattr(data,'fill_value'): - fill_value = data.fill_value - else: - fill_value = MA.default_fill_value(data) - data = data.filled(fill_value) - newdata.fill(fill_value) - #.... - for (new,old) in zip(newslc,oldslc): - newdata[new] = data[old] - newmask[new] = oldmask[old] -# for mis in misslc: -# newdata[mis].fill(fill_value) - # Get new shape .............. - if data.ndim == 1: - nshp = (newdates.size,) - else: - nshp = tuple([-1,] + list(data.shape[1:])) - return MaskedTimeSeries(newdata.reshape(nshp), - dates=newdates.reshape(nshp), - mask=newmask.reshape(nshp), - fill_value=fill_value) - -######-------------------------------------------------------------------------- -##---- --- Archiving --- -######-------------------------------------------------------------------------- -#import iodata.iotools as iotools -#def archive(timeseries,filename,compression=None): -# data = timeseries.asrecords() -# iotools.archive(data, filename, compression) -# -#def unarchive(filename): -# raise NotImplementedError - - -############################################################################### \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py 2007-01-03 06:08:11 UTC (rev 2480) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tscore.py 2007-01-03 08:12:10 UTC (rev 2481) @@ -136,15 +136,13 @@ #####--------------------------------------------------------------------------- #---- --- Misc functions --- #####--------------------------------------------------------------------------- -#def flatten(listOfLists): -# return list(chain(*listOfLists)) #http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348 -def flatten(iterable): +def flatten_sequence(iterable): """Flattens a compound of nested iterables.""" itm = iter(iterable) for elm in itm: if hasattr(elm,'__iter__') and not isinstance(elm, basestring): - for f in flatten(elm): + for f in flatten_sequence(elm): yield f else: yield elm @@ -154,6 +152,6 @@ if not hasattr(args, '__iter__'): return args else: - return flatten(args) + return flatten_sequence(args) Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-03 06:08:11 UTC (rev 2480) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-03 08:12:10 UTC (rev 2481) @@ -703,6 +703,22 @@ self.__tostr = tostr return self.__tostr # +# def asfreq_ini(self, freq=None): +# "Converts the dates to another frequency." +# # Note: As we define a new object, we don't need caching +# if freq is None: +# return self +# freq = corelib.fmtFreq(freq) +# if freq == self.freq: +# return self +# if self.isvalid(): +# new = numeric.arange(self.size, dtype=int_) +# new += self[0].asfreq(freq).value +# else: +# new = numpy.fromiter((d.asfreq(freq).value for d in self), +# dtype=float_) +# return DateArray(new, freq=freq) + def asfreq(self, freq=None): "Converts the dates to another frequency." # Note: As we define a new object, we don't need caching @@ -711,12 +727,8 @@ freq = corelib.fmtFreq(freq) if freq == self.freq: return self - if self.isvalid(): - new = numeric.arange(self.size, dtype=int_) - new += self[0].asfreq(freq).value - else: - new = numpy.fromiter((d.asfreq(freq).value for d in self), - dtype=float_) + new = numpy.fromiter((d.asfreq(freq).value for d in self), + dtype=float_) return DateArray(new, freq=freq) #...................................................... def find_dates(self, *dates): @@ -1052,3 +1064,7 @@ myDateD = Date(freq='D',year=1985,month=10,day=4) #------------------------------------------------ + if 1: + dlist = ['2007-01-%02i' % i for i in range(1,15)] + dates = date_array_fromlist(dlist) + dates_2 = dates.asfreq('M') \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-03 06:08:11 UTC (rev 2480) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-03 08:12:10 UTC (rev 2481) @@ -119,9 +119,14 @@ if a.freq != b.freq: raise TimeSeriesCompatibilityError('freq', a.freq, b.freq) elif a.start_date() != b.start_date(): - raise TimeSeriesCompatibilityError('start_date', a.start_date(), b.start_date()) + raise TimeSeriesCompatibilityError('start_date', + a.start_date(), b.start_date()) + elif (a._dates.get_steps() != b._dates.get_steps()).any(): + raise TimeSeriesCompatibilityError('time_steps', + a._dates.get_steps(), b._dates.get_steps()) elif a.shape != b.shape: - raise TimeSeriesCompatibilityError('size', str(a.shape), str(b.shape)) + raise TimeSeriesCompatibilityError('size', "1: %s" % str(a.shape), + "2: %s" % str(b.shape)) return True def _datadatescompat(data,dates): @@ -134,12 +139,19 @@ if dsize == tsize: return True elif data.ndim > 1: - dsize = numeric.asarray(data.shape[1:]).prod() + dsize = numeric.asarray(data.shape)[:-1].prod() if dsize == tsize: return True - raise TimeSeriesCompatibilityError('size', dsize, tsize) - + raise TimeSeriesCompatibilityError('size', "data: %s" % dsize, + "dates: %s" % tsize) +def _getdatalength(data): + "Estimates the length of a series (size/nb of variables)." + if numeric.ndim(data) >= 2: + return numeric.asarray(numeric.shape(data))[:-1].prod() + else: + return numeric.size(data) + ##### -------------------------------------------------------------------------- ##--- ... Time Series ... ##### -------------------------------------------------------------------------- @@ -196,10 +208,7 @@ else: # Check dates ........ if dates is None: - if numeric.ndim(data) >= 2: - length = numeric.asarray(numeric.shape(data))[1:].prod() - else: - length = numeric.size(data) + length = _getdatalength(data) newdates = date_array(start_date=start_date, length=length, freq=freq) elif not hasattr(dates, 'freq'): @@ -606,10 +615,9 @@ dates=instance._dates) #TimeSeries.astype = _tsarraymethod('astype') TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) -TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) -TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) TimeSeries.copy = _tsarraymethod('copy', ondates=True) TimeSeries.compress = _tsarraymethod('compress', ondates=True) +TimeSeries.ravel = _tsarraymethod('ravel', ondates=True) TimeSeries.filled = _tsarraymethod('filled', ondates=False) TimeSeries.cumsum = _tsarraymethod('cumsum',ondates=False) TimeSeries.cumprod = _tsarraymethod('cumprod',ondates=False) @@ -640,7 +648,7 @@ else: try: axis = params.get('axis', args[0]) - if axis == 0: + if axis in [-1, _series.ndim-1]: result = TimeSeries(result, dates=_dates) except IndexError: pass @@ -654,6 +662,25 @@ TimeSeries.std = _tsaxismethod('std') TimeSeries.stdu = _tsaxismethod('stdu') +class _tsblockedmethods(object): + """Defines a wrapper for array methods that should be temporarily disabled. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + raise NotImplementedError +TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) +TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) + + #####--------------------------------------------------------------------------- #---- --- Definition of functions from the corresponding methods --- #####--------------------------------------------------------------------------- @@ -697,7 +724,7 @@ ##### --------------------------------------------------------------------------- #---- ... Additional methods ... ##### --------------------------------------------------------------------------- -def tofile(self, output, sep='\t', format='%s', format_dates=None): +def tofile(self, output, sep='\t', format_dates=None): """Writes the TimeSeries to a file. :Parameters: @@ -718,328 +745,105 @@ ofile.close() TimeSeries.tofile = tofile -##### --------------------------------------------------------------------------- -##--- ... Pickling ... -##### --------------------------------------------------------------------------- -##FIXME: We're kinda stuck with forcing the mask to have the same shape as the data -#def _tsreconstruct(baseclass, datesclass, baseshape, basetype): -# """Internal function that builds a new MaskedArray from the information stored -#in a pickle.""" -# _series = ndarray.__new__(ndarray, baseshape, basetype) -# _dates = ndarray.__new__(datesclass, baseshape, basetype) -# return TimeSeries.__new__(baseclass, _series, dates=_dates, dtype=basetype) -# -#def _tsgetstate(a): -# "Returns the internal state of the TimeSeries, for pickling purposes." -# #TODO: We should prolly go through a recarray here as well. -# state = (1, -# a.shape, -# a.dtype, -# a.flags.fnc, -# (a._series).__reduce__()[-1][-1], -# (a._dates).__reduce__()[-1][-1]) -# return state +#............................................ +def asrecords(series): + """Returns the masked time series as a recarray. +Fields are `_dates`, `_data` and _`mask`. + """ + desctype = [('_dates',int_), ('_series',series.dtype), ('_mask', bool_)] + flat = series.ravel() + _dates = numeric.asarray(flat._dates) + if flat.size > 0: + return recfromarrays([_dates, flat._data, getmaskarray(flat)], + dtype=desctype, + shape = (flat.size,), + ) + else: + return recfromarrays([[], [], []], dtype=desctype, + shape = (flat.size,), + ) +TimeSeries.asrecords = asrecords + +def flatten(series): + """Flattens a (multi-) time series to 1D series.""" + shp_ini = series.shape + # Already flat time series.... + if len(shp_ini) == 1: + return series + # Folded single time series .. + newdates = series._dates.ravel() + if series._dates.size == series._series.size: + newshape = (series._series.size,) + else: + newshape = (numeric.asarray(shp_ini[:-1]).prod(), shp_ini[-1]) + newseries = series._series.reshape(newshape) + return time_series(newseries, newdates) +TimeSeries.flatten = flatten + + + +#####--------------------------------------------------------------------------- +#---- --- Archiving --- +#####--------------------------------------------------------------------------- +def _tsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): + """Internal function that builds a new TimeSeries from the information stored +in a pickle.""" +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + _series = ndarray.__new__(ndarray, baseshape, basetype) + _dates = ndarray.__new__(datesclass, baseshape, int_) + _mask = ndarray.__new__(ndarray, baseshape, bool_) + return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, + dtype=basetype, fill_value=fill_value) # -#def _tssetstate(a, 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 -# - a binary string for the data -# - a binary string for the mask. -# """ -# (ver, shp, typ, isf, raw, dti) = state -# (a._series).__setstate__((shp, typ, isf, raw)) -# (a._dates).__setstate__((shp, N.dtype('|O8'), isf, dti)) -# (a._dates)._asstrings = None +def _tsgetstate(a): + "Returns the internal state of the TimeSeries, for pickling purposes." +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + records = a.asrecords() + state = (1, + a.shape, + a.dtype, + a.freq, + records.flags.fnc, + a.fill_value, + records + ) + return state +# +def _tssetstate(a, 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 + - a binary string for the data + - a binary string for the mask. + """ + (ver, shp, typ, frq, isf, flv, rec) = state + a.fill_value = flv + a._dates = a._dates.__class__(rec['_dates'], freq=frq) + (a._dates).__tostr = None + _data = rec['_series'].view(typ) + _mask = rec['_mask'].view(MA.MaskType) + a._series = masked_array(_data, mask=_mask) +# a._data.shape = shp +# a._dates.shape = shp +# a._mask = rec['_mask'].view(MA.MaskType) +# a._mask.shape = shp # -#def _tsreduce(a): -# """Returns a 3-tuple for pickling a MaskedArray.""" -# return (_tsreconstruct, -# (a.__class__, a._dates.__class__, (0,), 'b', ), -# a.__getstate__()) -# -#TimeSeries.__getstate__ = _tsgetstate -#TimeSeries.__setstate__ = _tssetstate -#TimeSeries.__reduce__ = _tsreduce +def _tsreduce(a): + """Returns a 3-tuple for pickling a MaskedArray.""" + return (_tsreconstruct, + (a.__class__, a.dates.__class__, (0,), 'b', -9999), + a.__getstate__()) +# +TimeSeries.__getstate__ = _tsgetstate +TimeSeries.__setstate__ = _tssetstate +TimeSeries.__reduce__ = _tsreduce #TimeSeries.__dump__ = dump #TimeSeries.__dumps__ = dumps -# -##................................................ -# -##### -------------------------------------------------------------------------- -##--- ... Shortcuts ... -##### -------------------------------------------------------------------------- -#def isTimeSeries(x): -# """Checks whether `x` is a time series (an instance of `TimeSeries` ).""" -# return isinstance(x, TimeSeries) -# -##### -------------------------------------------------------------------------- -##--- ... MaskedTimeSeries class ... -##### -------------------------------------------------------------------------- -#class MaskedTimeSeries(MaskedArray, TimeSeries): -# """Base class for the definition of time series. -#A time series is here defined as the combination of two arrays: -# -# - an array storing the time information (as a `TimeArray` instance); -# - an array storing the data (as a `MaskedArray` instance. -# """ -# def __new__(cls, data, dates=None, mask=nomask, -# dtype=None, copy=True, fill_value=-9999): -# mtslog.log(5, "__new__: data types %s, %s" % (type(data), dtype)) -## if isinstance(data, TimeSeries): -# #.................... -# if isinstance(data, TimeSeries): -# if isinstance(data, MaskedTimeSeries): -# _data = data._data -# else: -# _data = data -# _dates = data._dates -# _series = data._series -# mtslog.log(5, "__new__ from TS: data %i - %s - %s" % \ -# (id(_data._series), type(_data._series), _data.ravel())) -# mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ -# (id(_dates), type(_dates), _dates.ravel())) -# elif isinstance(data, recarray): -# assert(data.dtype.names == ('_dates', '_series', '_mask'), -# "Invalid fields names (got %s)" % (data.dtype.names,)) -# _dates = data['_dates'] -# _series = data['_series'] -# _mask = data['_mask'] -# else: -# if hasattr(data, "_data"): -# _data = TimeSeries(data._data, dates=dates, -# dtype=dtype, copy=copy) -# else: -# _data = TimeSeries(data, dates=dates, -# dtype=dtype, copy=copy) -# _dates = _data._dates -# _series = _data._series -# mtslog.log(5,"__new__ from scratch: data %i - %s - %s" % \ -# (id(_data._series), type(_data._series), _data.ravel())) -# mtslog.log(5,"__new__ from TS: dates %i - %s - %s" % \ -# (id(_dates), type(_dates), _dates.ravel())) -# #..................... -# if mask is nomask: -# if hasattr(data, "_mask"): -# _mask = data._mask -# else: -# _mask = nomask -# else: -# _mask = make_mask(mask, copy=copy, flag=True) -# #....Check shapes compatibility -# if _mask is not nomask: -# (nd, nm) = (_data.size, _mask.size) -# if (nm != nd): -# if nm == 1: -# _mask = N.resize(_mask, _data.shape) -# elif nd == 1: -# _data = N.resize(_data, _mask.shape) -# else: -# msg = "Mask and data not compatible (size issues: %i & %i)." -# raise MAError, msg % (nm, nd) -# elif (_mask.shape != _data.shape): -# mtslog.log(5,"__new__ from scratch: force _mask shape %s > %s" % \ -# (_mask.shape, _data.shape)) -# _mask.shape = _data.shape -# #.... -# cls._fill_value = fill_value -# cls._basemask = _mask -# cls._basedates = _dates -# cls._baseseries = _series -# return _data.view(cls) -## return _series.view(cls) -# #.............. -# def __array_wrap__(self, obj, context=None): -# """Special hook for ufuncs. -#Wraps the numpy array and sets the mask according to context. -# """ -## return MaskedArray.__array_wrap__(obj, context=None) -# return MaskedTimeSeries(obj, dates=self._dates, mask=self._mask, -# fill_value=self._fill_value) -# -# #.............. -# def __array_finalize__(self,obj): -# mtslog.log(5, "__array_finalize__: obj is %s" % (type(obj), )) -# if not hasattr(self, "_data"): -# self._data = obj -# if not hasattr(self, "_dates"): -# self._dates = self._basedates -# mtslog.log(5, "__array_finalize__: set dates to: %s - %s" % \ -# (id(self._dates), self._dates.ravel() )) -# if not hasattr(self, "_mask"): -# self._mask = self._basemask -# mtslog.log(5, "__array_finalize__: set mask to: %s - %s" % \ -# (id(self._mask), self._mask.ravel() )) -# if not hasattr(self, "_series"): -# if hasattr(obj, "_series"): -# self._series = obj._series -# else: -# self._series = obj -# self.fill_value = self._fill_value -# return -# #------------------------------------------------------ -# def __str__(self): -# """Calculate the str representation, using masked for fill if -# it is enabled. Otherwise fill with fill value. -# """ -# if masked_print_option.enabled(): -# f = masked_print_option -# # XXX: Without the following special case masked -# # XXX: would print as "[--]", not "--". Can we avoid -# # XXX: checks for masked by choosing a different value -# # XXX: for the masked singleton? 2005-01-05 -- sasha -# if self is masked: -# return str(f) -# m = self._mask -# if m is nomask: -# res = self._data -# else: -# if m.shape == () and m: -# return str(f) -# # convert to object array to make filled work -# res = (self._series).astype("|O8") -# res[self._mask] = f -# else: -# res = self.filled(self.fill_value) -# return str(res) -# #............................................ -# def ids (self): -# """Return the ids of the data, dates and mask areas""" -# return (id(self._series), id(self.dates), id(self._mask)) -# #............................................ -# @property -# def maskedseries(self): -# """Returns a masked array of the series (dates are omitteed).""" -# return masked_array(self._series, mask=self._mask) -# _mseries = maskedseries -# #............................................ -# def filled(self, fill_value=None): -# """A numeric array with masked values filled. If fill_value is None, -# use self.fill_value(). -# -# If mask is nomask, copy data only if not contiguous. -# Result is always a contiguous, numeric array. -## Is contiguous really necessary now? -# """ -# (d, m) = (self._data, self._mask) -# if m is nomask: -# return d -# # -# if fill_value is None: -# value = self._fill_value -# else: -# value = fill_value -# # -# if self is masked_singleton: -# return numeric.array(value) -# # -# result = d.copy() -# try: -# result.__setitem__(m, value) -# except (TypeError, AttributeError): -# #ok, can't put that value in here -# value = numeric.array(value, dtype=object) -# d = d.astype(object) -# result = fromnumeric.choose(m, (d, value)) -# except IndexError: -# #ok, if scalar -# if d.shape: -# raise -# elif m: -# result = numeric.array(value, dtype=d.dtype) -# else: -# result = d -# return result -# #............................................ -# #............................................ -# def asrecords(self): -# """Returns the masked time series as a recarray. -#Fields are `_dates`, `_data` and _`mask`. -# """ -# desctype = [('_dates','|O8'), ('_series',self.dtype), ('_mask',N.bool_)] -# flat = self.ravel() -# if flat.size > 0: -# return recfromarrays([flat._dates, flat._series, getmaskarray(flat)], -# dtype=desctype, -# shape = (flat.size,), -# ) -# else: -# return recfromarrays([[], [], []], dtype=desctype, -# shape = (flat.size,), -# ) -# -# -## def reshape (self, *s): -## """This array reshaped to shape s""" -## self._data = self._data.reshape(*s) -## self._dates = self._dates.reshape(*s) -## if self._mask is not nomask: -## self._mask = self._mask.reshape(*s) -## return self.view() -##### -------------------------------------------------------------------------- -##--- ... Pickling ... -##### -------------------------------------------------------------------------- -#def _mtsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): -# """Internal function that builds a new MaskedArray from the information stored -#in a pickle.""" -## raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" -# _series = ndarray.__new__(ndarray, baseshape, basetype) -# _dates = ndarray.__new__(datesclass, baseshape, '|O8') -# _mask = ndarray.__new__(ndarray, baseshape, '|O8') -# return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, -# dtype=basetype, fill_value=fill_value) -## -#def _mtsgetstate(a): -# "Returns the internal state of the TimeSeries, for pickling purposes." -## raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" -# records = a.asrecords() -# state = (1, -# a.shape, -# a.dtype, -# records.flags.fnc, -# a.fill_value, -# records -# ) -# return state -## -#def _mtssetstate(a, 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 -# - a binary string for the data -# - a binary string for the mask. -# """ -# (ver, shp, typ, isf, flv, rec) = state -# a.fill_value = flv -# a._data._series = a._series = N.asarray(rec['_series']) -# a._data._series.shape = a._series.shape = shp -# a._data._dates = a._dates = a._dates.__class__(rec['_dates']) -# a._data._dates.shape = a._dates.shape = shp -# (a._dates)._asstrings = None -# a._mask = N.array(rec['_mask'], dtype=MA.MaskType) -# a._mask.shape = shp -## -#def _mtsreduce(a): -# """Returns a 3-tuple for pickling a MaskedArray.""" -# return (_mtsreconstruct, -# (a.__class__, a.dates.__class__, (0,), 'b', -9999), -# a.__getstate__()) -## -#MaskedTimeSeries.__getstate__ = _mtsgetstate -#MaskedTimeSeries.__setstate__ = _mtssetstate -#MaskedTimeSeries.__reduce__ = _mtsreduce -#MaskedTimeSeries.__dump__ = dump -#MaskedTimeSeries.__dumps__ = dumps - - ##### ------------------------------------------------------------------------- #---- --- TimeSeries creator --- ##### ------------------------------------------------------------------------- @@ -1057,10 +861,7 @@ Array of data. """ if dates is None: - if numeric.ndim(data) >= 2: - length = numeric.asarray(numeric.shape(data))[1:].prod() - else: - length = numeric.size(data) + length = _getdatalength(data) dates = date_array(start_date=start_date, end_date=end_date, length=length, include_last=include_last, freq=freq) elif not isinstance(dates, DateArray): @@ -1078,82 +879,6 @@ ##### -------------------------------------------------------------------------- ##--- ... Additional functions ... ##### -------------------------------------------------------------------------- -#def check_dates(a,b): -# """Returns the array of dates from the two objects `a` or `b` (or None).""" -# if isTimeSeries(a): -# if isTimeSeries(b) and (a._dates == b._dates).all() is False: -# raise ValueError, "Incompatible dates !" -# return a._dates -# elif isTimeSeries(b): -# return b._dates -# else: -# return -# -#def parse_period(period): -# """Returns a TimeArray couple (starting date; ending date) from the arguments.""" -##### print "........DEBUG PARSE DATES: period %s is %s" % (period, type(period)) -## if isinstance(period,TimeArray) or isinstance(period,Dates): -##### print "........DEBUG PARSE_PERIOD: OK" -# if isinstance(period,TimeArray): -# return (period[0],period[-1]) -# elif hasattr(period,"__len__"): -# if not isinstance(period[0], TimeArray): -# tstart = TimeArray(period[0]) -# else: -# tstart = period[0] -# if not isinstance(period[-1], TimeArray): -# tend = TimeArray(period[-1]) -# else: -# tend = period[-1] -# return (tstart, tend) -# else: -# p = N.asarray(period) -# if N.all(p < 9999): -# p = N.array(period,dtype="|S4") -# p = time_array(p) -# return (p[0], p[-1]) -# -#def where_period(period, dates, *choices): -# """Returns choices fro True/False, whether dates fall during a given period. -#If no choices are given, outputs the array indices for the dates falling in the -#period. -# -#:Parameters: -# `period` : Sequence -# Selection period, as a sequence (starting date, ending date). -# `dates` : TimeArray -# Array of dates. -# `choices` : *(optional)* -# Arrays to select from when the condition is True/False. -# """ -# (tstart, tend) = parse_period(period) -# condition = ascondition((dates>=tstart)&(dates<=tend)) -# condition = (dates>=tstart)&(dates<=tend) -# return N.where(condition, *choices) -# -#def masked_inside_period(data, period, dates=None): -# """Returns x as an array masked where dates fall inside the selection period, -#as well as where data are initially missing (masked).""" -# (tstart, tend) = parse_period(period) -# # Get dates .................. -# if hasattr(data, "_dates"): -# dates = data._dates -# elif dates is None: -# raise ValueError,"Undefined dates !" -# else: -# assert(N.size(dates)==N.size(data), -# "Inconsistent data and dates sizes!") -# # where_period yields True inside the period, when mask should yield False -# condition = ascondition(N.logical_and((dates>=tstart), (dates<=tend))) -# cm = filled(condition,True).reshape(data.shape) -# mask = mask_or(MA.getmaskarray(data), cm, copy=True) -# if isinstance(data, MaskedTimeSeries): -# return data.__class__(data._data, dates=dates, mask=mask, copy=True) -# if isinstance(data, TimeSeries): -# return MaskedTimeSeries(data, dates=dates, mask=mask, copy=True) -# else: -# return masked_array(data, mask=mask, copy=True) -# def mask_period(data, start_date=None, end_date=None, inside=True, include_edges=True, inplace=True): """Returns x as an array masked where dates fall outside the selection period, @@ -1223,7 +948,7 @@ """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) - +#.......................................................... 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, @@ -1238,6 +963,9 @@ if not a.dates.isvalid(): raise TimeSeriesError, \ "Cannot adjust a series with missing or duplicated dates." + # Flatten the series if needed .............. + a = a.flatten() + shp_flat = a.shape # Dates validity checks .,................... msg = "%s should be a valid Date instance! (got %s instead)" (dstart, dend) = a.dates[[0,-1]] @@ -1248,7 +976,7 @@ if not isDateType(start_date): raise TypeError, msg % ('start_date', type(start_date)) start_lag = start_date - dstart - + #.... if end_date is None: end_date = dend end_lag = 0 @@ -1256,14 +984,15 @@ if not isDateType(end_date): raise TypeError, msg % ('end_date', type(end_date)) end_lag = end_date - dend + # Check if the new range is included in the old one if start_lag >= 0: if end_lag == 0: return a[start_lag:] elif end_lag < 0: return a[start_lag:end_lag] - + # Create a new series ....................... newdates = date_array(start_date=start_date, end_date=end_date) - newshape = list(a.shape) + newshape = list(shp_flat) newshape[0] = len(newdates) newshape = tuple(newshape) @@ -1273,8 +1002,7 @@ end_date = min(end_date, dend) + 1 newseries[start_date:end_date] = a[start_date:end_date] return newseries - - +#.......................................................... 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. @@ -1286,8 +1014,7 @@ dates respectively. """ if len(series) < 2: - return series - + return series unique_freqs = numpy.unique([x.freq for x in series]) try: common_freq = unique_freqs.item() @@ -1365,23 +1092,16 @@ tempData = masked_array(_values, mask=_mask) - if tempData.ndim == 2: -# tempData = tempData.T - if func is not None: - tempData = MA.apply_along_axis(func, 1, tempData) - else: - tempData = tempData.T - - #startIndex = cseries.convert(start_date, fromFreq, toFreq) + if tempData.ndim == 2 and func is not None: + tempData = MA.apply_along_axis(func, -1, tempData) + newStart = series._dates[0].asfreq(toFreq, "BEFORE") newEnd = series._dates[-1].asfreq(toFreq, "AFTER") newseries = TimeSeries(tempData, freq=toFreq, observed=series.observed, start_date=newStart) - return newseries -# return adjust_endpoints(newseries, end_date=newEnd) -# return (tempData, newStart, toFreq, newseries, _values, _mask) + return adjust_endpoints(newseries, end_date=newEnd) def fill_missing_dates(data, dates=None, freq=None,fill_value=None): @@ -1457,14 +1177,7 @@ return time_series(newdata.reshape(nshp), newdates) -#######-------------------------------------------------------------------------- -###---- --- Archiving --- -#######-------------------------------------------------------------------------- - - - - if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) from maskedarray.testutils import assert_equal @@ -1498,9 +1211,25 @@ data = masked_array(numeric.arange(15)-6, mask=[1,0,0,0,0]*3) print "."*50+"\nseries" tseries = time_series(data, dlist) - + if 1: - mser3 = time_series(MA.mr_[malg1._series, malg2._series].reshape(2,-1), + dlist_1 = ['2007-01-%02i' % i for i in range(1,8)] + dlist_2 = ['2007-01-%02i' % i for i in numpy.arange(1,28)[::4]] + data = masked_array(numeric.arange(7), mask=[1,0,0,0,0,0,0]) + tseries_1 = time_series(data, dlist_1) + tseries_2 = time_series(data, dlist_2) + tseries_3 = time_series(data[::-1], dlist_2) + + try: + tseries = tseries_1 + tseries_2 + except TimeSeriesCompatibilityError: + print "I knew it!" + tseries = tseries_2 + tseries_3 + assert_equal(tseries._dates, tseries_3._dates) + assert_equal(tseries._mask, [1,0,0,0,0,0,1]) + + if 1: + mser3 = time_series(MA.mr_[malg1._series, malg2._series].reshape(-1,2), dates=malg1.dates) From scipy-svn at scipy.org Wed Jan 3 15:26:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 3 Jan 2007 14:26:32 -0600 (CST) Subject: [Scipy-svn] r2482 - trunk/Lib/sandbox/timeseries/mtimeseries Message-ID: <20070103202632.858E639C00C@new.scipy.org> Author: pierregm Date: 2007-01-03 14:26:24 -0600 (Wed, 03 Jan 2007) New Revision: 2482 Modified: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py Log: cf changelog Modified: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-03 08:12:10 UTC (rev 2481) +++ trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-03 20:26:24 UTC (rev 2482) @@ -3,4 +3,5 @@ # : - Put the estimation of the data length in its own function. # : - Added a timestep compatibility check. # : - The variables in a multi-series correspond now to the last axis. -# : - Blocked transpose/swapaxes, temporarily. \ No newline at end of file +# : - Blocked transpose/swapaxes, temporarily. +# : - Speed-up fill_missing_dates \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-03 08:12:10 UTC (rev 2481) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-03 20:26:24 UTC (rev 2482) @@ -24,7 +24,7 @@ import tscore as corelib #reload(corelib) -from tscore import isDateType +#from tscore import isDateType #from corelib import fmtFreq, freqToType import mx.DateTime as mxD @@ -412,7 +412,8 @@ else: before = False - if not isDateType(date): +# if not isDateType(date): + if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" if date.freq == toFreq: @@ -628,7 +629,7 @@ def __getitem__(self, index): #dalog.info("__getitem__ got index %s (%s)"%(index, type(index))) - if isDateType(index): + if isinstance(index, Date): index = self.find_dates(index) elif numeric.asarray(index).dtype.kind == 'O': try: @@ -762,8 +763,9 @@ if self.freq == 'U': warnings.warn("Undefined frequency: assuming daily!") if self.__steps is None: - steps = numeric.asarray(numpy.diff(self)) - if steps.size > 0: + val = numeric.asarray(self).ravel() + if val.size > 0: + steps = val[1:] - val[:-1] if self.__full is None: self.__full = (steps.max() == 1) if self.__hasdups is None: @@ -831,7 +833,7 @@ raise FrequencyDateError("Cannot operate on dates", \ freq, other.freq) # other = - elif isDateType(other): + elif isinstance(other, Date): if other.freq != freq: raise FrequencyDateError("Cannot operate on dates", \ freq, other.freq) @@ -923,7 +925,7 @@ elif dlist.dtype.kind == 'O': template = dlist[0] #...as Date objects - if isDateType(template): + if isinstance(template, Date): dates = numpy.fromiter((d.value for d in dlist), float_) #...as mx.DateTime objects elif hasattr(template,'absdays'): @@ -963,15 +965,18 @@ # Case #2: we have a starting date .......... if start_date is None: raise InsufficientDateError - if not isDateType(start_date): +# if not isDateType(start_date): + if not isinstance(start_date, Date): raise DateError, "Starting date should be a valid Date instance!" # Check if we have an end_date if end_date is None: if length is None: raise ValueError,"No length precised!" else: - assert(isDateType(end_date), - "Starting date should be a valid Date instance!") + if not isinstance(end_date, Date): + raise DateError, "Ending date should be a valid Date instance!" +# assert(isDateType(end_date), +# "Starting date should be a valid Date instance!") length = end_date - start_date if include_last: length += 1 Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-03 08:12:10 UTC (rev 2481) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-03 20:26:24 UTC (rev 2482) @@ -877,7 +877,7 @@ return isinstance(series, TimeSeries) ##### -------------------------------------------------------------------------- -##--- ... Additional functions ... +#---- ... Additional functions ... ##### -------------------------------------------------------------------------- def mask_period(data, start_date=None, end_date=None, inside=True, include_edges=True, inplace=True): @@ -1102,8 +1102,8 @@ observed=series.observed, start_date=newStart) return adjust_endpoints(newseries, end_date=newEnd) +TimeSeries.convert = convert - 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 @@ -1127,11 +1127,20 @@ if not isTimeSeries(data): raise InsufficientDateError dates = data._dates - data = data._series freq = dates.freq + datad = data._series._data + datam = data._series._mask +# if fill_value is None: +# fill_value = data._fill_value elif not isinstance(dates, DateArray): dates = DateArray(dates, freq) - dflat = dates.ravel().asfreq(freq) + if isinstance(data, MaskedArray): + datad = data._data + datam = data._mask + else: + datad = data + datam = nomask + dflat = dates.asfreq(freq).ravel() n = len(dflat) if not dflat.has_missing_dates(): return time_series(data, dflat) @@ -1153,22 +1162,31 @@ ] #............................. # Just a quick check + vdflat = numeric.asarray(dflat) + vnewdates = numeric.asarray(newdates) for (osl,nsl) in zip(oldslc,newslc): - assert numpy.equal(dflat[osl],newdates[nsl]).all(),\ + assert numpy.equal(vdflat[osl],vnewdates[nsl]).all(),\ "Slicing mishap ! Please check %s (old) and %s (new)" % (osl,nsl) #............................. data = MA.asarray(data) - newdata = MA.masked_array(numeric.empty(nsize, data.dtype), - mask=numeric.ones(nsize, bool_)) - if fill_value is None: - if hasattr(data,'fill_value'): - fill_value = data.fill_value - else: - fill_value = MA.default_fill_value(data) + newdatad = numeric.empty(nsize, data.dtype) + newdatam = numeric.ones(nsize, bool_) +# if fill_value is None: +# if hasattr(data,'fill_value'): +# fill_value = data.fill_value +# else: +# fill_value = MA.default_fill_value(data) #data = data.filled(fill_value) #.... - for (new,old) in zip(newslc,oldslc): - newdata[new] = data[old] + if datam is nomask: + for (new,old) in zip(newslc,oldslc): + newdatad[new] = datad[old] + newdatam[new] = False + else: + 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) # Get new shape .............. if data.ndim == 1: nshp = (newdates.size,) @@ -1229,7 +1247,7 @@ assert_equal(tseries._mask, [1,0,0,0,0,0,1]) if 1: - mser3 = time_series(MA.mr_[malg1._series, malg2._series].reshape(-1,2), + mser3 = time_series(MA.mr_[malg1._series, 100+malg2._series].reshape(2,-1).T, dates=malg1.dates) - + data = mser3._series._data From scipy-svn at scipy.org Wed Jan 3 16:31:21 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 3 Jan 2007 15:31:21 -0600 (CST) Subject: [Scipy-svn] r2483 - trunk/Lib/sandbox/maskedarray Message-ID: <20070103213121.90EE839C065@new.scipy.org> Author: pierregm Date: 2007-01-03 15:31:12 -0600 (Wed, 03 Jan 2007) New Revision: 2483 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/extras.py Log: cf changelog Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-03 20:26:24 UTC (rev 2482) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-03 21:31:12 UTC (rev 2483) @@ -1,3 +1,7 @@ +#2007-01-02 : Extras +# : - Made sure that apply_along_axis output the proper fill_value +# : Core +# : - Can use dtypes for the definition of default_fill_value #2006-12-30 : Core # : - Cleaned up setitem/setslice w/ hard_mask=True # : - Fixed masked_unary/binary_operations to work with subclasses of MaskedArray Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-01-03 20:26:24 UTC (rev 2482) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-03 21:31:12 UTC (rev 2483) @@ -163,6 +163,8 @@ return default_filler['S'] elif isinstance(obj, complex): return default_filler['c'] + elif isinstance(obj, numeric.dtype): + return default_filler[obj.kind] else: return default_filler['O'] Modified: trunk/Lib/sandbox/maskedarray/extras.py =================================================================== --- trunk/Lib/sandbox/maskedarray/extras.py 2007-01-03 20:26:24 UTC (rev 2482) +++ trunk/Lib/sandbox/maskedarray/extras.py 2007-01-03 21:31:12 UTC (rev 2483) @@ -231,12 +231,14 @@ outarr[tuple(i.tolist())] = res dtypes.append(asarray(res).dtype) k += 1 + max_dtypes = numeric.dtype(numeric.asarray(dtypes).max()) if not hasattr(arr, '_mask'): - return numeric.asarray(outarr, dtype=max(dtypes)) + result = numeric.asarray(outarr, dtype=max_dtypes) else: - return outarr.astype(max(dtypes)) + result = core.asarray(outarr, dtype=max_dtypes) + result.fill_value = core.default_fill_value(result) + return result - def average (a, axis=None, weights=None, returned = 0): """average(a, axis=None weights=None, returned=False) From scipy-svn at scipy.org Thu Jan 4 01:03:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 4 Jan 2007 00:03:15 -0600 (CST) Subject: [Scipy-svn] r2484 - trunk/Lib/linsolve Message-ID: <20070104060315.3FA8939C1C0@new.scipy.org> Author: timl Date: 2007-01-04 00:03:07 -0600 (Thu, 04 Jan 2007) New Revision: 2484 Modified: trunk/Lib/linsolve/linsolve.py Log: update docstring Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-01-03 21:31:12 UTC (rev 2483) +++ trunk/Lib/linsolve/linsolve.py 2007-01-04 06:03:07 UTC (rev 2484) @@ -87,8 +87,12 @@ def splu(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): """ - A linear solver, for a square matrix A, using LU decomposition where + A linear solver, for a sparse, square matrix A, using LU decomposition where L is a lower triangular matrix and U is an upper triagular matrix. + + Returns a factored_lu object. (scipy.linsolve._superly.SciPyLUType) + + See scipy.linsolve._superlu.dgstrf for more info. """ M, N = A.shape if (M != N): From scipy-svn at scipy.org Thu Jan 4 11:02:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 4 Jan 2007 10:02:22 -0600 (CST) Subject: [Scipy-svn] r2485 - trunk/Lib/sandbox/timeseries Message-ID: <20070104160222.895C839C040@new.scipy.org> Author: mattknox_ca Date: 2007-01-04 10:02:18 -0600 (Thu, 04 Jan 2007) New Revision: 2485 Modified: trunk/Lib/sandbox/timeseries/tsdate.py Log: fixed bug with modifying value parameter passed in Modified: trunk/Lib/sandbox/timeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/tsdate.py 2007-01-04 06:03:07 UTC (rev 2484) +++ trunk/Lib/sandbox/timeseries/tsdate.py 2007-01-04 16:02:18 UTC (rev 2485) @@ -14,7 +14,7 @@ if self.freq == 'D': self.mxDate = mx.DateTime.DateTimeFromAbsDays(value-1) elif self.freq == 'B': - value -= 1 + value = value - 1 self.mxDate = mx.DateTime.DateTimeFromAbsDays(value + (value//5)*7 - (value//5)*5) elif self.freq == 'S': self.mxDate = secondlyOriginDate + mx.DateTime.DateTimeDeltaFromSeconds(value) @@ -60,7 +60,6 @@ self.mxDate = mx.DateTime.Date(year, month, day, _hours, _minutes, _seconds) self.value = self.__value() - def day(self): return self.mxDate.day def day_of_week(self): return self.mxDate.day_of_week From scipy-svn at scipy.org Thu Jan 4 11:08:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 4 Jan 2007 10:08:16 -0600 (CST) Subject: [Scipy-svn] r2486 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070104160816.2926439C040@new.scipy.org> Author: mattknox_ca Date: 2007-01-04 10:08:13 -0600 (Thu, 04 Jan 2007) New Revision: 2486 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: revamped convert function so that it can act on an array of dates. Also, renamed some functions Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-04 16:02:18 UTC (rev 2485) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-04 16:08:13 UTC (rev 2486) @@ -193,19 +193,101 @@ } +/* +convert fromDate to a date at toFreq according to relation +*/ static long -convert(long fromDate, char fromFreq, char toFreq, int notStartInd) +asfreq(long fromDate, char fromFreq, char toFreq, char relation) { long absdate, secsInDay; long converted; - int y,m; + int y,m, doAfter; mxDateTimeObject *convDate; secsInDay = 86400; + doAfter = 0; - absdate = toDaily(fromDate, fromFreq); + if (relation == 'A') { + switch(fromFreq) + { + case 'D': //daily + + switch(toFreq) + { + case 'A': + break; + case 'Q': + break; + case 'M': + break; + case 'B': + break; + default: + doAfter = 1; + break; + } + break; + + case 'B': //business + + switch(toFreq) + { + case 'A': + break; + case 'Q': + break; + case 'M': + break; + case 'D': + break; + default: + doAfter = 1; + break; + } + break; + + case 'M': //monthly + + switch(toFreq) + { + case 'A': + break; + case 'Q': + break; + default: + doAfter = 1; + break; + } + break; + + case 'Q': //quarterly + + switch(toFreq) + { + case 'A': + break; + default: + doAfter = 1; + break; + } + break; + + case 'A': //annual + doAfter = 1; + break; + + } + + } + + if (doAfter) { + absdate = toDaily(fromDate + 1, fromFreq); + } else { + absdate = toDaily(fromDate, fromFreq); + } + convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(absdate,0); y = convDate->year; @@ -220,27 +302,16 @@ case 'B': if (convDate->day_of_week > 4) //is weekend day { - if (notStartInd == 1 && freqVal(fromFreq) > 4) - { - return -1; + if (fromFreq == 'D' && relation == 'B') { + //change to friday before weekend + absdate -= (convDate->day_of_week - 4); + } else { + //change to Monday after weekend + absdate += (7 - convDate->day_of_week); } - else - { - if (convDate->day - (convDate->day_of_week - 4) < 1) { - //change to Monday after weekend - absdate += (7 - convDate->day_of_week); - } else { - //change to friday before weekend - absdate -= (convDate->day_of_week - 4); - } - - converted = (long)((absdate / 7 * 5.0) + absdate%7); - } } - else - { - converted = (long)((absdate / 7 * 5.0) + absdate%7); - } + //converted = (long)((absdate / 7 * 5.0) + absdate%7); + converted = (long)((absdate / 7 * 5.0) + absdate%7); break; case 'M': converted = (long)(y*12 + m); @@ -255,9 +326,35 @@ return -1; } - return converted; + if (doAfter) { + return converted-1; + } else { + return converted; + } } + +/* +for use internally by the convert function. Same as the asfreq function, +except going from daily to business returns -1 always if fromDate is on +a weekend +*/ +static long +asfreq_forseries(long fromDate, char fromFreq, char toFreq, char relation) +{ + mxDateTimeObject *convDate; + + if (fromFreq == 'D' && toFreq == 'B') { + convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate,0); + if (convDate->day_of_week > 4) //is weekend day + { + return -1; + } + } + + return asfreq(fromDate, fromFreq, toFreq, relation); +} + static int validFreq(char freq) { switch(freq) { @@ -426,9 +523,9 @@ } -static char cseries_reindex_doc[] = ""; +static char cseries_convert_doc[] = ""; static PyObject * -cseries_reindex(PyObject *self, PyObject *args) +cseries_convert(PyObject *self, PyObject *args) { PyArrayObject *array; PyArrayObject *tempArray; @@ -440,7 +537,6 @@ PyObject *returnVal = NULL; - int notStartInd; long startIndex, newStart, newStartYaxis; long newLen, newHeight; long i, currIndex, prevIndex; @@ -448,6 +544,7 @@ long *dim; long currPerLen; char *fromFreq, *toFreq, *position; + char relation; PyObject *val, *valMask; @@ -455,7 +552,7 @@ returnVal = PyDict_New(); - if (!PyArg_ParseTuple(args, "OssslO:reindex(array, fromfreq, tofreq, position, startIndex, mask)", &tempArray, &fromFreq, &toFreq, &position, &startIndex, &tempMask)) return NULL; + if (!PyArg_ParseTuple(args, "OssslO:convert(array, fromfreq, tofreq, position, startIndex, mask)", &tempArray, &fromFreq, &toFreq, &position, &startIndex, &tempMask)) return NULL; if (toFreq[0] == fromFreq[0]) { @@ -466,6 +563,21 @@ return returnVal; } + switch(position[0]) + { + case 'S': + // start -> before + relation = 'B'; + break; + case 'E': + // end -> after + relation = 'A'; + break; + default: + return NULL; + break; + } + //get frequency numeric mapping fromFrVal = freqVal(fromFreq[0]); toFrVal = freqVal(toFreq[0]); @@ -477,12 +589,11 @@ if (!expand(array->dimensions[0], fromFreq[0], toFreq[0], &newLen, &newHeight)) return NULL; //convert start index to new frequency - notStartInd = 0; - newStart = convert(startIndex, fromFreq[0], toFreq[0], notStartInd); + newStart = asfreq(startIndex, fromFreq[0], toFreq[0], 'B'); if (newHeight > 1) { - newStartYaxis = startIndex - convert(newStart, toFreq[0], fromFreq[0], notStartInd); + newStartYaxis = startIndex - asfreq(newStart, toFreq[0], fromFreq[0], 'B'); currPerLen = newStartYaxis; nd = 2; @@ -507,8 +618,6 @@ //initialize prevIndex prevIndex = newStart; - notStartInd = 1; - //set values in the new array for (i = 0; i < array->dimensions[0]; i++) { @@ -520,12 +629,9 @@ valMask = PyArray_GETITEM(mask, PyArray_GetPtr(mask, &i)); //find index for start of current period in new frequency - if (newHeight == 1 && (position[0] == 'E' && !((fromFrVal == 4 && toFrVal == 5) || (fromFrVal == 5 && toFrVal == 4))) ) { - currIndex = convert(startIndex + i + 1, fromFreq[0], toFreq[0], notStartInd)-1; - } else { - currIndex = convert(startIndex + i, fromFreq[0], toFreq[0], notStartInd); - } + currIndex = asfreq_forseries(startIndex + i, fromFreq[0], toFreq[0], relation); + if (newHeight > 1) { if (currIndex != prevIndex) @@ -558,29 +664,49 @@ } -static char cseries_convert_doc[] = ""; +static char cseries_asfreq_doc[] = ""; static PyObject * -cseries_convert(PyObject *self, PyObject *args) +cseries_asfreq(PyObject *self, PyObject *args) { - long fromDate; - char* fromFreq; - char* toFreq; - int notStartInd; + PyArrayObject *fromDates, *toDates; + PyArrayIterObject *iterFrom, *iterTo; + PyObject *fromDateObj, *toDateObj; + char *fromFreq, *toFreq, *relation; + long fromDate, toDate; - if (!PyArg_ParseTuple(args, "lss:convert(fromDate, fromfreq, tofreq)", &fromDate, &fromFreq, &toFreq)) return NULL; + if (!PyArg_ParseTuple(args, "Osss:asfreq(fromDates, fromfreq, tofreq, relation)", &fromDates, &fromFreq, &toFreq, &relation)) return NULL; - //always want start of period (only matters when converting from lower freq to higher freq ie. m -> d) - notStartInd = 0; + toDates = (PyArrayObject *)PyArray_Copy(fromDates); - return PyInt_FromLong(convert(fromDate, fromFreq[0], toFreq[0], notStartInd)); + iterFrom = (PyArrayIterObject *)PyArray_IterNew((PyObject *)fromDates); + if (iterFrom == NULL) return NULL; + + iterTo = (PyArrayIterObject *)PyArray_IterNew((PyObject *)toDates); + if (iterTo == NULL) return NULL; + + while (iterFrom->index < iterFrom->size) { + + fromDateObj = PyArray_GETITEM(fromDates, iterFrom->dataptr); + fromDate = PyInt_AsLong(fromDateObj); + toDate = asfreq(fromDate, fromFreq[0], toFreq[0], relation[0]); + toDateObj = PyInt_FromLong(toDate); + + PyArray_SETITEM(toDates, iterTo->dataptr, toDateObj); + + PyArray_ITER_NEXT(iterFrom); + PyArray_ITER_NEXT(iterTo); + } + + return (PyObject *)toDates; + } /////////////////////////////////////////////////////////////////////// static PyMethodDef cseries_methods[] = { - {"reindex", cseries_reindex, METH_VARARGS, cseries_reindex_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} }; From scipy-svn at scipy.org Thu Jan 4 11:09:56 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 4 Jan 2007 10:09:56 -0600 (CST) Subject: [Scipy-svn] r2487 - trunk/Lib/sandbox/timeseries Message-ID: <20070104160956.D417C39C085@new.scipy.org> Author: mattknox_ca Date: 2007-01-04 10:09:52 -0600 (Thu, 04 Jan 2007) New Revision: 2487 Modified: trunk/Lib/sandbox/timeseries/timeseries.py Log: modified convert method to use updated c code Modified: trunk/Lib/sandbox/timeseries/timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-04 16:08:13 UTC (rev 2486) +++ trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-04 16:09:52 UTC (rev 2487) @@ -190,7 +190,6 @@ if self.size == 0: return TimeSeries(self, freq=toFreq, start_date=tsdate.dateOf(self.start_date(), toFreq)) - tempData = self.filled() if self.mask is ma.nomask: @@ -198,7 +197,7 @@ tempMask[:] = False else: tempMask = self.mask - cRetVal = cseries.reindex(tempData, fromFreq, toFreq, position, int(self.start_date()), tempMask) + cRetVal = cseries.convert(tempData, fromFreq, toFreq, position, int(self.start_date()), tempMask) _values = cRetVal['values'] _mask = cRetVal['mask'] @@ -210,11 +209,12 @@ if func is not None and tempData.ndim == 2: tempData = corelib.apply_along_axis(func, 1, tempData) - startIndex = cseries.convert(int(self.start_date()), fromFreq, toFreq) - - newStart = tsdate.dateOf(self.start_date(),toFreq, "BEFORE") - newEnd = tsdate.dateOf(self.end_date(),toFreq, "AFTER") + startIndex = cseries.asfreq(numpy.asarray(int(self.start_date())), fromFreq, toFreq, 'BEFORE') + newStart = tsdate.Date(freq=toFreq, value=startIndex) + endIndex = cseries.asfreq(numpy.asarray(int(self.end_date())), fromFreq, toFreq, 'AFTER') + newEnd = tsdate.Date(freq=toFreq, value=endIndex) + return adjust_endpoints(TimeSeries(tempData, freq=toFreq, observed=self.observed, start_date=startIndex), start_date=newStart, end_date=newEnd) else: From scipy-svn at scipy.org Thu Jan 4 11:42:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 4 Jan 2007 10:42:33 -0600 (CST) Subject: [Scipy-svn] r2488 - trunk/Lib/sandbox/timeseries/mtimeseries Message-ID: <20070104164233.8FD5939C09E@new.scipy.org> Author: pierregm Date: 2007-01-04 10:42:30 -0600 (Thu, 04 Jan 2007) New Revision: 2488 Modified: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py Log: Modified: trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-04 16:09:52 UTC (rev 2487) +++ trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-04 16:42:30 UTC (rev 2488) @@ -1,3 +1,5 @@ +#2007-01-04 : tsdate +# : - Corrected a bug w/ Date.__init__ and 'B' freq #2007-01-03 : tseries # : - Allowed endpoints adjustment after convert # : - Put the estimation of the data length in its own function. Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-04 16:09:52 UTC (rev 2487) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tsdate.py 2007-01-04 16:42:30 UTC (rev 2488) @@ -123,7 +123,7 @@ if self.freq == 'A': self.mxDate = mxD.Date(value, -1, -1) elif self.freq == 'B': - value -= 1 + value = value - 1 self.mxDate = mxD.DateTimeFromAbsDays(value + (value//5)*7 - (value//5)*5) elif self.freq in ['D','U']: self.mxDate = mxD.DateTimeFromAbsDays(value-1) @@ -744,6 +744,17 @@ if fromnumeric.size(c) == 0: raise ValueError, "Date out of bounds!" return c +# def find_dates_alt(self, *dates): +# "Returns the indices corresponding to given dates, as an array." +# ifreq = self.freq +# c = numpy.zeros(self.shape, bool_) +# dates = date_array([d for d in corelib.flatargs(*dates)]).asfreq(ifreq) +# for d in numeric.asarray(dates): +# c += (self == d) +# c = c.nonzero() +# if fromnumeric.size(c) == 0: +# raise ValueError, "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(): Modified: trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-04 16:09:52 UTC (rev 2487) +++ trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-04 16:42:30 UTC (rev 2488) @@ -1002,7 +1002,7 @@ end_date = min(end_date, dend) + 1 newseries[start_date:end_date] = a[start_date:end_date] return newseries -#.......................................................... +#.................................................................... 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. @@ -1038,8 +1038,7 @@ return [adjust_endpoints(x, start_date, end_date) for x in series] aligned = align_series - - +#.................................................................... def convert(series, freq, func='auto', position='END', interp=None): """Converts a series to a frequency @@ -1103,7 +1102,7 @@ start_date=newStart) return adjust_endpoints(newseries, end_date=newEnd) TimeSeries.convert = convert - +#.................................................................... 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 @@ -1120,9 +1119,9 @@ Default value for missing data. If None, the data are just masked. """ freq = corelib.fmtFreq(freq) -# if freq == 'U': -# raise ValueError,\ -# "Unable to define a proper date resolution (found %s)." % freq + if freq == 'U': + raise ValueError,\ + "Unable to define a proper date resolution (found %s)." % freq if dates is None: if not isTimeSeries(data): raise InsufficientDateError @@ -1150,7 +1149,7 @@ newdates = date_array(start_date=tstart, end_date=tend, include_last=True) nsize = newdates.size #............................. - # Get the steps between consecutive data. We need relativedelta to deal w/ months + # Get the steps between consecutive data. delta = dflat.get_steps()-1 gap = delta.nonzero() slcid = numpy.r_[[0,], numpy.arange(1,n)[gap], [n,]] From scipy-svn at scipy.org Fri Jan 5 09:09:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 5 Jan 2007 08:09:23 -0600 (CST) Subject: [Scipy-svn] r2489 - trunk/Lib/sandbox/timeseries Message-ID: <20070105140923.3AD4039C122@new.scipy.org> Author: mattknox_ca Date: 2007-01-05 08:09:19 -0600 (Fri, 05 Jan 2007) New Revision: 2489 Added: trunk/Lib/sandbox/timeseries/old/ Log: Created folder remotely From scipy-svn at scipy.org Fri Jan 5 09:09:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 5 Jan 2007 08:09:38 -0600 (CST) Subject: [Scipy-svn] r2490 - in trunk/Lib/sandbox/timeseries: . old Message-ID: <20070105140938.4D98439C17F@new.scipy.org> Author: mattknox_ca Date: 2007-01-05 08:09:36 -0600 (Fri, 05 Jan 2007) New Revision: 2490 Added: trunk/Lib/sandbox/timeseries/old/shiftingarray.py Removed: trunk/Lib/sandbox/timeseries/shiftingarray.py Log: Moved remotely Copied: trunk/Lib/sandbox/timeseries/old/shiftingarray.py (from rev 2489, trunk/Lib/sandbox/timeseries/shiftingarray.py) Deleted: trunk/Lib/sandbox/timeseries/shiftingarray.py =================================================================== --- trunk/Lib/sandbox/timeseries/shiftingarray.py 2007-01-05 14:09:19 UTC (rev 2489) +++ trunk/Lib/sandbox/timeseries/shiftingarray.py 2007-01-05 14:09:36 UTC (rev 2490) @@ -1,290 +0,0 @@ -import numpy, types , corelib -from numpy import ma - -class ShiftingArray(object): - def __init__(self, values, dtype=None, startIndex=None, mask=ma.nomask): - - # hack to convert our fake date data types to real data types - if corelib.isDateType(dtype): - self.dtype = numpy.int_ - else: - self.dtype = dtype - - if self.dtype is None: - self.dtype = values.dtype - - # need to use the empty function instead of passing an empty list - # because that won't work when type=numpy.object_ - if len(values) == 0 and dtype is numpy.object_: - tempData = ma.array(numpy.empty((0,), self.dtype)) - else: - tempData = ma.array(values, self.dtype) - - #newSize = tempData.size*2 - newShape = list(tempData.shape) - newShape[0] *= 2 - newShape = tuple(newShape) - - - firstIndex = newShape[0]//4 - lastIndex = firstIndex + tempData.shape[0] - 1 - if startIndex is None: - self.indexZeroRepresents = None - else: - self.indexZeroRepresents = int(startIndex)-firstIndex - - if mask is not ma.nomask: - tempMask = ma.make_mask(mask) - tempData[tempMask] = ma.masked - - self.data = ma.array(numpy.empty(newShape,self.dtype)) - - if firstIndex > 0: - self.data[0:firstIndex] = ma.masked - if self.data.size > lastIndex+1: self.data[lastIndex+1:self.data.size] = ma.masked - - self.data[firstIndex:lastIndex+1] = tempData[:] - - - def shift(self, n): - self.indexZeroRepresents += n - - - #DATA ACCESS - - def __setitem__(self, index, value): - self.__expandToFit(self.__minIndex(index),self.__maxIndex(index)) - convIndex = self.__convIndex(index) - self.data[convIndex] = value - - - def __getitem__(self, index): - self.__expandToFit(self.__minIndex(index),self.__maxIndex(index)) - convIndex = self.__convIndex(index) - return self.data[convIndex] - - def _shift(self, startIndex, endIndex): - self.__expandToFit(startIndex, endIndex) - return self.data[startIndex-self.indexZeroRepresents:endIndex-self.indexZeroRepresents+1] - - - #PRIVATE FUNCTIONS - - def __convIndex(self,index): - - if self.indexZeroRepresents is not None: - if isinstance(index,ShiftingArray): - - if index.indexZeroRepresents > self.indexZeroRepresents: - #expand index to the left - originalSize = index.data.size - shiftAmt = index.indexZeroRepresents - self.indexZeroRepresents - newSize = originalSize + shiftAmt - temp = ma.array(numpy.empty(newSize, index.data.dtype)) - temp[newSize-originalSize:] = index.data - temp[0:shiftAmt] = False - temp = temp.filled(False) - else: - #chop off first portion of data - temp = index.data[self.indexZeroRepresents - index.indexZeroRepresents:].filled(False) - - # chop off extra values on right hand side - if temp.size > self.data.size: return temp[:self.data.size] - else: return temp - - elif type(index) == types.SliceType: - if index.start is None: tempStart = None - else: tempStart = index.start - self.indexZeroRepresents - if index.stop is None: tempStop = None - else: tempStop = index.stop - self.indexZeroRepresents - tempStep = index.step - - return slice(tempStart,tempStop,tempStep) - else: - return index - self.indexZeroRepresents - - else: - return index - - def __maxIndex(self,index): - if type(index) == types.IntType: return index - if type(index) == types.SliceType: return index.stop - elif isinstance(index,ShiftingArray): return index.lastValue() - elif hasattr(index,'__len__'): return max(index) - else: return int(index) - - def __minIndex(self,index): - if type(index) == types.IntType: return index - if type(index) == types.SliceType: return index.start - elif isinstance(index,ShiftingArray): return index.firstValue() - elif hasattr(index,'__len__'): return min(index) - else: return int(index) - - def __expandToFit(self, minRange, maxRange=None): - - if self.indexZeroRepresents is None: - self.indexZeroRepresents = minRange - - if maxRange is None: - maxRange = minRange - if maxRange < minRange: - raise ValueError("invalid range: " + str(minRange) + " to " + str(maxRange)) - - minRange -= self.indexZeroRepresents - maxRange -= self.indexZeroRepresents - - if maxRange > self.data.size-1: #expand to the right - originalSize = self.data.size - newSize = originalSize - while maxRange > newSize-1: - newSize = expandAmt(newSize) - - self.data = self.data.resize(numpy.shape(numpy.empty(newSize))) - self.data[originalSize:] = ma.masked - - - if minRange < 0: #expand to the left - originalSize = self.data.size - newSize = originalSize - shiftAmt = int(0) - while minRange + shiftAmt < 0: - newSize = expandAmt(newSize) - shiftAmt = int(newSize - originalSize) - - temp = ma.array(numpy.empty(newSize, self.data.dtype)) - temp[newSize-originalSize:] = self.data - self.data = temp - self.data[0:shiftAmt] = ma.masked - - self.indexZeroRepresents -= shiftAmt - - - - #MATH FUNCTIONS - - def __add__(self, other,fill_value=ma.masked): return doFunc(self,other, ma.add,fill_value=fill_value) - def __radd__(self, other): return self+other - def __sub__(self, other,fill_value=ma.masked): return doFunc(self,other, ma.subtract,fill_value=fill_value) - def __rsub__(self, other): return doFunc((self*-1),other, ma.add) - def __mul__(self, other,fill_value=ma.masked): return doFunc(self,other, ma.multiply,fill_value=fill_value) - def __rmul__(self, other): return self*other - def __div__(self, other,fill_value=ma.masked): return doFunc(self,other, ma.divide,fill_value=fill_value) - def __rdiv__(self, other): return doFunc(pow(self,-1),other, ma.multiply) - def __pow__(self, other,fill_value=ma.masked): return doFunc(self,other, ma.power,fill_value=fill_value) - - def __eq__(self, other): return doFunc(self,other, ma.equal) - def __le__(self, other): return doFunc(self,other, ma.less_equal) - def __lt__(self, other): return doFunc(self,other, ma.less) - def __ge__(self, other): return doFunc(self,other, ma.greater_equal) - def __gt__(self, other): return doFunc(self,other, ma.greater) - - def max(self,other): return doFunc(self,other, ma.maximum) - def min(self,other): return doFunc(self,other, ma.minimum) - - #INFO FUNCTIONS - - def __len__(self): - fv = self.firstValue() - if fv is not None: - return self.lastValue()-fv+1 - else: - return 0 - - def firstValue(self): - firstIndex = corelib.first_unmasked(self.data) - if self.indexZeroRepresents is None or firstIndex is None: - return None - else: - return firstIndex+self.indexZeroRepresents - - - def lastValue(self): - lastIndex = corelib.last_unmasked(self.data) - if self.indexZeroRepresents is None or lastIndex is None: - return None - else: - return lastIndex+self.indexZeroRepresents - - - #DISPLAY FUNCTIONS - - def __str__(self): - retVal = "" - if self.firstValue() is not None: - for i in range(corelib.first_unmasked(self.data), corelib.last_unmasked(self.data)+1): - index = str(i+self.indexZeroRepresents) - index = index + (" " * (6-len(index))) - retVal += index + "---> " + str(self.data[i]) + "\n" - return retVal - else: - return "" - - - -#apply func to ser1 and ser2, replacing masked values with fill_value -def doFunc(ser1, ser2, func,fill_value=ma.masked): - if not isinstance(ser2, ShiftingArray): - if ser1.indexZeroRepresents is None: - return ShiftingArray([],ser1.data.dtype) - else: - tempSer = numpy.empty(ser1.data.shape,dtype=ser1.data.dtype) - tempSer.fill(ser2) - ser2 = ShiftingArray(tempSer, startIndex=ser1.firstValue()) - - sFV, sLV = ser1.firstValue(), ser1.lastValue() - oFV, oLV = ser2.firstValue(), ser2.lastValue() - - if ser1.indexZeroRepresents is not None and ser2.indexZeroRepresents is not None: - if fill_value is not ma.masked: - minVal = min(sFV, oFV) - maxVal = max(sLV, oLV) - else: - minVal = max(sFV, oFV) - maxVal = min(sLV, oLV) - elif ser1.indexZeroRepresents is None and ser2.indexZeroRepresents is None: - return ShiftingArray([],ser1.data.dtype) - elif ser1.indexZeroRepresents is None: - minVal = oFV - maxVal = oLV - else: #ser2.indexZeroRepresents is None: - minVal = sFV - maxVal = sLV - - if maxVal < minVal: - return ShiftingArray([],ser1.data.dtype, startIndex=minVal) - - data1 = ser1._shift(minVal, maxVal) - data2 = ser2._shift(minVal, maxVal) - - if fill_value is ma.masked: - mask = data1.mask | data2.mask - else: - mask = data1.mask & data2.mask - - data1 = data1.filled(fill_value) - data2 = data2.filled(fill_value) - - data = func(data1,data2) - - return ShiftingArray(data,data.dtype,minVal, mask) - - -def doFunc_oneseries(ser,func): - - sFV = ser.firstValue() - - if sFV is None: - return ser - else: - result = func(ser.data) - return ShiftingArray(result,result.dtype,sFV,result.mask) - - -#MISC GLOBAL FUNCTIONS - -def expandAmt(size): - EXPAND_MULT = 1.2 - EXPAND_ADD = 5 - return round(size*EXPAND_MULT) + EXPAND_ADD - - From scipy-svn at scipy.org Fri Jan 5 18:43:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 5 Jan 2007 17:43:54 -0600 (CST) Subject: [Scipy-svn] r2491 - trunk/Lib/fftpack Message-ID: <20070105234354.532EE39C0D3@new.scipy.org> Author: rkern Date: 2007-01-05 17:43:53 -0600 (Fri, 05 Jan 2007) New Revision: 2491 Modified: trunk/Lib/fftpack/setup.py Log: Use the necessary info dict for the djbfft library. Modified: trunk/Lib/fftpack/setup.py =================================================================== --- trunk/Lib/fftpack/setup.py 2007-01-05 14:09:36 UTC (rev 2490) +++ trunk/Lib/fftpack/setup.py 2007-01-05 23:43:53 UTC (rev 2491) @@ -30,7 +30,7 @@ config.add_extension('_fftpack', sources=sources, libraries=['dfftpack'], - extra_info = fft_opt_info + extra_info = [fft_opt_info, djbfft_info], ) config.add_extension('convolve', From scipy-svn at scipy.org Fri Jan 5 18:45:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 5 Jan 2007 17:45:02 -0600 (CST) Subject: [Scipy-svn] r2492 - trunk Message-ID: <20070105234502.9C3F439C069@new.scipy.org> Author: rkern Date: 2007-01-05 17:45:02 -0600 (Fri, 05 Jan 2007) New Revision: 2492 Modified: trunk/MANIFEST.in Log: Rebuild the MANIFEST.in to reflect the new sandbox packages. Yay for new sandbox packages! Modified: trunk/MANIFEST.in =================================================================== --- trunk/MANIFEST.in 2007-01-05 23:43:53 UTC (rev 2491) +++ trunk/MANIFEST.in 2007-01-05 23:45:02 UTC (rev 2492) @@ -22,6 +22,9 @@ include Lib/sandbox/arraysetops/* include Lib/sandbox/arraysetops/tests/* include Lib/sandbox/buildgrid/* +include Lib/sandbox/cdavid/* +include Lib/sandbox/cdavid/src/* +include Lib/sandbox/cdavid/tests/* include Lib/sandbox/constants/* include Lib/sandbox/cow/* include Lib/sandbox/delaunay/* @@ -37,6 +40,8 @@ include Lib/sandbox/ga/* include Lib/sandbox/gplt/* include Lib/sandbox/image/* +include Lib/sandbox/maskedarray/* +include Lib/sandbox/maskedarray/tests/* include Lib/sandbox/models/* include Lib/sandbox/models/family/* include Lib/sandbox/models/robust/* @@ -75,8 +80,17 @@ include Lib/sandbox/svm/* include Lib/sandbox/svm/libsvm-2.82/* include Lib/sandbox/svm/tests/* +include Lib/sandbox/timeseries/* +include Lib/sandbox/timeseries/doc/* +include Lib/sandbox/timeseries/examples/* +include Lib/sandbox/timeseries/mtimeseries/* +include Lib/sandbox/timeseries/mtimeseries/tests/* +include Lib/sandbox/timeseries/old/* +include Lib/sandbox/timeseries/plotlib/* +include Lib/sandbox/timeseries/src/* include Lib/sandbox/umfpack/* include Lib/sandbox/umfpack/umfpack/* +include Lib/sandbox/wavelet/* include Lib/sandbox/xplt/* include Lib/sandbox/xplt/gistdata/* include Lib/sandbox/xplt/pygist/* From scipy-svn at scipy.org Fri Jan 5 18:47:21 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 5 Jan 2007 17:47:21 -0600 (CST) Subject: [Scipy-svn] r2493 - trunk Message-ID: <20070105234721.D3F9239C069@new.scipy.org> Author: rkern Date: 2007-01-05 17:47:21 -0600 (Fri, 05 Jan 2007) New Revision: 2493 Modified: trunk/ Log: Ignore site.cfg files. Property changes on: trunk ___________________________________________________________________ Name: svn:ignore - *.pyc *.swp *.pyd *.so build dist scipy.egg-info + *.pyc *.swp *.pyd *.so build dist scipy.egg-info site.cfg From scipy-svn at scipy.org Sat Jan 6 00:59:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 5 Jan 2007 23:59:36 -0600 (CST) Subject: [Scipy-svn] r2494 - trunk/Lib/io Message-ID: <20070106055936.16F3039C10E@new.scipy.org> Author: wnbell Date: 2007-01-05 23:59:18 -0600 (Fri, 05 Jan 2007) New Revision: 2494 Modified: trunk/Lib/io/mmio.py Log: Fixed small bug in io for sparse matrices Modified: trunk/Lib/io/mmio.py =================================================================== --- trunk/Lib/io/mmio.py 2007-01-05 23:47:21 UTC (rev 2493) +++ trunk/Lib/io/mmio.py 2007-01-06 05:59:18 UTC (rev 2494) @@ -266,7 +266,7 @@ raise ValueError,'unknown matrix type ' + `type(a)` rows,cols = a.shape entries = a.getnnz() - typecode = a.gettypecode() + typecode = a.dtype.char if precision is None: if typecode in 'fF': From scipy-svn at scipy.org Sat Jan 6 01:01:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 00:01:24 -0600 (CST) Subject: [Scipy-svn] r2495 - trunk/Lib/interpolate Message-ID: <20070106060124.9BA7D39C07D@new.scipy.org> Author: timl Date: 2007-01-06 00:01:15 -0600 (Sat, 06 Jan 2007) New Revision: 2495 Modified: trunk/Lib/interpolate/__fitpack.h Log: revert patch from [2477] in response to #339. This reopens #248 Modified: trunk/Lib/interpolate/__fitpack.h =================================================================== --- trunk/Lib/interpolate/__fitpack.h 2007-01-06 05:59:18 UTC (rev 2494) +++ trunk/Lib/interpolate/__fitpack.h 2007-01-06 06:01:15 UTC (rev 2495) @@ -140,7 +140,6 @@ PyObject *x_py = NULL,*y_py = NULL,*z_py = NULL,*w_py = NULL,\ *tx_py = NULL,*ty_py = NULL; PyObject *wrk_py=NULL; - PyObject *ret=NULL; nx=ny=ier=nxo=nyo=0; if (!PyArg_ParseTuple(args, "OOOOddddiiiddOOiiOii",\ &x_py,&y_py,&z_py,&w_py,&xb,&xe,\ @@ -225,17 +224,10 @@ Py_DECREF(ap_y); Py_DECREF(ap_z); Py_DECREF(ap_w); - ret = Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),\ - PyArray_Return(ap_ty),PyArray_Return(ap_c),\ - "wrk",PyArray_Return(ap_wrk),\ - "ier",ier,"fp",fp); - Py_DECREF(ap_tx); - Py_DECREF(ap_ty); - Py_DECREF(ap_c); - Py_DECREF(ap_wrk); - - return ret; - + return Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),\ + PyArray_Return(ap_ty),PyArray_Return(ap_c),\ + "wrk",PyArray_Return(ap_wrk),\ + "ier",ier,"fp",fp); fail: if (wa) free(wa); Py_XDECREF(ap_x); From scipy-svn at scipy.org Sat Jan 6 01:34:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 00:34:54 -0600 (CST) Subject: [Scipy-svn] r2496 - in trunk/Lib/sparse: . sparsetools tests Message-ID: <20070106063454.E32E539C07D@new.scipy.org> Author: wnbell Date: 2007-01-06 00:34:41 -0600 (Sat, 06 Jan 2007) New Revision: 2496 Added: trunk/Lib/sparse/sparsetools/complex_ops.h trunk/Lib/sparse/sparsetools/numpy.i trunk/Lib/sparse/sparsetools/sparsetools.h trunk/Lib/sparse/sparsetools/sparsetools.i trunk/Lib/sparse/sparsetools/sparsetools.py trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx Removed: trunk/Lib/sparse/sparsetools.txt trunk/Lib/sparse/sparsetools/sparsetools.pyf.src trunk/Lib/sparse/sparsetools/spblas.f.src trunk/Lib/sparse/sparsetools/spconv.f.src Modified: trunk/Lib/sparse/setup.py trunk/Lib/sparse/sparse.py trunk/Lib/sparse/tests/test_sparse.py Log: Rewrite of sparsetools. additional sparse unittests, and changes to sparse.py to interface w/ the new sparsetools Modified: trunk/Lib/sparse/setup.py =================================================================== --- trunk/Lib/sparse/setup.py 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/setup.py 2007-01-06 06:34:41 UTC (rev 2496) @@ -15,10 +15,16 @@ # sources = [join('sparsekit','*.f')] # ) - sources = ['spblas.f.src','spconv.f.src','sparsetools.pyf.src'] +## sources = ['spblas.f.src','spconv.f.src','sparsetools.pyf.src'] +## sources = [join('sparsetools',x) for x in sources] + +## config.add_extension('sparsetools', +## sources = sources, +## ) + sources = ['sparsetools_wrap.cxx','sparsetools.py'] sources = [join('sparsetools',x) for x in sources] - config.add_extension('sparsetools', + config.add_extension('_sparsetools', sources = sources, ) Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparse.py 2007-01-06 06:34:41 UTC (rev 2496) @@ -2,6 +2,7 @@ Original code by Travis Oliphant. Modified and extended by Ed Schofield and Robert Cimrman. +Revision of sparsetools by Nathan Bell """ from numpy import zeros, isscalar, real, imag, asarray, asmatrix, matrix, \ @@ -23,14 +24,6 @@ ALLOCSIZE=1000 NZMAX = 100 -_coerce_rules = {('f', 'f'):'f', ('f', 'd'):'d', ('f', 'F'):'F', - ('f', 'D'):'D', ('d', 'f'):'d', ('d', 'd'):'d', - ('d', 'F'):'D', ('d', 'D'):'D', ('F', 'f'):'F', - ('F', 'd'):'D', ('F', 'F'):'F', ('F', 'D'):'D', - ('D', 'f'):'D', ('D', 'd'):'d', ('D', 'F'):'D', - ('D', 'D'):'D'} -_transtabl = {'f':'s', 'd':'d', 'F':'c', 'D':'z'} -_itranstabl = {'s':'f', 'd':'d', 'c':'F', 'z':'D'} # The formats that we might potentially understand. _formats = {'csc':[0, "Compressed Sparse Column"], @@ -55,6 +48,17 @@ 'und':[19, "Undefined"] } + + +#these four don't appear to be used anymore (Jan 6th, 2007) +_coerce_rules = {('f', 'f'):'f', ('f', 'd'):'d', ('f', 'F'):'F', + ('f', 'D'):'D', ('d', 'f'):'d', ('d', 'd'):'d', + ('d', 'F'):'D', ('d', 'D'):'D', ('F', 'f'):'F', + ('F', 'd'):'D', ('F', 'F'):'F', ('F', 'D'):'D', + ('D', 'f'):'D', ('D', 'd'):'d', ('D', 'F'):'D', + ('D', 'D'):'D'} +_transtabl = {'f':'s', 'd':'d', 'F':'c', 'D':'z'} +_itranstabl = {'s':'f', 'd':'d', 'c':'F', 'z':'D'} def _convert_data(data1, data2, newtype): if data1.dtype.char != newtype: data1 = data1.astype(newtype) @@ -62,6 +66,9 @@ data2 = data2.astype(newtype) return data1, data2 + + + class spmatrix(object): """ This class provides a base class for all sparse matrices. It cannot be instantiated. Most of the work is provided by subclasses. @@ -476,25 +483,8 @@ # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): - M, N = s.shape - dtype = s.dtype - func = getattr(sparsetools, _transtabl[dtype.char]+'fulltocsc') - ierr = irow = jcol = 0 - nnz = (s != 0.0).sum() - a = zeros((nnz,), self.dtype) - rowa = zeros((nnz,), intc) - ptra = zeros((N+1,), intc) - while 1: - a, rowa, ptra, irow, jcol, ierr = \ - func(s, a, rowa, ptra, irow, jcol, ierr) - if (ierr == 0): break - nnz = nnz + ALLOCSIZE - a = resize1d(a, nnz) - rowa = resize1d(rowa, nnz) - self.data = a - self.rowind = rowa - self.indptr = ptra - self.shape = (M, N) + self.shape = s.shape + self.indptr,self.rowind,self.data = sparsetools.densetocsr(s.shape[1],s.shape[0],s.T) else: raise ValueError, "dense array must have rank 1 or 2" elif isspmatrix(arg1): @@ -513,9 +503,7 @@ self.indptr = s.indptr elif isinstance(s, csr_matrix): self.shape = s.shape - func = getattr(sparsetools, s.ftype+'transp') - self.data, self.rowind, self.indptr = \ - func(s.shape[1], s.data, s.colind, s.indptr) + self.indptr,self.rowind,self.data = sparsetools.csrtocsc(s.shape[0],s.shape[1],s.indptr,s.colind,s.data) else: temp = s.tocsc() self.data = temp.data @@ -609,6 +597,10 @@ raise ValueError, \ "Last value of index list should be less than "\ "the size of data list" + if (self.rowind.dtype != numpy.intc): + raise TypeError, "rowind indices must be of type numpy.intc" + if (self.indptr.dtype != numpy.intc): + raise TypeError, "inptr indices must be of type numpy.intc" self.nnz = nnz self.nzmax = nzmax self.dtype = self.data.dtype @@ -641,18 +633,10 @@ ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" - dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] - nnz1, nnz2 = self.nnz, ocs.nnz - if (nnz1 == 0): nnz1 = 1 - if (nnz2 == 0): nnz2 = 1 - data1, data2 = _convert_data(self.data[:nnz1], ocs.data[:nnz2], dtypechar) - func = getattr(sparsetools, _transtabl[dtypechar]+'cscadd') - c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, - data2, ocs.rowind[:nnz2], ocs.indptr) - if ierr: - raise RuntimeError, "ran out of space" - M, N = self.shape - return csc_matrix((c, rowc, ptrc), dims=(M, N)) + indptr,rowind,data = sparsetools.cscplcsc(self.shape[0],self.shape[1], \ + self.indptr,self.rowind,self.data,\ + ocs.indptr,ocs.rowind,ocs.data) + return csc_matrix((data,rowind,indptr),self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. return self.todense() + other @@ -667,18 +651,10 @@ ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" - dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] - nnz1, nnz2 = self.nnz, ocs.nnz - if (nnz1 == 0): nnz1=1 - if (nnz2 == 0): nnz2=1 - data1, data2 = _convert_data(self.data[:nnz1], ocs.data[:nnz2], dtypechar) - func = getattr(sparsetools, _transtabl[dtypechar]+'cscadd') - c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, - data2, ocs.rowind[:nnz2], ocs.indptr) - if ierr: - raise RuntimeError, "ran out of space" - M, N = self.shape - return csc_matrix((c, rowc, ptrc), dims=(M, N)) + indptr,rowind,data = sparsetools.cscplcsc(self.shape[0],self.shape[1], \ + self.indptr,self.rowind,self.data,\ + ocs.indptr,ocs.rowind,ocs.data) + return csc_matrix((data,rowind,indptr),self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them return other + self.todense() @@ -731,15 +707,10 @@ ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" - dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] - nnz1, nnz2 = self.nnz, ocs.nnz - data1, data2 = _convert_data(self.data[:nnz1], ocs.data[:nnz2], dtypechar) - func = getattr(sparsetools, _transtabl[dtypechar]+'cscmul') - c, rowc, ptrc, ierr = func(data1, self.rowind[:nnz1], self.indptr, data2, ocs.rowind[:nnz2], ocs.indptr) - if ierr: - raise RuntimeError, "ran out of space" - M, N = self.shape - return csc_matrix((c, rowc, ptrc), dims=(M, N)) + indptr,rowind,data = sparsetools.cscelmulcsc(self.shape[0],self.shape[1],\ + self.indptr,self.rowind,self.data,\ + ocs.indptr,ocs.rowind,ocs.data) + return csc_matrix((data,rowind,indptr),(self.shape[0],ocs.shape[1])) def transpose(self, copy=False): M, N = self.shape @@ -801,8 +772,9 @@ # being created on-the-fly like with dense matrix objects. #if len(other) != self.shape[1]: # raise ValueError, "dimension mismatch" - func = getattr(sparsetools, self.ftype+'cscmux') - y = func(self.data, self.rowind, self.indptr, other, self.shape[0]) + oth = numpy.ravel(other) + y = sparsetools.cscmux(self.shape[0],self.shape[1],\ + self.indptr,self.rowind,self.data,oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -821,13 +793,12 @@ # being created on-the-fly like with dense matrix objects. #if len(other) != self.shape[0]: # raise ValueError, "dimension mismatch" - func = getattr(sparsetools, self.ftype+'csrmux') + oth = numpy.ravel(other) if conjugate: cd = conj(self.data) else: cd = self.data - y = func(cd, self.rowind, self.indptr, other) - + y = sparsetool.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an @@ -846,51 +817,10 @@ K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" - a, rowa, ptra = self.data, self.rowind, self.indptr - if isinstance(other, csr_matrix): - other._check() - dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] - ftype = _transtabl[dtypechar] - func = getattr(sparsetools, ftype+'cscmucsr') - b = other.data - rowb = other.colind - ptrb = other.indptr - elif isinstance(other, csc_matrix): - other._check() - dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] - ftype = _transtabl[dtypechar] - func = getattr(sparsetools, ftype+'cscmucsc') - b = other.data - rowb = other.rowind - ptrb = other.indptr - else: - other = other.tocsc() - dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] - ftype = _transtabl[dtypechar] - func = getattr(sparsetools, ftype+'cscmucsc') - b = other.data - rowb = other.rowind - ptrb = other.indptr - a, b = _convert_data(a, b, dtypechar) - ptrc = zeros((N+1,), intc) - nnzc = 2*max(ptra[-1], ptrb[-1]) - c = zeros((nnzc,), dtypechar) - rowc = zeros((nnzc,), intc) - ierr = irow = kcol = 0 - while True: # loop in case first call runs out of memory. - c, rowc, ptrc, irow, kcol, ierr = func(M, a, rowa, ptra, b, - rowb, ptrb, c, rowc, - ptrc, irow, kcol, ierr) - if (ierr==0): break - # otherwise we were too small and must resize arrays - # calculations continue where they left off... - print "Resizing...", kcol, irow, ierr - percent_to_go = 1- (1.0*kcol*M + irow) / (N*M) - newnnzc = int(ceil((1+percent_to_go)*nnzc)) - c = resize1d(c, newnnzc) - rowc = resize1d(rowc, newnnzc) - nnzc = newnnzc - return csc_matrix((c, rowc, ptrc), dims=(M, N)) + other = other.tocsc() + indptr,rowind,data = sparsetools.cscmucsc(M,N,self.indptr,self.rowind,self.data,\ + other.indptr,other.rowind,other.data) + return csc_matrix((data,rowind,indptr),(M,N)) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! @@ -915,9 +845,12 @@ col = N + col if not (0<=row= M): M = row+1 self.shape = (M, N) - nzmax = self.nzmax - if (nzmax < self.nnz+1): # need more room - alloc = max(1, self.allocsize) - self.data = resize1d(self.data, nzmax + alloc) - self.rowind = resize1d(self.rowind, nzmax + alloc) - func(self.data, self.rowind, self.indptr, row, col, val) + + indxs = numpy.where(row == self.rowind[self.indptr[col]:self.indptr[col+1]]) + if len(indxs[0]) == 0: + #value not present + nzmax = self.nzmax + if (nzmax < self.nnz+1): # need more room + alloc = max(1, self.allocsize) + self.data = resize1d(self.data, nzmax + alloc) + self.rowind = resize1d(self.rowind, nzmax + alloc) + + newindex = self.indptr[col] + self.data[newindex+1:] = self.data[newindex:-1] + self.rowind[newindex+1:] = self.rowind[newindex:-1] + + self.data[newindex] = val + self.rowind[newindex] = row + self.indptr[col+1:] += 1 + + elif len(indxs[0]) == 1: + #value already present + self.data[self.indptr[col]:self.indptr[col+1]][indxs[0]] = val + else: + raise IndexError, "row index occurs more than once" + self._check() else: # We should allow slices here! @@ -966,31 +916,18 @@ if stop <= start: raise ValueError, "slice width must be >= 1" startind = -1 - # Locate the first element in self.data - # (could be made more efficient with a binary search) - for ind in xrange(self.indptr[j], self.indptr[j+1]): - if self.rowind[ind] >= start: - startind = ind - break - if startind == -1: - # Col has only zeros - return csc_matrix((stop-start, 1), dtype=self.dtype, \ - nzmax=min(NZMAX, stop-start)) + + indices = [] - stopind = self.indptr[j+1] - # Locate the last+1 index into self.data - # (could be made more efficient with a binary search) - for ind in xrange(startind, self.indptr[j+1]): - if self.rowind[ind] >= stop: - stopind = ind - break - - data = self.data[startind : stopind] - rowind = self.rowind[startind : stopind] - start - indptr = numpy.array([0, stopind - startind]) - new = csc_matrix((data, rowind, indptr), dims=(stop-start, 1), \ - dtype=self.dtype) - return new + for ind in xrange(self.indptr[j], self.indptr[j+1]): + if self.rowind[ind] >= start and self.rowind[ind] < stop: + indices.append(ind) + + rowind = self.rowind[indices] - start + data = self.data[indices] + indptr = numpy.array([0,len(indices)]) + return csc_matrix((data, rowind, indptr), dims=(stop-start, 1), \ + dtype=self.dtype) def rowcol(self, ind): row = self.rowind[ind] @@ -1008,19 +945,16 @@ return new def tocoo(self): - if self.nnz == 0: - return coo_matrix(None, dims=self.shape, dtype=self.dtype) - else: - func = getattr(sparsetools, self.ftype+"csctocoo") - data, row, col = func(self.data, self.rowind, self.indptr) - return coo_matrix((data, (row, col)), dims=self.shape) + rows,cols,data = sparsetools.csctocoo(self.shape[0],self.shape[1],\ + self.indptr,self.rowind,self.data) + return coo_matrix((data,(rows,cols)),self.shape) def tocsr(self): - return self.tocoo().tocsr() - + indptr,colind,data = sparsetools.csctocsr(self.shape[0],self.shape[1],self.indptr,self.rowind,self.data) + return csr_matrix((data,colind,indptr),self.shape) + def toarray(self): - func = getattr(sparsetools, self.ftype+'csctofull') - return func(self.shape[0], self.data, self.rowind, self.indptr) + return self.tocsr().toarray() def prune(self): """ Remove empty space after all non-zero elements. @@ -1097,11 +1031,6 @@ self.data = s.data self.colind = s.colind self.indptr = s.indptr - elif isinstance(s, csc_matrix): - self.shape = s.shape - func = getattr(sparsetools, s.ftype+'transp') - self.data, self.colind, self.indptr = \ - func(s.shape[1], s.data, s.rowind, s.indptr) else: try: temp = s.tocsr() @@ -1196,6 +1125,10 @@ raise ValueError, \ "last value of index list should be less than "\ "the size of data list" + if (self.colind.dtype != numpy.intc): + raise TypeError, "colind indices must be of type numpy.intc" + if (self.indptr.dtype != numpy.intc): + raise TypeError, "inptr indices must be of type numpy.intc" self.nnz = nnz self.nzmax = nzmax self.dtype = self.data.dtype @@ -1226,19 +1159,12 @@ raise NotImplementedError, 'adding a scalar to a CSR matrix ' \ 'is not yet supported' elif isspmatrix(other): - ocs = other.tocsr() - if (ocs.shape != self.shape): + other = other.tocsr() + if (other.shape != self.shape): raise ValueError, "inconsistent shapes" - - dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] - data1, data2 = _convert_data(self.data, ocs.data, dtypechar) - func = getattr(sparsetools, _transtabl[dtypechar]+'cscadd') - c, colc, ptrc, ierr = func(data1, self.colind, self.indptr, data2, - ocs.colind, ocs.indptr) - if ierr: - raise RuntimeError, "ran out of space" - M, N = self.shape - return csr_matrix((c, colc, ptrc), dims=(M, N)) + indptr,colind,data = sparsetools.csrplcsr(self.shape[0],other.shape[1],\ + self.indptr,self.colind,self.data,other.indptr,other.colind,other.data) + return csr_matrix((data,colind,indptr),self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. return self.todense() + other @@ -1288,18 +1214,13 @@ new.ftype = _transtabl[new.dtype.char] return new elif isspmatrix(other): - ocs = other.tocsr() - if (ocs.shape != self.shape): + other = other.tocsr() + if (other.shape != self.shape): raise ValueError, "inconsistent shapes" - dtypechar = _coerce_rules[(self.dtype.char, ocs.dtype.char)] - data1, data2 = _convert_data(self.data, ocs.data, dtypechar) - func = getattr(sparsetools, _transtabl[dtypechar]+'cscmul') - c, colc, ptrc, ierr = func(data1, self.colind, self.indptr, data2, - ocs.colind, ocs.indptr) - if ierr: - raise RuntimeError, "ran out of space" - M, N = self.shape - return csr_matrix((c, colc, ptrc), dims=(M, N)) + indptr,colind,data = sparsetools.csrelmulcsr(self.shape[0],other.shape[1],\ + self.indptr,self.colind,self.data,\ + other.indptr,other.colind,other.data) + return csr_matrix((data,colind,indptr),(self.shape[0],other.shape[1])) else: raise TypeError, "unsupported type for sparse matrix power" @@ -1349,9 +1270,8 @@ # being created on-the-fly like dense matrix objects can. #if len(other) != self.shape[1]: # raise ValueError, "dimension mismatch" - func = getattr(sparsetools, self.ftype+'csrmux') - y = func(self.data, self.colind, self.indptr, other) - + oth = numpy.ravel(other) + y = sparsetools.csrmux(self.shape[0],self.shape[1],self.indptr,self.colind,self.data,oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -1370,8 +1290,9 @@ cd = conj(self.data) else: cd = self.data - y = func(cd, self.colind, self.indptr, other, self.shape[1]) + oth = numpy.ravel(other) + y = sparsetools.cscmux(self.shape[0],self.shape[1],self.indptr,self.rowind,cd,oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an @@ -1387,69 +1308,11 @@ a, rowa, ptra = self.data, self.colind, self.indptr if (K1 != K2): raise ValueError, "shape mismatch error" - if isinstance(other, csc_matrix): - other._check() - dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] - ftype = _transtabl[dtypechar] - func = getattr(sparsetools, ftype+'csrmucsc') - b = other.data - colb = other.rowind - ptrb = other.indptr - out = 'csc' - firstarg = () - elif isinstance(other, csr_matrix): - other._check() - dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] - ftype = _transtabl[dtypechar] - func = getattr(sparsetools, ftype+'cscmucsc') - b, colb, ptrb = a, rowa, ptra - a, rowa, ptra = other.data, other.colind, other.indptr - out = 'csr' - firstarg = (N,) - else: - other = other.tocsc() - dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] - ftype = _transtabl[dtypechar] - func = getattr(sparsetools, ftype+'csrmucsc') - b = other.data - colb = other.rowind - ptrb = other.indptr - out = 'csc' - firstarg = () - a, b = _convert_data(a, b, dtypechar) - newshape = (M, N) - if out == 'csr': - ptrc = zeros((M+1,), intc) - else: - ptrc = zeros((N+1,), intc) - nnzc = 2*max(ptra[-1], ptrb[-1]) - # Avoid an infinite loop when multiplying by a matrix with - # only zeros - if nnzc == 0: - if out == 'csr': - return csr_matrix(newshape, dtype=dtypechar) - else: - return csc_matrix(newshape, dtype=dtypechar) - c = zeros((nnzc,), dtypechar) - rowc = zeros((nnzc,), intc) - ierr = irow = kcol = 0 - while 1: - args = firstarg+(a, rowa, ptra, b, colb, ptrb, c, rowc, ptrc, irow, - kcol, ierr) - c, rowc, ptrc, irow, kcol, ierr = func(*args) - if (ierr==0): break - # otherwise we were too small and must resize - percent_to_go = 1- (1.0*kcol) / N - newnnzc = int(ceil((1+percent_to_go)*nnzc)) - c = resize1d(c, newnnzc) - rowc = resize1d(rowc, newnnzc) - nnzc = newnnzc - - if out == 'csr': - # Note: 'rowc' is deliberate - return csr_matrix((c, rowc, ptrc), dims=(M, N)) - else: - return csc_matrix((c, rowc, ptrc), dims=(M, N)) + other = other.tocsr() + indptr,colind,data = sparsetools.csrmucsr(self.shape[0],other.shape[1],\ + self.indptr,self.colind,self.data,\ + other.indptr,other.colind,other.data) + return csr_matrix((data,colind,indptr),(self.shape[0],other.shape[1])) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! @@ -1474,9 +1337,12 @@ col = N + col if not (0<=row= 1" startind = -1 - # Locate the first element in self.data - # (could be made more efficient with a binary search) - for ind in xrange(self.indptr[i], self.indptr[i+1]): - if self.colind[ind] >= start: - startind = ind - break - if startind == -1: - # Row has only zeros - return csr_matrix((1, stop-start), dtype=self.dtype, \ - nzmax=min(NZMAX, stop-start)) + + indices = [] - stopind = self.indptr[i+1] - # Locate the last+1 index into self.data - # (could be made more efficient with a binary search) - for ind in xrange(startind, self.indptr[i+1]): - if self.colind[ind] >= stop: - stopind = ind - break - - data = self.data[startind : stopind] - colind = self.colind[startind : stopind] - start - indptr = numpy.array([0, stopind - startind]) - new = csr_matrix((data, colind, indptr), dims=(1, stop-start), \ - dtype=self.dtype) - return new + for ind in xrange(self.indptr[i], self.indptr[i+1]): + if self.colind[ind] >= start and self.colind[ind] < stop: + indices.append(ind) + + colind = self.colind[indices] - start + data = self.data[indices] + indptr = numpy.array([0,len(indices)]) + return csr_matrix((data, colind, indptr), dims=(1,stop-start), \ + dtype=self.dtype) def __setitem__(self, key, val): if isinstance(key, tuple): row = key[0] col = key[1] - func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row @@ -1534,19 +1386,33 @@ self.indptr = resize1d(self.indptr, row+2) self.indptr[M+1:] = self.indptr[M] M = row+1 - elif (row < 0): - row = M - row if (col >= N): N = col+1 - elif (col < 0): - col = N - col self.shape = (M, N) - nzmax = self.nzmax - if (nzmax < self.nnz+1): # need more room - alloc = max(1, self.allocsize) - self.data = resize1d(self.data, nzmax + alloc) - self.colind = resize1d(self.colind, nzmax + alloc) - func(self.data, self.colind, self.indptr, col, row, val) + + indxs = numpy.where(col == self.colind[self.indptr[row]:self.indptr[row+1]]) + if len(indxs[0]) == 0: + #value not present + nzmax = self.nzmax + if (nzmax < self.nnz+1): # need more room + alloc = max(1, self.allocsize) + self.data = resize1d(self.data, nzmax + alloc) + self.colind = resize1d(self.colind, nzmax + alloc) + + newindex = self.indptr[row] + self.data[newindex+1:] = self.data[newindex:-1] + self.colind[newindex+1:] = self.colind[newindex:-1] + + self.data[newindex] = val + self.colind[newindex] = col + self.indptr[row+1:] += 1 + + elif len(indxs[0]) == 1: + #value already present + self.data[self.indptr[row]:self.indptr[row+1]][indxs[0]] = val + else: + raise IndexError, "row index occurs more than once" + self._check() else: # We should allow slices here! @@ -1567,20 +1433,19 @@ return self def tocoo(self): - if self.nnz == 0: - return coo_matrix(None, dims=self.shape, dtype=self.dtype) - else: - func = getattr(sparsetools, self.ftype+"csctocoo") - data, col, row = func(self.data, self.colind, self.indptr) - return coo_matrix((data, (row, col)), dims=self.shape) + rows,cols,data = sparsetools.csrtocoo(self.shape[0],self.shape[1],\ + self.indptr,self.colind,self.data) + return coo_matrix((data,(rows,cols)),self.shape) def tocsc(self): - return self.tocoo().tocsc() + indptr,rowind,data = sparsetools.csrtocsc(self.shape[0],self.shape[1],self.indptr,self.colind,self.data) + return csc_matrix((data,rowind,indptr),self.shape) + def toarray(self): - func = getattr(sparsetools, self.ftype+'csctofull') - s = func(self.shape[1], self.data, self.colind, self.indptr) - return s.transpose() + data = numpy.zeros(self.shape,self.data.dtype) + sparsetools.csrtodense(self.shape[0],self.shape[1],self.indptr,self.colind,self.data,data) + return data def prune(self): """ Eliminate non-zero entries, leaving space for at least @@ -1648,6 +1513,7 @@ assert M == int(M) and M > 0 assert N == int(N) and N > 0 self.shape = (int(M), int(N)) + return except (TypeError, ValueError, AssertionError): raise TypeError, "dimensions must be a 2-tuple of positive"\ " integers" @@ -2057,6 +1923,7 @@ base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) + N = len(cols_or_rows) if indx: for key in self: num = searchsorted(cols_or_rows, key[1]) @@ -2132,6 +1999,7 @@ ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey0 != current_row: + N = ikey0-current_row row_ptr[current_row+1:ikey0+1] = k current_row = ikey0 data[k] = dict.__getitem__(self, key) @@ -2164,6 +2032,7 @@ ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey1 != current_col: + N = ikey1-current_col col_ptr[current_col+1:ikey1+1] = k current_col = ikey1 data[k] = self[key] @@ -2272,6 +2141,10 @@ if (nnz != len(self.row)) or (nnz != len(self.col)): raise ValueError, "row, column, and data array must all be "\ "the same length" + if (self.row.dtype != numpy.intc): + raise TypeError, "row indices must be of type numpy.intc" + if (self.col.dtype != numpy.intc): + raise TypeError, "col indices must be of type numpy.intc" self.nnz = nnz self.ftype = _transtabl.get(self.dtype.char,'') @@ -2304,24 +2177,17 @@ if self.nnz == 0: return csc_matrix(self.shape, dtype=self.dtype) else: - func = getattr(sparsetools, self.ftype+"cootocsc") - data, row, col = self._normalize() - a, rowa, ptra, ierr = func(self.shape[1], data, row, col) - if ierr: - raise RuntimeError, "error in conversion" - return csc_matrix((a, rowa, ptra), dims=self.shape) + indptr,rowind,data = sparsetools.cootocsc(self.shape[0],self.shape[1],self.size,self.row,self.col,self.data) + return csc_matrix((data,rowind,indptr),self.shape) + def tocsr(self): if self.nnz == 0: return csr_matrix(self.shape, dtype=self.dtype) else: - func = getattr(sparsetools, self.ftype+"cootocsc") - data, row, col = self._normalize(rowfirst=True) - a, cola, ptra, ierr = func(self.shape[0], data, col, row) - if ierr: - raise RuntimeError, "error in conversion" - return csr_matrix((a, cola, ptra), dims=self.shape) - + indptr,colind,data = sparsetools.cootocsr(self.shape[0],self.shape[1],self.size,self.row,self.col,self.data) + return csr_matrix((data,colind,indptr),self.shape) + def tocoo(self, copy=False): if copy: return self.copy() @@ -2811,15 +2677,10 @@ if not hasattr(offsets, '__len__' ): offsets = (offsets,) offsets = array(offsets, copy=False) - mtype = diags.dtype.char assert(len(offsets) == diags.shape[0]) - # set correct diagonal to csc conversion routine for this type - diagfunc = eval('sparsetools.'+_transtabl[mtype]+'diatocsc') - a, rowa, ptra, ierr = diagfunc(M, N, diags, offsets) - if ierr: - raise RuntimeError, "ran out of space" - return csc_matrix((a, rowa, ptra), dims=(M, N)) - + indptr,rowind,data = sparsetools.spdiags(M,N,len(offsets),offsets,diags) + return csc_matrix((data,rowind,indptr),(M,N)) + def spidentity(n, dtype='d'): """ spidentity( n ) returns the identity matrix of shape (n, n) stored Added: trunk/Lib/sparse/sparsetools/complex_ops.h =================================================================== --- trunk/Lib/sparse/sparsetools/complex_ops.h 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/complex_ops.h 2007-01-06 06:34:41 UTC (rev 2496) @@ -0,0 +1,159 @@ +#ifndef COMPLEX_OPS_H +#define COMPLEX_OPS_H + +/* + * Functions to handle arithmetic operations on NumPy complex values + */ + + + + +/* + * Addition + */ +inline npy_cfloat operator+(const npy_cfloat& A, const npy_cfloat& B){ + npy_cfloat result; + result.real = A.real + B.real; + result.imag = A.imag + B.imag; + return result; +} +inline npy_cdouble operator+(const npy_cdouble& A, const npy_cdouble& B){ + npy_cdouble result; + result.real = A.real + B.real; + result.imag = A.imag + B.imag; + return result; +} +inline npy_clongdouble operator+(const npy_clongdouble& A, const npy_clongdouble& B){ + npy_clongdouble result; + result.real = A.real + B.real; + result.imag = A.imag + B.imag; + return result; +} + +inline npy_cfloat& operator+=(npy_cfloat& A, const npy_cfloat& B){ + A.real += B.real; + A.imag += B.imag; + return A; +} +inline npy_cdouble& operator+=(npy_cdouble& A, const npy_cdouble& B){ + A.real += B.real; + A.imag += B.imag; + return A; +} +inline npy_clongdouble& operator+=(npy_clongdouble& A, const npy_clongdouble& B){ + A.real += B.real; + A.imag += B.imag; + return A; +} + +/* + * Multiplication + */ +inline npy_cfloat operator*(const npy_cfloat& A, const npy_cfloat& B){ + npy_cfloat result; + result.real = A.real * B.real - A.imag * B.imag; + result.imag = A.real * B.imag + A.imag * B.real; + return result; +} +inline npy_cdouble operator*(const npy_cdouble& A, const npy_cdouble& B){ + npy_cdouble result; + result.real = A.real * B.real - A.imag * B.imag; + result.imag = A.real * B.imag + A.imag * B.real; + return result; +} +inline npy_clongdouble operator*(const npy_clongdouble& A, const npy_clongdouble& B){ + npy_clongdouble result; + result.real = A.real * B.real - A.imag * B.imag; + result.imag = A.real * B.imag + A.imag * B.real; + return result; +} + +inline npy_cfloat& operator*=(npy_cfloat& A, const npy_cfloat& B){ + npy_float temp = A.real * B.real - A.imag * B.imag; + A.imag = A.real * B.imag + A.imag * B.real; + A.real = temp; + return A; +} +inline npy_cdouble& operator*=(npy_cdouble& A, const npy_cdouble& B){ + npy_double temp = A.real * B.real - A.imag * B.imag; + A.imag = A.real * B.imag + A.imag * B.real; + A.real = temp; + return A; +} +inline npy_clongdouble& operator*=(npy_clongdouble& A, const npy_clongdouble& B){ + npy_longdouble temp = A.real * B.real - A.imag * B.imag; + A.imag = A.real * B.imag + A.imag * B.real; + A.real = temp; + return A; +} + +/* + * Equality (complex==complex) + */ +inline bool operator==(const npy_cfloat& A, const npy_cfloat& B){ + return A.real == B.real && A.imag == B.imag; +} +inline bool operator==(const npy_cdouble& A, const npy_cdouble& B){ + return A.real == B.real && A.imag == B.imag; +} +inline bool operator==(const npy_clongdouble& A, const npy_clongdouble& B){ + return A.real == B.real && A.imag == B.imag; +} + +inline bool operator!=(const npy_cfloat& A, const npy_cfloat& B){ + return A.real != B.real || A.imag != B.imag; +} +inline bool operator!=(const npy_cdouble& A, const npy_cdouble& B){ + return A.real != B.real || A.imag != B.imag; +} +inline bool operator!=(const npy_clongdouble& A, const npy_clongdouble& B){ + return A.real != B.real || A.imag != B.imag; +} + +/* + * Equality (complex==scalar) + */ +inline bool operator==(const npy_cfloat& A, const npy_float& B){ + return A.real == B && A.imag == 0; +} +inline bool operator==(const npy_cdouble& A, const npy_double& B){ + return A.real == B && A.imag == 0; +} +inline bool operator==(const npy_clongdouble& A, const npy_longdouble& B){ + return A.real == B && A.imag == 0; +} + +inline bool operator!=(const npy_cfloat& A, const npy_float& B){ + return A.real != B || A.imag != 0; +} +inline bool operator!=(const npy_cdouble& A, const npy_double& B){ + return A.real != B || A.imag != 0; +} +inline bool operator!=(const npy_clongdouble& A, const npy_longdouble& B){ + return A.real != B || A.imag != 0; +} + +/* + * Equality (scalar==complex) + */ +inline bool operator==(const npy_float& A, const npy_cfloat& B){ + return A == B.real && 0 == B.imag; +} +inline bool operator==(const npy_double& A, const npy_cdouble& B){ + return A == B.real && 0 == B.imag; +} +inline bool operator==(const npy_longdouble& A, const npy_clongdouble& B){ + return A == B.real && 0 == B.imag; +} + +inline bool operator!=(const npy_float& A, const npy_cfloat& B){ + return A != B.real || 0 != B.imag; +} +inline bool operator!=(const npy_double& A, const npy_cdouble& B){ + return A != B.real || 0 != B.imag; +} +inline bool operator!=(const npy_longdouble& A, const npy_clongdouble& B){ + return A != B.real || 0 != B.imag; +} + +#endif Added: trunk/Lib/sparse/sparsetools/numpy.i =================================================================== --- trunk/Lib/sparse/sparsetools/numpy.i 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/numpy.i 2007-01-06 06:34:41 UTC (rev 2496) @@ -0,0 +1,563 @@ +/* -*- C -*- (not really, but good for syntax highlighting) */ +%{ +#ifndef SWIG_FILE_WITH_INIT +# define NO_IMPORT_ARRAY +#endif +#include "stdio.h" +#include + +/* The following code originally appeared in enthought/kiva/agg/src/numeric.i, + * author unknown. It was translated from C++ to C by John Hunter. Bill + * Spotz has modified it slightly to fix some minor bugs, add some comments + * and some functionality. + */ + +/* Macros to extract array attributes. + */ +#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) +#define array_type(a) (int)(PyArray_TYPE(a)) +#define array_dimensions(a) (((PyArrayObject *)a)->nd) +#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) +#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) + +/* Given a PyObject, return a string describing its type. + */ +char* pytype_string(PyObject* py_obj) { + if (py_obj == NULL ) return "C NULL value"; + if (PyCallable_Check(py_obj)) return "callable" ; + if (PyString_Check( py_obj)) return "string" ; + if (PyInt_Check( py_obj)) return "int" ; + if (PyFloat_Check( py_obj)) return "float" ; + if (PyDict_Check( py_obj)) return "dict" ; + if (PyList_Check( py_obj)) return "list" ; + if (PyTuple_Check( py_obj)) return "tuple" ; + if (PyFile_Check( py_obj)) return "file" ; + if (PyModule_Check( py_obj)) return "module" ; + if (PyInstance_Check(py_obj)) return "instance" ; + + return "unkown type"; +} + +/* Given a Numeric typecode, return a string describing the type. + */ +char* typecode_string(int typecode) { + char* type_names[20] = {"char","unsigned byte","byte","short", + "unsigned short","int","unsigned int","long", + "float","double","complex float","complex double", + "object","ntype","unkown"}; + return type_names[typecode]; +} + +/* Make sure input has correct numeric type. Allow character and byte + * to match. Also allow int and long to match. + */ +int type_match(int actual_type, int desired_type) { + return PyArray_EquivTypenums(actual_type, desired_type); +} + +/* Given a PyObject pointer, cast it to a PyArrayObject pointer if + * legal. If not, set the python error string appropriately and + * return NULL./ + */ +PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) { + PyArrayObject* ary = NULL; + if (is_array(input) && (typecode == PyArray_NOTYPE || + PyArray_EquivTypenums(array_type(input), + typecode))) { + ary = (PyArrayObject*) input; + } + else if is_array(input) { + char* desired_type = typecode_string(typecode); + char* actual_type = typecode_string(array_type(input)); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. Array of type '%s' given", + desired_type, actual_type); + ary = NULL; + } + else { + char * desired_type = typecode_string(typecode); + char * actual_type = pytype_string(input); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. A %s was given", + desired_type, actual_type); + ary = NULL; + } + return ary; +} + +/* Convert the given PyObject to a Numeric array with the given + * typecode. On Success, return a valid PyArrayObject* with the + * correct type. On failure, the python error string will be set and + * the routine returns NULL. + */ +PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, + int* is_new_object) +{ + PyArrayObject* ary = NULL; + PyObject* py_obj; + if (is_array(input) && (typecode == PyArray_NOTYPE || type_match(array_type(input),typecode))) { + ary = (PyArrayObject*) input; + *is_new_object = 0; + } + else { + py_obj = PyArray_FromObject(input, typecode, 0, 0); + /* If NULL, PyArray_FromObject will have set python error value.*/ + ary = (PyArrayObject*) py_obj; + *is_new_object = 1; + } + return ary; +} + +/* Given a PyArrayObject, check to see if it is contiguous. If so, + * return the input pointer and flag it as not a new object. If it is + * not contiguous, create a new PyArrayObject using the original data, + * flag it as a new object and return the pointer. + */ +PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object, + int min_dims, int max_dims) +{ + PyArrayObject* result; + if (array_is_contiguous(ary)) { + result = ary; + *is_new_object = 0; + } + else { + result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary, + array_type(ary), + min_dims, + max_dims); + *is_new_object = 1; + } + return result; +} + +/* Convert a given PyObject to a contiguous PyArrayObject of the + * specified type. If the input object is not a contiguous + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ +PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, + &is_new1); + if (ary1) { + ary2 = make_contiguous(ary1, &is_new2, 0, 0); + if ( is_new1 && is_new2) { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; +} + +/* Test whether a python object is contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ +int require_contiguous(PyArrayObject* ary) { + int contiguous = 1; + if (!array_is_contiguous(ary)) { + PyErr_SetString(PyExc_TypeError, "Array must be contiguous. A discontiguous array was given"); + contiguous = 0; + } + return contiguous; +} + +/* Require the given PyArrayObject to have a specified number of + * dimensions. If the array has the specified number of dimensions, + * return 1. Otherwise, set the python error string and return 0. + */ +int require_dimensions(PyArrayObject* ary, int exact_dimensions) { + int success = 1; + if (array_dimensions(ary) != exact_dimensions) { + PyErr_Format(PyExc_TypeError, + "Array must be have %d dimensions. Given array has %d dimensions", + exact_dimensions, array_dimensions(ary)); + success = 0; + } + return success; +} + +/* Require the given PyArrayObject to have one of a list of specified + * number of dimensions. If the array has one of the specified number + * of dimensions, return 1. Otherwise, set the python error string + * and return 0. + */ +int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n) { + int success = 0; + int i; + char dims_str[255] = ""; + char s[255]; + for (i = 0; i < n && !success; i++) { + if (array_dimensions(ary) == exact_dimensions[i]) { + success = 1; + } + } + if (!success) { + for (i = 0; i < n-1; i++) { + sprintf(s, "%d, ", exact_dimensions[i]); + strcat(dims_str,s); + } + sprintf(s, " or %d", exact_dimensions[n-1]); + strcat(dims_str,s); + PyErr_Format(PyExc_TypeError, + "Array must be have %s dimensions. Given array has %d dimensions", + dims_str, array_dimensions(ary)); + } + return success; +} + +/* Require the given PyArrayObject to have a specified shape. If the + * array has the specified shape, return 1. Otherwise, set the python + * error string and return 0. + */ +int require_size(PyArrayObject* ary, int* size, int n) { + int i; + int success = 1; + int len; + char desired_dims[255] = "["; + char s[255]; + char actual_dims[255] = "["; + for(i=0; i < n;i++) { + if (size[i] != -1 && size[i] != array_size(ary,i)) { + success = 0; + } + } + if (!success) { + for (i = 0; i < n; i++) { + if (size[i] == -1) { + sprintf(s, "*,"); + } + else + { + sprintf(s, "%d,", size[i]); + } + strcat(desired_dims,s); + } + len = strlen(desired_dims); + desired_dims[len-1] = ']'; + for (i = 0; i < n; i++) { + sprintf(s, "%d,", array_size(ary,i)); + strcat(actual_dims,s); + } + len = strlen(actual_dims); + actual_dims[len-1] = ']'; + PyErr_Format(PyExc_TypeError, + "Array must be have shape of %s. Given array has shape of %s", + desired_dims, actual_dims); + } + return success; +} +/* End John Hunter translation (with modifications by Bill Spotz) */ + +%} + +/* TYPEMAP_IN macros + * + * This family of typemaps allows pure input C arguments of the form + * + * (type* IN_ARRAY1, int DIM1) + * (type* IN_ARRAY2, int DIM1, int DIM2) + * + * where "type" is any type supported by the Numeric module, to be + * called in python with an argument list of a single array (or any + * python object that can be passed to the Numeric.array constructor + * to produce an arrayof te specified shape). This can be applied to + * a existing functions using the %apply directive: + * + * %apply (double* IN_ARRAY1, int DIM1) {double* series, int length} + * %apply (double* IN_ARRAY2, int DIM1, int DIM2) {double* mx, int rows, int cols} + * double sum(double* series, int length); + * double max(double* mx, int rows, int cols); + * + * or with + * + * double sum(double* IN_ARRAY1, int DIM1); + * double max(double* IN_ARRAY2, int DIM1, int DIM2); + */ + +/* One dimensional input arrays */ +%define TYPEMAP_IN1(type,typecode) + %typemap(in) type* IN_ARRAY1 (PyArrayObject* array=NULL, int is_new_object) { + int size[1] = {-1}; + array = obj_to_array_contiguous_allow_conversion($input, typecode, &is_new_object); + if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; + $1 = (type*) array->data; +} +%typemap(freearg) type* IN_ARRAY1 { + if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +} +%enddef + +/* Define concrete examples of the TYPEMAP_IN1 macros */ +TYPEMAP_IN1(char, PyArray_CHAR ) +TYPEMAP_IN1(unsigned char, PyArray_UBYTE ) +TYPEMAP_IN1(signed char, PyArray_SBYTE ) +TYPEMAP_IN1(short, PyArray_SHORT ) +TYPEMAP_IN1(int, PyArray_INT ) +TYPEMAP_IN1(long, PyArray_LONG ) +TYPEMAP_IN1(float, PyArray_FLOAT ) +TYPEMAP_IN1(double, PyArray_DOUBLE) +TYPEMAP_IN1(long double, PyArray_LONGDOUBLE) +TYPEMAP_IN1(npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_IN1(npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_IN1(npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_IN1(const char, PyArray_CHAR ) +TYPEMAP_IN1(const unsigned char, PyArray_UBYTE ) +TYPEMAP_IN1(const signed char, PyArray_SBYTE ) +TYPEMAP_IN1(const short, PyArray_SHORT ) +TYPEMAP_IN1(const int, PyArray_INT ) +TYPEMAP_IN1(const long, PyArray_LONG ) +TYPEMAP_IN1(const float, PyArray_FLOAT ) +TYPEMAP_IN1(const double, PyArray_DOUBLE) +TYPEMAP_IN1(const long double, PyArray_LONGDOUBLE) +TYPEMAP_IN1(const npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_IN1(const npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_IN1(const npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_IN1(PyObject, PyArray_OBJECT) + +#undef TYPEMAP_IN1 + + + + + /* Two dimensional input arrays */ +%define TYPEMAP_IN2(type,typecode) + %typemap(in) (type* IN_ARRAY2) + (PyArrayObject* array=NULL, int is_new_object) { + int size[2] = {-1,-1}; + array = obj_to_array_contiguous_allow_conversion($input, typecode, &is_new_object); + if (!array || !require_dimensions(array,2) || !require_size(array,size,1)) SWIG_fail; + $1 = (type*) array->data; +} +%typemap(freearg) (type* IN_ARRAY2) { + if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +} +%enddef + +/* Define concrete examples of the TYPEMAP_IN2 macros */ +TYPEMAP_IN2(char, PyArray_CHAR ) +TYPEMAP_IN2(unsigned char, PyArray_UBYTE ) +TYPEMAP_IN2(signed char, PyArray_SBYTE ) +TYPEMAP_IN2(short, PyArray_SHORT ) +TYPEMAP_IN2(int, PyArray_INT ) +TYPEMAP_IN2(long, PyArray_LONG ) +TYPEMAP_IN2(float, PyArray_FLOAT ) +TYPEMAP_IN2(double, PyArray_DOUBLE) +TYPEMAP_IN2(long double, PyArray_LONGDOUBLE) +TYPEMAP_IN2(npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_IN2(npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_IN2(npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_IN2(const char, PyArray_CHAR ) +TYPEMAP_IN2(const unsigned char, PyArray_UBYTE ) +TYPEMAP_IN2(const signed char, PyArray_SBYTE ) +TYPEMAP_IN2(const short, PyArray_SHORT ) +TYPEMAP_IN2(const int, PyArray_INT ) +TYPEMAP_IN2(const long, PyArray_LONG ) +TYPEMAP_IN2(const float, PyArray_FLOAT ) +TYPEMAP_IN2(const double, PyArray_DOUBLE) +TYPEMAP_IN2(const long double, PyArray_LONGDOUBLE) +TYPEMAP_IN2(const npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_IN2(const npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_IN2(const npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_IN2(PyObject, PyArray_OBJECT) + +#undef TYPEMAP_IN2 + + +/* TYPEMAP_INPLACE macros + * + * This family of typemaps allows input/output C arguments of the form + * + * (type* INPLACE_ARRAY1, int DIM1) + * (type* INPLACE_ARRAY2, int DIM1, int DIM2) + * + * where "type" is any type supported by the Numeric module, to be + * called in python with an argument list of a single contiguous + * Numeric array. This can be applied to an existing function using + * the %apply directive: + * + * %apply (double* INPLACE_ARRAY1, int DIM1) {double* series, int length} + * %apply (double* INPLACE_ARRAY2, int DIM1, int DIM2) {double* mx, int rows, int cols} + * void negate(double* series, int length); + * void normalize(double* mx, int rows, int cols); + * + * + * or with + * + * void sum(double* INPLACE_ARRAY1, int DIM1); + * void sum(double* INPLACE_ARRAY2, int DIM1, int DIM2); + */ + + /* One dimensional input/output arrays */ +%define TYPEMAP_INPLACE1(type,typecode) +%typemap(in) (type* INPLACE_ARRAY) (PyArrayObject* temp=NULL) { + int i; + temp = obj_to_array_no_conversion($input,typecode); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (type*) temp->data; +} +%enddef + +/* Define concrete examples of the TYPEMAP_INPLACE1 macro */ +TYPEMAP_INPLACE1(char, PyArray_CHAR ) +TYPEMAP_INPLACE1(unsigned char, PyArray_UBYTE ) +TYPEMAP_INPLACE1(signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE1(short, PyArray_SHORT ) +TYPEMAP_INPLACE1(int, PyArray_INT ) +TYPEMAP_INPLACE1(long, PyArray_LONG ) +TYPEMAP_INPLACE1(float, PyArray_FLOAT ) +TYPEMAP_INPLACE1(double, PyArray_DOUBLE) +TYPEMAP_INPLACE1(long double, PyArray_LONGDOUBLE) +TYPEMAP_INPLACE1(npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_INPLACE1(npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_INPLACE1(npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_INPLACE1(const char, PyArray_CHAR ) +TYPEMAP_INPLACE1(const unsigned char, PyArray_UBYTE ) +TYPEMAP_INPLACE1(const signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE1(const short, PyArray_SHORT ) +TYPEMAP_INPLACE1(const int, PyArray_INT ) +TYPEMAP_INPLACE1(const long, PyArray_LONG ) +TYPEMAP_INPLACE1(const float, PyArray_FLOAT ) +TYPEMAP_INPLACE1(const double, PyArray_DOUBLE) +TYPEMAP_INPLACE1(const long double, PyArray_LONGDOUBLE) +TYPEMAP_INPLACE1(const npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_INPLACE1(const npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_INPLACE1(const npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_INPLACE1(PyObject, PyArray_OBJECT) + +#undef TYPEMAP_INPLACE1 + + + + + + /* Two dimensional input/output arrays */ +%define TYPEMAP_INPLACE2(type,typecode) + %typemap(in) (type* INPLACE_ARRAY2) (PyArrayObject* temp=NULL) { + temp = obj_to_array_no_conversion($input,typecode); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (type*) temp->data; +} +%enddef + +/* Define concrete examples of the TYPEMAP_INPLACE2 macro */ +TYPEMAP_INPLACE2(char, PyArray_CHAR ) +TYPEMAP_INPLACE2(unsigned char, PyArray_UBYTE ) +TYPEMAP_INPLACE2(signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE2(short, PyArray_SHORT ) +TYPEMAP_INPLACE2(int, PyArray_INT ) +TYPEMAP_INPLACE2(long, PyArray_LONG ) +TYPEMAP_INPLACE2(float, PyArray_FLOAT ) +TYPEMAP_INPLACE2(double, PyArray_DOUBLE) +TYPEMAP_INPLACE2(long double, PyArray_LONGDOUBLE) +TYPEMAP_INPLACE2(npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_INPLACE2(npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_INPLACE2(npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_INPLACE2(const char, PyArray_CHAR ) +TYPEMAP_INPLACE2(const unsigned char, PyArray_UBYTE ) +TYPEMAP_INPLACE2(const signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE2(const short, PyArray_SHORT ) +TYPEMAP_INPLACE2(const int, PyArray_INT ) +TYPEMAP_INPLACE2(const long, PyArray_LONG ) +TYPEMAP_INPLACE2(const float, PyArray_FLOAT ) +TYPEMAP_INPLACE2(const double, PyArray_DOUBLE) +TYPEMAP_INPLACE2(const long double, PyArray_LONGDOUBLE) +TYPEMAP_INPLACE2(const npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_INPLACE2(const npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_INPLACE2(const npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_INPLACE2(PyObject, PyArray_OBJECT) + +#undef TYPEMAP_INPLACE2 + + + + +/* TYPEMAP_ARGOUT macros + * + * This family of typemaps allows output C arguments of the form + * + * (type* ARGOUT_ARRAY[ANY]) + * (type* ARGOUT_ARRAY[ANY][ANY]) + * + * where "type" is any type supported by the Numeric module, to be + * called in python with an argument list of a single contiguous + * Numeric array. This can be applied to an existing function using + * the %apply directive: + * + * %apply (double* ARGOUT_ARRAY[ANY] {double series, int length} + * %apply (double* ARGOUT_ARRAY[ANY][ANY]) {double* mx, int rows, int cols} + * void negate(double* series, int length); + * void normalize(double* mx, int rows, int cols); + * + * + * or with + * + * void sum(double* ARGOUT_ARRAY[ANY]); + * void sum(double* ARGOUT_ARRAY[ANY][ANY]); + */ + + /* One dimensional input/output arrays */ +%define TYPEMAP_ARGOUT1(type,typecode) +%typemap(in,numinputs=0) type ARGOUT_ARRAY[ANY] { + $1 = (type*) malloc($1_dim0*sizeof(type)); + if (!$1) { + PyErr_SetString(PyExc_RuntimeError, "Failed to allocate memory"); + SWIG_fail; + } +} +%typemap(argout) ARGOUT_ARRAY[ANY] { + int dimensions[1] = {$1_dim0}; + PyObject* outArray = PyArray_FromDimsAndData(1, dimensions, typecode, (char*)$1); +} +%enddef + +/* Define concrete examples of the TYPEMAP_ARGOUT1 macro */ +TYPEMAP_ARGOUT1(char, PyArray_CHAR ) +TYPEMAP_ARGOUT1(unsigned char, PyArray_UBYTE ) +TYPEMAP_ARGOUT1(signed char, PyArray_SBYTE ) +TYPEMAP_ARGOUT1(short, PyArray_SHORT ) +TYPEMAP_ARGOUT1(int, PyArray_INT ) +TYPEMAP_ARGOUT1(long, PyArray_LONG ) +TYPEMAP_ARGOUT1(float, PyArray_FLOAT ) +TYPEMAP_ARGOUT1(double, PyArray_DOUBLE) +TYPEMAP_ARGOUT1(long double, PyArray_LONGDOUBLE) +TYPEMAP_ARGOUT1(npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_ARGOUT1(npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_ARGOUT1(npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_ARGOUT1(PyObject, PyArray_OBJECT) + +#undef TYPEMAP_ARGOUT1 + + /* Two dimensional input/output arrays */ +%define TYPEMAP_ARGOUT2(type,typecode) + %typemap(in) (type* ARGOUT_ARRAY2, int DIM1, int DIM2) (PyArrayObject* temp=NULL) { + temp = obj_to_array_no_conversion($input,typecode); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (type*) temp->data; + $2 = temp->dimensions[0]; + $3 = temp->dimensions[1]; +} +%enddef + +/* Define concrete examples of the TYPEMAP_ARGOUT2 macro */ +TYPEMAP_ARGOUT2(char, PyArray_CHAR ) +TYPEMAP_ARGOUT2(unsigned char, PyArray_UBYTE ) +TYPEMAP_ARGOUT2(signed char, PyArray_SBYTE ) +TYPEMAP_ARGOUT2(short, PyArray_SHORT ) +TYPEMAP_ARGOUT2(int, PyArray_INT ) +TYPEMAP_ARGOUT2(long, PyArray_LONG ) +TYPEMAP_ARGOUT2(float, PyArray_FLOAT ) +TYPEMAP_ARGOUT2(double, PyArray_DOUBLE) +TYPEMAP_ARGOUT2(long double, PyArray_LONGDOUBLE) +TYPEMAP_ARGOUT2(npy_cfloat, PyArray_CFLOAT ) +TYPEMAP_ARGOUT2(npy_cdouble, PyArray_CDOUBLE) +TYPEMAP_ARGOUT2(npy_clongdouble, PyArray_CLONGDOUBLE) +TYPEMAP_ARGOUT2(PyObject, PyArray_OBJECT) + +#undef TYPEMAP_ARGOUT2 Added: trunk/Lib/sparse/sparsetools/sparsetools.h =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.h 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/sparsetools.h 2007-01-06 06:34:41 UTC (rev 2496) @@ -0,0 +1,863 @@ +#ifndef SPARSETOOLS_H +#define SPARSETOOLS_H + + +/* + * sparsetools.h + * A collection of CSR/CSC/COO matrix conversion and arithmetic functions. + * + * Authors: + * Nathan Bell + * + * Revisions: + * 01/06/2007 - initial inclusion into SciPy + * + */ + + + + +#include + + + + + +/* + * Return zero of the appropriate type + */ +template +T ZERO(){ + T temp = {0}; + return temp; +} + + + +/* + * Compute B = A for CSR matrix A, CSC matrix B + * + * Also, with the appropriate arguments can also be used to: + * - compute B = A^t for CSR matrix A, CSR matrix B + * - compute B = A^t for CSC matrix A, CSC matrix B + * - convert CSC->CSR + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * + * Output Arguments: + * vec Bp - row pointer + * vec Bj - column indices + * vec Bx - nonzeros + * + * Note: + * Output arrays Bp,Bj,Bx will be allocated within in the method + * + * Note: + * Input: column indices *are not* assumed to be in sorted order + * Output: row indices *will be* in sorted order + * + * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) + * + */ +template +void csrtocsc(const int n_row, + const int n_col, + const int Ap[], + const int Aj[], + const T Ax[], + std::vector* Bp, + std::vector* Bi, + std::vector* Bx) +{ + int NNZ = Ap[n_row]; + + *Bp = std::vector(n_col+1); + *Bi = std::vector(NNZ); + *Bx = std::vector(NNZ); + + std::vector nnz_per_col(n_col,0); //temp array + + //compute number of non-zero entries per column of A + for (int i = 0; i < NNZ; i++){ + nnz_per_col[Aj[i]]++; + } + + //cumsum the nnz_per_col to get Bp[] + for(int i = 0, cumsum = 0; i < n_col; i++){ + (*Bp)[i] = cumsum; + cumsum += nnz_per_col[i]; + nnz_per_col[i] = 0; //reset count + } + (*Bp)[n_col] = NNZ; + + for(int i = 0; i < n_row; i++){ + int row_start = Ap[i]; + int row_end = Ap[i+1]; + for(int j = row_start; j < row_end; j++){ + int col = Aj[j]; + int k = (*Bp)[col] + nnz_per_col[col]; + + (*Bi)[k] = i; + (*Bx)[k] = Ax[j]; + + nnz_per_col[col]++; + } + } +} + + + + +/* + * Compute B = A for CSR matrix A, COO matrix B + * + * Also, with the appropriate arguments can also be used to: + * - convert CSC->COO + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * + * Output Arguments: + * vec Bi - row indices + * vec Bj - column indices + * vec Bx - nonzeros + * + * Note: + * Output arrays Bi,Bj,Bx will be allocated within in the method + * + * Note: + * Complexity: Linear. + * + */ +template +void csrtocoo(const int n_row, + const int n_col, + const int Ap [], + const int Aj[], + const T Ax[], + std::vector* Bi, + std::vector* Bj, + std::vector* Bx) +{ + for(int i = 0; i < n_row; i++){ + int row_start = Ap[i]; + int row_end = Ap[i+1]; + for(int jj = row_start; jj < row_end; jj++){ + Bi->push_back(i); + Bj->push_back(Aj[jj]); + Bx->push_back(Ax[jj]); + } + } +} + + + +/* + * Compute C = A*B for CSR matrices A,B + * + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in B (hence C is n_row by n_col) + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * int Bp[?] - row pointer + * int Bj[nnz(B)] - column indices + * T Bx[nnz(B)] - nonzeros + * Output Arguments: + * vec Cp - row pointer + * vec Cj - column indices + * vec Cx - nonzeros + * + * Note: + * Output arrays Cp,Cj, and Cx will be allocated within in the method + * + * Note: + * Input: A and B column indices *are not* assumed to be in sorted order + * Output: C column indices *are not* assumed to be in sorted order + * Cx will not contain any zero entries + * + * Complexity: O(n_row*K^2 + max(n_row,n_col)) + * where K is the maximum nnz in a row of A + * and column of B. + * + * + * This implementation closely follows the SMMP algorithm: + * + * "Sparse Matrix Multiplication Package (SMMP)" + * Randolph E. Bank and Craig C. Douglas + * + * http://citeseer.ist.psu.edu/445062.html + * http://www.mgnet.org/~douglas/ccd-codes.html + * + */ +template +void csrmucsr(const int n_row, + const int n_col, + const int Ap [], + const int Aj[], + const T Ax[], + const int Bp[], + const int Bj[], + const T Bx[], + std::vector* Cp, + std::vector* Cj, + std::vector* Cx) +{ + *Cp = std::vector(n_row+1,0); + Cj->clear(); + Cx->clear(); + + const T zero = ZERO(); + + std::vector index(n_col,-1); + std::vector sums(n_col,zero); + + for(int i = 0; i < n_row; i++){ + int istart = -1; + int length = 0; + + for(int jj = Ap[i]; jj < Ap[i+1]; jj++){ + int j = Aj[jj]; + for(int kk = Bp[j]; kk < Bp[j+1]; kk++){ + int k = Bj[kk]; + + sums[k] += Ax[jj]*Bx[kk]; + + if(index[k] == -1){ + index[k] = istart; + istart = k; + length++; + } + } + } + + for(int jj = 0; jj < length; jj++){ + if(sums[istart] != zero){ + Cj->push_back(istart); + Cx->push_back(sums[istart]); + } + + int temp = istart; + istart = index[istart]; + + index[temp] = -1; //clear arrays + sums[temp] = zero; + } + + (*Cp)[i+1] = Cx->size(); + } +} + + + + +/* + * Compute C = A+B for CSR matrices A,B + * + * + * Input Arguments: + * int n_row - number of rows in A (and B) + * int n_col - number of columns in A (and B) + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * int Bp[?] - row pointer + * int Bj[nnz(B)] - column indices + * T Bx[nnz(B)] - nonzeros + * Output Arguments: + * vec Cp - row pointer + * vec Cj - column indices + * vec Cx - nonzeros + * + * Note: + * Output arrays Cp,Cj, and Cx will be allocated within in the method + * + * Note: + * Input: A and B column indices *are not* assumed to be in sorted order + * Output: C column indices *are not* assumed to be in sorted order + * Cx will not contain any zero entries + * + */ +template +void csrplcsr(const int n_row, + const int n_col, + const int Ap[], + const int Aj[], + const T Ax[], + const int Bp[], + const int Bj[], + const T Bx[], + std::vector* Cp, + std::vector* Cj, + std::vector * Cx) +{ + + *Cp = std::vector(n_row+1,0); + Cj->clear(); + Cx->clear(); + + const T zero = ZERO(); + + std::vector index(n_col,-1); + std::vector sums(n_col,zero); + + for(int i = 0; i < n_row; i++){ + int istart = -1; + int length = 0; + + //add a row of A to sums + for(int jj = Ap[i]; jj < Ap[i+1]; jj++){ + int j = Aj[jj]; + sums[j] += Ax[jj]; + + if(index[j] == -1){ + index[j] = istart; + istart = j; + length++; + } + } + + //add a row of B to sums + for(int jj = Bp[i]; jj < Bp[i+1]; jj++){ + int j = Bj[jj]; + sums[j] += Bx[jj]; + + if(index[j] == -1){ + index[j] = istart; + istart = j; + length++; + } + } + + + for(int jj = 0; jj < length; jj++){ + if(sums[istart] != zero){ + Cj->push_back(istart); + Cx->push_back(sums[istart]); + } + + int temp = istart; + istart = index[istart]; + + index[temp] = -1; + sums[temp] = zero; + } + + (*Cp)[i+1] = Cx->size(); + } +} + +/* + * Compute C = A (elmul) B for CSR matrices A,B + * + * (elmul) - elementwise multiplication + * + * Input Arguments: + * int n_row - number of rows in A (and B) + * int n_col - number of columns in A (and B) + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * int Bp[?] - row pointer + * int Bj[nnz(B)] - column indices + * T Bx[nnz(B)] - nonzeros + * Output Arguments: + * vec Cp - row pointer + * vec Cj - column indices + * vec Cx - nonzeros + * + * Note: + * Output arrays Cp,Cj, and Cx will be allocated within in the method + * + * Note: + * Input: A and B column indices *are not* assumed to be in sorted order + * Output: C column indices *are not* assumed to be in sorted order + * Cx will not contain any zero entries + * + */ +template +void csrelmulcsr(const int n_row, + const int n_col, + const int Ap [], + const int Aj[], + const T Ax[], + const int Bp[], + const int Bj[], + const T Bx[], + std::vector* Cp, + std::vector* Cj, + std::vector* Cx) +{ + *Cp = std::vector(n_row+1,0); + Cj->clear(); + Cx->clear(); + + const T zero = ZERO(); + + std::vector index(n_col,-1); + std::vector A_row(n_col,zero); + std::vector B_row(n_col,zero); + + for(int i = 0; i < n_row; i++){ + int istart = -1; + int length = 0; + + //add a row of A to A_row + for(int jj = Ap[i]; jj < Ap[i+1]; jj++){ + int j = Aj[jj]; + + A_row[j] += Ax[jj]; + + if(index[j] == -1){ + index[j] = istart; + istart = j; + length++; + } + } + + //add a row of B to B_row + for(int jj = Bp[i]; jj < Bp[i+1]; jj++){ + int j = Bj[jj]; + + B_row[j] += Bx[jj]; + + if(index[j] == -1){ + index[j] = istart; + istart = j; + length++; + } + } + + + for(int jj = 0; jj < length; jj++){ + T prod = A_row[istart] * B_row[istart]; + + if(prod != zero){ + Cj->push_back(istart); + Cx->push_back(prod); + } + + int temp = istart; + istart = index[istart]; + + index[temp] = -1; + A_row[temp] = zero; + B_row[temp] = zero; + } + + (*Cp)[i+1] = Cx->size(); + } +} + + +/* + * Compute B = A for COO matrix A, CSR matrix B + * + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int Ai[nnz(A)] - row indices + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * Output Arguments: + * vec Bp - row pointer + * vec Bj - column indices + * vec Bx - nonzeros + * + * Note: + * Output arrays Bp,Bj,Bx will be allocated within in the method + * + * Note: + * Input: row and column indices *are not* assumed to be ordered + * duplicate (i,j) entries will be summed together + * + * Output: CSR column indices *will be* in sorted order + * + * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) + * + */ +template +void cootocsr(const int n_row, + const int n_col, + const int NNZ, + const int Ai[], + const int Aj[], + const T Ax[], + std::vector* Bp, + std::vector* Bj, + std::vector* Bx) +{ + std::vector tempBp(n_row+1,0); + std::vector tempBj(NNZ); + std::vector tempBx(NNZ); + + std::vector nnz_per_row(n_row,0); //temp array + + //compute nnz per row, then compute Bp + for(int i = 0; i < NNZ; i++){ + nnz_per_row[Ai[i]]++; + } + for(int i = 0, cumsum = 0; i < n_row; i++){ + tempBp[i] = cumsum; + cumsum += nnz_per_row[i]; + nnz_per_row[i] = 0; //reset count + } + tempBp[n_row] = NNZ; + + + //write Aj,Ax into tempBj,tempBx + for(int i = 0; i < NNZ; i++){ + int row = Ai[i]; + int n = tempBp[row] + nnz_per_row[row]; + + tempBj[n] = Aj[i]; + tempBx[n] = Ax[i]; + + nnz_per_row[row]++; + } + //now tempBp,tempBj,tempBx form a CSR representation (with duplicates) + + + //use (tempB + 0) to sum duplicates + std::vector Xp(n_row+1,0); //row pointer for an empty matrix + + csrplcsr(n_row,n_col, + &tempBp[0],&tempBj[0],&tempBx[0], + &Xp[0],NULL,NULL, + Bp,Bj,Bx); +} + + + + + +/* + * Compute Y = A*X for CSR matrix A and dense vectors X,Y + * + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[n_col] - nonzeros + * T Xx[n_col] - nonzeros + * + * Output Arguments: + * vec Yx - nonzeros (real part) + * + * Note: + * Output array Xx will be allocated within in the method + * + * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) + * + */ +template +void csrmux(const int n_row, + const int n_col, + const int Ap [], + const int Aj[], + const T Ax[], + const T Xx[], + std::vector* Yx) +{ + const T zero = ZERO(); + + *Yx = std::vector(n_row,zero); + + for(int i = 0; i < n_row; i++){ + int row_start = Ap[i]; + int row_end = Ap[i+1]; + + T& Yx_i = (*Yx)[i]; + for(int jj = row_start; jj < row_end; jj++){ + Yx_i += Ax[jj] * Xx[Aj[jj]]; + } + } +} + + + +/* + * Compute Y = A*X for CSC matrix A and dense vectors X,Y + * + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int Ap[n_row+1] - column pointer + * int Ai[nnz(A)] - row indices + * T Ax[n_col] - nonzeros (real part) + * T Xx[n_col] - nonzeros (real part) + * bool do_complex - switch scalar/complex modes + * + * Output Arguments: + * vec Yx - nonzeros (real part) + * + * Note: + * Output arrays Xx will be allocated within in the method + * + * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) + * + */ +template +void cscmux(const int n_row, + const int n_col, + const int Ap[], + const int Ai[], + const T Ax[], + const T Xx[], + std::vector* Yx) +{ + const T zero = ZERO(); + + *Yx = std::vector(n_row,zero); + + for(int j = 0; j < n_col; j++){ + int col_start = Ap[j]; + int col_end = Ap[j+1]; + + for(int ii = col_start; ii < col_end; ii++){ + int row = Ai[ii]; + (*Yx)[row] += Ax[ii] * Xx[j]; + } + } +} + + + + +/* + * Construct CSC matrix A from diagonals + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int n_diags - number of diagonals + * int diags_indx[n_diags] - where to place each diagonal + * T diags[n_diags][min(n_row,n_col)] - diagonals + * + * Output Arguments: + * vec Ap - row pointer + * vec Aj - column indices + * vec Ax - nonzeros + * + * Note: + * Output arrays Ap,Aj,Ax will be allocated within in the method + * + * Note: + * Output: row indices are not in sorted order + * + * Complexity: Linear + * + */ +template +void spdiags(const int n_row, + const int n_col, + const int n_diag, + const int offsets[], + const T diags[], + std::vector * Ap, + std::vector * Ai, + std::vector * Ax) +{ + const int diags_length = std::min(n_row,n_col); + Ap->push_back(0); + + for(int i = 0; i < n_col; i++){ + for(int j = 0; j < n_diag; j++){ + if(offsets[j] <= 0){ //sub-diagonal + int row = i - offsets[j]; + if (row >= n_row){ continue; } + + Ai->push_back(row); + Ax->push_back(diags[j*diags_length + i]); + + } else { //super-diagonal + int row = i - offsets[j]; + if (row < 0 || row >= n_row){ continue; } + + Ai->push_back(row); + Ax->push_back(diags[j*diags_length + row]); + } + } + Ap->push_back(Ai->size()); + } +} + + + +/* + * Compute M = A for CSR matrix A, dense matrix M + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * T Mx[n_row*n_col] - dense matrix + * + * Note: + * Output arrays Mx are assumed to be allocated and + * initialized to 0 by the caller. + * + */ +template +void csrtodense(const int n_row, + const int n_col, + const int Ap[], + const int Aj[], + const T Ax[], + T Mx[]) +{ + int row_base = 0; + for(int i = 0; i < n_row; i++){ + int row_start = Ap[i]; + int row_end = Ap[i+1]; + for(int jj = row_start; jj < row_end; jj++){ + int j = Aj[jj]; + + Mx[row_base + j] = Ax[jj]; + } + row_base += n_col; + } +} + + + +/* + * Compute A = M for CSR matrix A, dense matrix M + * + * Input Arguments: + * int n_row - number of rows in A + * int n_col - number of columns in A + * T Mx[n_row*n_col] - dense matrix + * int Ap[n_row+1] - row pointer + * int Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * + * Note: + * Output arrays Ap,Aj,Ax will be allocated within the method + * + */ +template +void densetocsr(const int n_row, + const int n_col, + const T Mx[], + std::vector* Ap, + std::vector* Aj, + std::vector* Ax) +{ + const T zero = ZERO(); + const T* x_ptr = Mx; + + Ap->push_back(0); + for(int i = 0; i < n_row; i++){ + for(int j = 0; j < n_col; j++){ + if(*x_ptr != zero){ + Aj->push_back(j); + Ax->push_back(*x_ptr); + } + x_ptr++; + } + Ap->push_back(Aj->size()); + } +} + + + +/* + * Derived methods + */ +template +void csctocsr(const int n_row, + const int n_col, + const int Ap[], + const int Ai[], + const T Ax[], + std::vector* Bp, + std::vector* Bj, + std::vector* Bx) +{ csrtocsc(n_col,n_row,Ap,Ai,Ax,Bp,Bj,Bx); } + +template +void csctocoo(const int n_row, + const int n_col, + const int Ap[], + const int Ai[], + const T Ax[], + std::vector* Bi, + std::vector* Bj, + std::vector* Bx) +{ csrtocoo(n_col,n_row,Ap,Ai,Ax,Bj,Bi,Bx); } + +template +void cscmucsc(const int n_row, + const int n_col, + const int Ap [], + const int Ai[], + const T Ax[], + const int Bp[], + const int Bi[], + const T Bx[], + std::vector* Cp, + std::vector* Ci, + std::vector * Cx) +{ csrmucsr(n_col,n_row,Bp,Bi,Bx,Ap,Ai,Ax,Cp,Ci,Cx); } + +template +void cscplcsc(const int n_row, + const int n_col, + const int Ap [], + const int Ai[], + const T Ax[], + const int Bp[], + const int Bi[], + const T Bx[], + std::vector* Cp, + std::vector* Ci, + std::vector* Cx) +{ csrplcsr(n_col,n_row,Ap,Ai,Ax,Bp,Bi,Bx,Cp,Ci,Cx); } + +template +void cscelmulcsc(const int n_row, + const int n_col, + const int Ap [], + const int Ai[], + const T Ax[], + const int Bp[], + const int Bi[], + const T Bx[], + std::vector* Cp, + std::vector* Ci, + std::vector* Cx) +{ csrelmulcsr(n_col,n_row,Ap,Ai,Ax,Bp,Bi,Bx,Cp,Ci,Cx); } + +template +void cootocsc(const int n_row, + const int n_col, + const int NNZ, + const int Ai[], + const int Aj[], + const T Ax[], + std::vector* Bp, + std::vector* Bi, + std::vector* Bx) +{ cootocsr(n_col,n_row,NNZ,Aj,Ai,Ax,Bp,Bi,Bx); } + + + +#endif Added: trunk/Lib/sparse/sparsetools/sparsetools.i =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.i 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/sparsetools.i 2007-01-06 06:34:41 UTC (rev 2496) @@ -0,0 +1,440 @@ +/* -*- C -*- (not really, but good for syntax highlighting) */ +%module sparsetools + + /* why does SWIG complain about int arrays? a typecheck is provided */ +#pragma SWIG nowarn=467 + +%{ +#define SWIG_FILE_WITH_INIT +#include "numpy/arrayobject.h" +#include "complex_ops.h" +#include "sparsetools.h" +%} + +%feature("autodoc", "1"); + +%include "numpy.i" + +%init %{ + import_array(); +%} + + +%{ +/*! + Appends @a what to @a where. On input, @a where need not to be a tuple, but on + return it always is. + + @par Revision history: + - 17.02.2005, c +*/ +PyObject *helper_appendToTuple( PyObject *where, PyObject *what ) { + PyObject *o2, *o3; + + if ((!where) || (where == Py_None)) { + where = what; + } else { + if (!PyTuple_Check( where )) { + o2 = where; + where = PyTuple_New( 1 ); + PyTuple_SetItem( where, 0, o2 ); + } + o3 = PyTuple_New( 1 ); + PyTuple_SetItem( o3, 0, what ); + o2 = where; + where = PySequence_Concat( o2, o3 ); + Py_DECREF( o2 ); + Py_DECREF( o3 ); + } + return where; +} + + + + +%} + + + +/* + * Use STL vectors for ARGOUTs + */ +%define VEC_ARRAY_ARGOUT( ctype, atype ) +%typemap( in, numinputs=0 ) std::vector* array_argout( std::vector* tmp ) { + tmp = new std::vector(); + $1 = tmp; +}; +%typemap( argout ) std::vector* array_argout { + int length = ($1)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_##atype); + memcpy(PyArray_DATA(obj),&((*($1))[0]),sizeof(ctype)*length); + delete $1; + $result = helper_appendToTuple( $result, (PyObject *)obj ); +}; +%enddef + + + + +%include "typemaps.i" + +%typemap(typecheck) int *, const int *, int [], const int [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_INT)) ? 1 : 0; +}; + +%typemap(typecheck) float *, const float *, float [], const float [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_FLOAT)) ? 1 : 0; +}; + +%typemap(typecheck) double *, const double *, double [], const double [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_DOUBLE)) ? 1 : 0; +}; + +%typemap(typecheck) long double *, const long double *, long double [], const long double [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_LONGDOUBLE)) ? 1 : 0; +}; + +%typemap(typecheck) npy_cfloat *, const npy_cfloat *, npy_cfloat [], const npy_cfloat [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_CFLOAT)) ? 1 : 0; +}; + +%typemap(typecheck) npy_cdouble *, const npy_cdouble *, npy_cdouble [], const npy_cdouble [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_CDOUBLE)) ? 1 : 0; +}; + +%typemap(typecheck) npy_clongdouble *, const npy_clongdouble *, npy_clongdouble [], const npy_clongdouble [] +{ + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_CLONGDOUBLE)) ? 1 : 0; +}; + + + + + + +/* + * IN types + */ +%apply int * IN_ARRAY1 { + const int Ap [ ], + const int Ai [ ], + const int Aj [ ], + const int Bp [ ], + const int Bi [ ], + const int Bj [ ], + const int offsets [ ] +}; + +%apply float * IN_ARRAY1 { + const float Ax [ ], + const float Bx [ ], + const float Xx [ ], + const float Yx [ ] +}; + +%apply double * IN_ARRAY1 { + const double Ax [ ], + const double Bx [ ], + const double Xx [ ], + const double Yx [ ] +}; + +%apply long double * IN_ARRAY1 { + const long double Ax [ ], + const long double Bx [ ], + const long double Xx [ ], + const long double Yx [ ] +}; + +%apply npy_cfloat * IN_ARRAY1 { + const npy_cfloat Ax [ ], + const npy_cfloat Bx [ ], + const npy_cfloat Xx [ ], + const npy_cfloat Yx [ ] +}; + +%apply npy_cdouble * IN_ARRAY1 { + const npy_cdouble Ax [ ], + const npy_cdouble Bx [ ], + const npy_cdouble Xx [ ], + const npy_cdouble Yx [ ] +}; + +%apply npy_clongdouble * IN_ARRAY1 { + const npy_clongdouble Ax [ ], + const npy_clongdouble Bx [ ], + const npy_clongdouble Xx [ ], + const npy_clongdouble Yx [ ] +}; + + +%apply float * IN_ARRAY2 { const float Mx[] } +%apply double * IN_ARRAY2 { const double Mx[] } +%apply long double * IN_ARRAY2 { const long double Mx[] } +%apply npy_cfloat * IN_ARRAY2 { const npy_cfloat Mx[] } +%apply npy_cdouble * IN_ARRAY2 { const npy_cdouble Mx[] } +%apply npy_clongdouble * IN_ARRAY2 { const npy_longdouble Mx[] } + + +%apply float * IN_ARRAY2 { const float diags[] } +%apply double * IN_ARRAY2 { const double diags[] } +%apply long double * IN_ARRAY2 { const long double diags[] } +%apply npy_cfloat * IN_ARRAY2 { const npy_cfloat diags[] } +%apply npy_cdouble * IN_ARRAY2 { const npy_cdouble diags[] } +%apply npy_clongdouble * IN_ARRAY2 { const npy_longdouble diags[] } + + + +/* + * OUT types + */ +VEC_ARRAY_ARGOUT( int, INT ) +%apply std::vector* array_argout { + std::vector* Ap, + std::vector* Ai, + std::vector* Aj, + std::vector* Bp, + std::vector* Bi, + std::vector* Bj, + std::vector* Cp, + std::vector* Ci, + std::vector* Cj +}; + +VEC_ARRAY_ARGOUT( float, FLOAT ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx +}; + +VEC_ARRAY_ARGOUT( double, DOUBLE ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx +}; + + +VEC_ARRAY_ARGOUT( long double, LONGDOUBLE ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx +}; + +VEC_ARRAY_ARGOUT( npy_cfloat, CFLOAT ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx +}; + + +VEC_ARRAY_ARGOUT( npy_cdouble, CDOUBLE ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx +}; + + +VEC_ARRAY_ARGOUT( npy_clongdouble, CLONGDOUBLE ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx +}; + + + +/* + * INOUT types + */ +%apply float * INPLACE_ARRAY2 { float Mx [] } +%apply double * INPLACE_ARRAY2 { double Mx [] } +%apply long double * INPLACE_ARRAY2 { long double Mx[] } +%apply npy_cfloat * INPLACE_ARRAY2 { npy_cfloat Mx[] } +%apply npy_cdouble * INPLACE_ARRAY2 { npy_cdouble Mx[] } +%apply npy_clongdouble * INPLACE_ARRAY2 { npy_longdouble Mx[] } + + + + + + +%include "sparsetools.h" + + + + /* + * Order may be important here, list float before double + */ + +/* + * CSR->CSC or CSC->CSR or CSR = CSR^T or CSC = CSC^T + */ +%template(csrtocsc) csrtocsc; +%template(csrtocsc) csrtocsc; +%template(csrtocsc) csrtocsc; +%template(csrtocsc) csrtocsc; +%template(csrtocsc) csrtocsc; +%template(csrtocsc) csrtocsc; + +%template(csctocsr) csctocsr; +%template(csctocsr) csctocsr; +%template(csctocsr) csctocsr; +%template(csctocsr) csctocsr; +%template(csctocsr) csctocsr; +%template(csctocsr) csctocsr; + + +/* + * CSR<->COO and CSC<->COO + */ +%template(csrtocoo) csrtocoo; +%template(csrtocoo) csrtocoo; +%template(csrtocoo) csrtocoo; +%template(csrtocoo) csrtocoo; +%template(csrtocoo) csrtocoo; +%template(csrtocoo) csrtocoo; + +%template(cootocsr) cootocsr; +%template(cootocsr) cootocsr; +%template(cootocsr) cootocsr; +%template(cootocsr) cootocsr; +%template(cootocsr) cootocsr; +%template(cootocsr) cootocsr; + +%template(csctocoo) csctocoo; +%template(csctocoo) csctocoo; +%template(csctocoo) csctocoo; +%template(csctocoo) csctocoo; +%template(csctocoo) csctocoo; +%template(csctocoo) csctocoo; + +%template(cootocsc) cootocsc; +%template(cootocsc) cootocsc; +%template(cootocsc) cootocsc; +%template(cootocsc) cootocsc; +%template(cootocsc) cootocsc; +%template(cootocsc) cootocsc; + + +/* + * CSR+CSR and CSC+CSC + */ +%template(csrplcsr) csrplcsr; +%template(csrplcsr) csrplcsr; +%template(csrplcsr) csrplcsr; +%template(csrplcsr) csrplcsr; +%template(csrplcsr) csrplcsr; +%template(csrplcsr) csrplcsr; + +%template(cscplcsc) cscplcsc; +%template(cscplcsc) cscplcsc; +%template(cscplcsc) cscplcsc; +%template(cscplcsc) cscplcsc; +%template(cscplcsc) cscplcsc; +%template(cscplcsc) cscplcsc; + + + +/* + * CSR*CSR and CSC*CSC + */ +%template(csrmucsr) csrmucsr; +%template(csrmucsr) csrmucsr; +%template(csrmucsr) csrmucsr; +%template(csrmucsr) csrmucsr; +%template(csrmucsr) csrmucsr; +%template(csrmucsr) csrmucsr; + +%template(cscmucsc) cscmucsc; +%template(cscmucsc) cscmucsc; +%template(cscmucsc) cscmucsc; +%template(cscmucsc) cscmucsc; +%template(cscmucsc) cscmucsc; +%template(cscmucsc) cscmucsc; + +/* + * CSR*x and CSC*x + */ +%template(csrmux) csrmux; +%template(csrmux) csrmux; +%template(csrmux) csrmux; +%template(csrmux) csrmux; +%template(csrmux) csrmux; +%template(csrmux) csrmux; + +%template(cscmux) cscmux; +%template(cscmux) cscmux; +%template(cscmux) cscmux; +%template(cscmux) cscmux; +%template(cscmux) cscmux; +%template(cscmux) cscmux; + + +/* + * CSR(elmul)CSR and CSC(elmul)CSC + */ +%template(csrelmulcsr) csrelmulcsr; +%template(csrelmulcsr) csrelmulcsr; +%template(csrelmulcsr) csrelmulcsr; +%template(csrelmulcsr) csrelmulcsr; +%template(csrelmulcsr) csrelmulcsr; +%template(csrelmulcsr) csrelmulcsr; + +%template(cscelmulcsc) cscelmulcsc; +%template(cscelmulcsc) cscelmulcsc; +%template(cscelmulcsc) cscelmulcsc; +%template(cscelmulcsc) cscelmulcsc; +%template(cscelmulcsc) cscelmulcsc; +%template(cscelmulcsc) cscelmulcsc; + + +/* + * spdiags->CSC + */ +%template(spdiags) spdiags; +%template(spdiags) spdiags; +%template(spdiags) spdiags; +%template(spdiags) spdiags; +%template(spdiags) spdiags; +%template(spdiags) spdiags; + + +/* + * CSR<->Dense + */ +%template(csrtodense) csrtodense; +%template(csrtodense) csrtodense; +%template(csrtodense) csrtodense; +%template(csrtodense) csrtodense; +%template(csrtodense) csrtodense; +%template(csrtodense) csrtodense; + +%template(densetocsr) densetocsr; +%template(densetocsr) densetocsr; +%template(densetocsr) densetocsr; +%template(densetocsr) densetocsr; +%template(densetocsr) densetocsr; +%template(densetocsr) densetocsr; Added: trunk/Lib/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-06 06:34:41 UTC (rev 2496) @@ -0,0 +1,398 @@ +# This file was created automatically by SWIG 1.3.28. +# Don't modify this file, modify the SWIG interface instead. +# This file is compatible with both classic and new-style classes. + +import _sparsetools +import new +new_instancemethod = new.instancemethod +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'PySwigObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + + + +def csrtocsc(*args): + """ + csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(float)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(double)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, long double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long double)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_clongdouble)> Bx) + """ + return _sparsetools.csrtocsc(*args) + +def csctocsr(*args): + """ + csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, long double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long double)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_clongdouble)> Bx) + """ + return _sparsetools.csctocsr(*args) + +def csrtocoo(*args): + """ + csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, long double Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long double)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_clongdouble)> Bx) + """ + return _sparsetools.csrtocoo(*args) + +def cootocsr(*args): + """ + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(float)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(double)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long double)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cfloat)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_cdouble)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_clongdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(npy_clongdouble)> Bx) + """ + return _sparsetools.cootocsr(*args) + +def csctocoo(*args): + """ + csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, long double Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(long double)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_clongdouble)> Bx) + """ + return _sparsetools.csctocoo(*args) + +def cootocsc(*args): + """ + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(float)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(double)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long double Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long double)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cfloat)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_cdouble)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_clongdouble Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(npy_clongdouble)> Bx) + """ + return _sparsetools.cootocsc(*args) + +def csrplcsr(*args): + """ + csrplcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csrplcsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(double)> Cx) + csrplcsr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long double)> Cx) + csrplcsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + int Bp, int Bj, npy_cfloat Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_cfloat)> Cx) + csrplcsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + int Bp, int Bj, npy_cdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_cdouble)> Cx) + csrplcsr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) + """ + return _sparsetools.csrplcsr(*args) + +def cscplcsc(*args): + """ + cscplcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + cscplcsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(double)> Cx) + cscplcsc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long double)> Cx) + cscplcsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + int Bp, int Bi, npy_cfloat Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_cfloat)> Cx) + cscplcsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + int Bp, int Bi, npy_cdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_cdouble)> Cx) + cscplcsc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, + int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) + """ + return _sparsetools.cscplcsc(*args) + +def csrmucsr(*args): + """ + csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(double)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long double)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + int Bp, int Bj, npy_cfloat Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_cfloat)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + int Bp, int Bj, npy_cdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_cdouble)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) + """ + return _sparsetools.csrmucsr(*args) + +def cscmucsc(*args): + """ + cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(double)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long double)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + int Bp, int Bi, npy_cfloat Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_cfloat)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + int Bp, int Bi, npy_cdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_cdouble)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, + int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) + """ + return _sparsetools.cscmucsc(*args) + +def csrmux(*args): + """ + csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, + std::vector<(float)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, + std::vector<(double)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Xx, std::vector<(long double)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + npy_cfloat Xx, std::vector<(npy_cfloat)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + npy_cdouble Xx, std::vector<(npy_cdouble)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) + """ + return _sparsetools.csrmux(*args) + +def cscmux(*args): + """ + cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, + std::vector<(float)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, + std::vector<(double)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, long double Ax, + long double Xx, std::vector<(long double)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + npy_cfloat Xx, std::vector<(npy_cfloat)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + npy_cdouble Xx, std::vector<(npy_cdouble)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, + npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) + """ + return _sparsetools.cscmux(*args) + +def csrelmulcsr(*args): + """ + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, + int Bj, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(float)> Cx) + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, + int Bj, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(double)> Cx) + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, long double Ax, + int Bp, int Bj, long double Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(long double)> Cx) + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + int Bp, int Bj, npy_cfloat Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_cfloat)> Cx) + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + int Bp, int Bj, npy_cdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_cdouble)> Cx) + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) + """ + return _sparsetools.csrelmulcsr(*args) + +def cscelmulcsc(*args): + """ + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, + int Bi, float Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(float)> Cx) + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, + int Bi, double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(double)> Cx) + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, long double Ax, + int Bp, int Bi, long double Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(long double)> Cx) + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + int Bp, int Bi, npy_cfloat Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_cfloat)> Cx) + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + int Bp, int Bi, npy_cdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_cdouble)> Cx) + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, + int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, + std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) + """ + return _sparsetools.cscelmulcsc(*args) + +def spdiags(*args): + """ + spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(float)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(double)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, long double diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(long double)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(npy_cfloat)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(npy_cdouble)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, npy_clongdouble diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(npy_clongdouble)> Ax) + """ + return _sparsetools.spdiags(*args) + +def csrtodense(*args): + """ + csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, long double Ax, + long double Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, + npy_cfloat Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, + npy_cdouble Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, + npy_clongdouble Mx) + """ + return _sparsetools.csrtodense(*args) + +def densetocsr(*args): + """ + densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(float)> Ax) + densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(double)> Ax) + densetocsr(int n_row, int n_col, long double Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(long double)> Ax) + densetocsr(int n_row, int n_col, npy_cfloat Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cfloat)> Ax) + densetocsr(int n_row, int n_col, npy_cdouble Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_cdouble)> Ax) + densetocsr(int n_row, int n_col, npy_clongdouble Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(npy_clongdouble)> Ax) + """ + return _sparsetools.densetocsr(*args) + Deleted: trunk/Lib/sparse/sparsetools/sparsetools.pyf.src =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.pyf.src 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/sparsetools.pyf.src 2007-01-06 06:34:41 UTC (rev 2496) @@ -1,240 +0,0 @@ -! -*- f90 -*- -python module sparsetools ! in - interface ! in :sparsetools - subroutine <_c>cscadd(n,a,rowa,ptra,nnzamax,b,rowb,ptrb,nnzbmax,c,rowc,ptrc,nnzcmax,ierr) ! in :sparsetools:dspblas.f - integer intent(hide),depend(ptra) :: n=(len(ptra)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - <_t> dimension(nnzbmax) :: b - integer dimension(nnzbmax),depend(nnzbmax) :: rowb - integer dimension(n + 1) :: ptrb - integer intent(hide),depend(b) :: nnzbmax=len(b) - <_t> intent(out), dimension(nnzcmax), depend(nnzcmax) :: c - integer intent(out),dimension(nnzcmax),depend(nnzcmax) :: rowc - integer intent(out),dimension(n + 1),depend(n) :: ptrc - integer intent(hide),depend(nnzamax,nnzbmax) :: nnzcmax=nnzamax+nnzbmax - integer intent(out) :: ierr - end subroutine <_c>cscadd - - subroutine <_c>cscmul(n,a,rowa,ptra,nnzamax,b,rowb,ptrb,nnzbmax,c,rowc,ptrc,nnzcmax,ierr) ! in :sparsetools:dspblas.f - integer intent(hide),depend(ptra) :: n=(len(ptra)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - <_t> dimension(nnzbmax) :: b - integer dimension(nnzbmax),depend(nnzbmax) :: rowb - integer dimension(n + 1) :: ptrb - integer intent(hide),depend(b) :: nnzbmax=len(b) - <_t> intent(out), dimension(nnzcmax), depend(nnzcmax) :: c - integer intent(out),dimension(nnzcmax),depend(nnzcmax) :: rowc - integer intent(out),dimension(n + 1),depend(n) :: ptrc - integer intent(hide),depend(nnzamax,nnzbmax) :: nnzcmax=nnzamax+nnzbmax - integer intent(out) :: ierr - end subroutine <_c>cscmul - - subroutine <_c>cscmux(a,rowa,ptra,nnzamax,ncol,x,mrow,y) ! in :sparsetools:dspblas.f - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(ncol + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - integer intent(hide),depend(ptra) :: ncol=(len(ptra)-1) - <_t> dimension(ncol),depend(ncol) :: x - integer intent(in) :: mrow - <_t> intent(out), dimension(mrow), depend(mrow) :: y - end subroutine <_c>cscmux - - subroutine <_c>csrmux(a,cola,ptra,nnzamax,ncol,x,mrow,y) ! in :sparsetools:dspblas.f - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: cola - integer dimension(mrow + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - integer intent(hide),depend(x) :: ncol=len(x) - <_t> dimension(ncol) :: x - integer intent(hide),depend(ptra) :: mrow=(len(ptra)-1) - <_t> intent(out),dimension(mrow),depend(mrow) :: y - end subroutine <_c>csrmux - - subroutine <_c>cscmucsr(m,k,n,a,rowa,ptra,nnzamax,b,colb,ptrb,nnzbmax,c,rowc,ptrc,nnzcmax,irow,kcol,ierr) ! in :sparsetools:dspblas.f - integer :: m - integer intent(hide),depend(ptra) :: k=(len(ptra)-1) - integer intent(hide),depend(ptrc) :: n=(len(ptrc)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(k + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - <_t> dimension(nnzbmax) :: b - integer dimension(nnzbmax),depend(nnzbmax) :: colb - integer dimension(k + 1),depend(k) :: ptrb - integer intent(hide),depend(b) :: nnzbmax=len(b) - <_t> intent(in, out), dimension(nnzcmax) :: c - integer intent(in, out), dimension(nnzcmax),depend(nnzcmax) :: rowc - integer intent(in, out), dimension(n + 1) :: ptrc - integer intent(hide), depend(c) :: nnzcmax=len(c) - integer intent(in, out) :: irow - integer intent(in, out) :: kcol - integer intent(in, out) :: ierr - end subroutine <_c>cscmucsr - - subroutine <_c>csrmucsc(m,n,a,rowa,ptra,nnzamax,b,colb,ptrb,nnzbmax,c,rowc,ptrc,nnzcmax,irow,kcol,ierr) ! in :sparsetools:dspblas.f - integer intent(hide), depend(ptra) :: m=(len(ptra)-1) - integer intent(hide), depend(ptrb) :: n=(len(ptrb)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax), depend(nnzamax) :: rowa - integer dimension(m + 1) :: ptra - integer intent(hide), depend(a) :: nnzamax=len(a) - <_t> dimension(nnzbmax) :: b - integer dimension(nnzbmax),depend(nnzbmax) :: colb - integer dimension(n + 1) :: ptrb - integer intent(hide), depend(b) :: nnzbmax=len(b) - <_t> intent(in,out),dimension(nnzcmax) :: c - integer intent(in, out), dimension(nnzcmax),depend(nnzcmax) :: rowc - integer intent(in, out), dimension(n + 1), depend(n) :: ptrc - integer intent(hide), depend(c) :: nnzcmax=len(c) - integer intent(in, out) :: irow - integer intent(in, out) :: kcol - integer intent(in, out) :: ierr - end subroutine <_c>csrmucsc - - subroutine <_c>cscmucsc(m,k,n,a,rowa,ptra,nnzamax,b,colb,ptrb,nnzbmax,c,rowc,ptrc,nnzcmax,irow,kcol,ierr) ! in :sparsetools:dspblas.f - integer :: m - integer intent(hide),depend(ptra) :: k=(len(ptra)-1) - integer intent(hide),depend(ptrb) :: n=(len(ptrb)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(k + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - <_t> dimension(nnzbmax) :: b - integer dimension(nnzbmax),depend(nnzbmax) :: colb - integer dimension(n + 1) :: ptrb - integer intent(hide), depend(b) :: nnzbmax=len(b) - <_t> intent(in, out),dimension(nnzcmax) :: c - integer intent(in, out), dimension(nnzcmax),depend(nnzcmax) :: rowc - integer intent(in, out), dimension(n + 1), depend(n) :: ptrc - integer intent(hide), depend(c) :: nnzcmax=len(c) - integer intent(in, out) :: irow - integer intent(in, out) :: kcol - integer intent(in, out) :: ierr - end subroutine <_c>cscmucsc - - subroutine <_c>transp(m,n,a,rowa,ptra,nnzamax,b,colb,ptrb) ! in :sparsetools:dspconv.f - integer intent(in) :: m - integer intent(hide), depend(ptra) :: n=(len(ptra)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide), depend(a) :: nnzamax=len(a) - <_t> intent(out),dimension(nnzamax),depend(nnzamax) :: b - integer intent(out), dimension(nnzamax),depend(nnzamax) :: colb - integer intent(out), dimension(m + 1), depend(m) :: ptrb - end subroutine <_c>transp - - subroutine <_c>cscgetel(a,rowa,ptra,nnzamax,n,row,col,ind,val) ! in :sparsetools:dspconv.f - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide), depend(a) :: nnzamax=len(a) - integer intent(hide), depend(ptra) :: n=(len(ptra)-1) - integer check((row >=0)) :: row - integer check(((col >= 0) && (col < n))), depend(n) :: col - integer intent(out) :: ind - <_t> intent(out) :: val - end subroutine <_c>cscgetel - - subroutine <_c>cscsetel(a,rowa,ptra,nnzamax,n,row,col,val) ! in :sparsetools:dspconv.f - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - integer intent(hide),depend(ptra) :: n=(len(ptra)-1) - integer :: row - integer :: col - <_t> :: val - end subroutine <_c>cscsetel - - subroutine <_c>cootocsc(n,vals,row,col,nnz,a,rowa,ptra,nnzamax,ierr) ! in :sparsetools:dspconv.f - integer intent(in) :: n - <_t> dimension(nnz) :: vals - integer dimension(nnz),depend(nnz) :: row - integer dimension(nnz),depend(nnz) :: col - integer intent(hide), depend(vals) :: nnz=len(vals) - <_t> intent(out), dimension(nnzamax), depend(nnzamax) :: a - integer intent(out), dimension(nnzamax),depend(nnzamax) :: rowa - integer intent(out), dimension(n + 1), depend(n) :: ptra - integer intent(hide), depend(nnz) :: nnzamax=nnz - integer intent(out) :: ierr - end subroutine <_c>cootocsc - - subroutine <_c>csctocoo(n, vals, row, col, a, rowa, ptra, nnzamax) - integer intent(hide),depend(ptra) :: n=(len(ptra)-1) - integer intent(in), dimension(n + 1) :: ptra - <_t> intent(in), dimension(nnzamax), depend(nnzamax) :: a - integer intent(hide), depend(rowa) :: nnzamax=len(rowa) - integer dimension(nnzamax),intent(in) :: rowa - integer dimension(ptra[n]),intent(out),depend(n,ptra) :: row,col - <_t> dimension(ptra[n]),intent(out),depend(n,ptra) :: vals - end subroutine <_c>csctocoo - - subroutine <_c>fulltocsc(m,n,fulla,a,rowa,ptra,nnzamax,irow,jcol,ierr) ! in :sparsetools:dspconv.f - integer intent(hide), depend(fulla) :: m=shape(fulla,0) - integer intent(hide), depend(fulla) :: n=shape(fulla,1) - <_t> dimension(m,n) :: fulla - <_t> intent(in,out),dimension(nnzamax) :: a - integer intent(in,out),dimension(nnzamax),depend(nnzamax) :: rowa - integer intent(in,out),dimension(n + 1),depend(n) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - integer intent(in,out) :: irow - integer intent(in,out) :: jcol - integer intent(in,out) :: ierr - end subroutine <_c>fulltocsc - - subroutine <_c>csctofull(m,n,fulla,a,rowa,ptra,nnzamax) ! in :sparsetools:dspconv.f - integer intent(in) :: m - integer intent(hide),depend(ptra) :: n = (len(ptra)-1) - <_t> intent(out), dimension(m,n), depend(m,n) :: fulla - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide), depend(a) :: nnzamax=len(a) - end subroutine <_c>csctofull - - subroutine <_c>cscextract(n,a,rowa,ptra,nnzamax,ibeg,iend,jbeg,jend,c,rowc,ptrc,nnzcmax,irow,jcol,ierr) ! in :sparsetools:dspconv.f - integer intent(hide),depend(ptra) :: n=(len(ptra)-1) - <_t> dimension(nnzamax) :: a - integer dimension(nnzamax),depend(nnzamax) :: rowa - integer dimension(n + 1) :: ptra - integer intent(hide),depend(a) :: nnzamax=len(a) - integer :: ibeg - integer :: iend - integer :: jbeg - integer :: jend - <_t> intent(in,out),dimension(nnzcmax) :: c - integer intent(in,out),dimension(nnzamax),depend(nnzamax) :: rowc - integer intent(in,out),dimension(jend-jbeg+1+1),depend(jbeg,jend) :: ptrc - integer intent(hide),depend(c) :: nnzcmax=len(c) - integer intent(in,out) :: irow - integer intent(in,out) :: jcol - integer intent(in,out) :: ierr - end subroutine <_c>cscextract - - subroutine <_c>diatocsc(m,n,diags,numdia,diasize,offsets,a,rowa,ptra,nzmax,ierr) - integer :: m - integer :: n - <_t> dimension(numdia, diasize) :: diags - integer intent(hide), depend(diags) :: numdia=shape(diags,0) - integer intent(hide), depend(diags) :: diasize=shape(diags,1) - integer dimension(numdia) :: offsets - <_t> intent(out), dimension(nzmax), depend(nzmax) :: a - integer intent(out), dimension(nzmax), depend(nzmax) :: rowa - integer intent(out), dimension(n+1), depend(n) :: ptra - integer intent(hide), depend(numdia,diasize,diags) :: nzmax=numdia*diasize - integer intent(out) :: ierr - end subroutine <_c>diatocsc - - end interface -end python module sparsetools - -! this file was auto-generated with f2py (version:2.39.235_1702). -! see http://cens.ioc.ee/projects/f2py2e/ Added: trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-06 06:34:41 UTC (rev 2496) @@ -0,0 +1,21677 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.28 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE + +#ifdef __cplusplus +template class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/* Python.h has to appear first */ +#include + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Python.h has to appear first */ +#include + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +#define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +/* Add PyObject_Del for old Pythons */ +#if PY_VERSION_HEX < 0x01060000 +#define PyObject_Del(op) PyMem_DEL((op)) +#endif +#ifndef PyObject_DEL +#define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +#define PyExc_StopIteration PyExc_RuntimeError +#define PyObject_GenericGetAttr 0 +#define Py_NotImplemented PyExc_RuntimeError +#endif + + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +#define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +#endif + +#if PY_VERSION_HEX < 0x02000000 +#define PySequence_Size PySequence_Length +#endif + + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_Format(PyExc_RuntimeError, mesg); + } +} + + + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + + +/*********************************************************************** + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * Author : David Beazley (beazley at cs.uchicago.edu) + ************************************************************************/ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) PySwigClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, (char *) msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, (char*) name, obj); + Py_DECREF(obj); +} + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN int +SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), min); + return 0; + } + } + if (!PyTuple_Check(args)) { + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + register int l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), min, l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), max, l); + return 0; + } else { + register int i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue(""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + + +/* PySwigClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; +} PySwigClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + PySwigClientData *data = (PySwigClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME PySwigClientData * +PySwigClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(obj); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); +#else + data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, (char *)"__new__"); + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + Py_INCREF(data->newargs); +#endif + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + return data; + } +} + +SWIGRUNTIME void +PySwigClientData_Del(PySwigClientData* data) +{ + Py_XDECREF(data->klass); + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== PySwigObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +} PySwigObject; + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_repr(PySwigObject *v) +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *hex = PySwigObject_hex(v); + PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); + Py_DECREF(hex); + if (v->next) { + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); + PyString_ConcatAndDel(&repr,nrep); + } + return repr; +} + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + PyObject *repr = PySwigObject_repr(v); + if (repr) { + fputs(PyString_AsString(repr), fp); + Py_DECREF(repr); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); + return type; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +SWIGRUNTIME PyObject * +PySwigObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +PySwigObject_dealloc(PyObject *v) +{ + PySwigObject *sobj = (PySwigObject *) v; + PyObject *next = sobj->next; + if (sobj->own) { + swig_type_info *ty = sobj->ty; + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + if (data->delargs) { + /* we need to create a temporal object to carry the destroy operation */ + PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + Py_XDECREF(res); + } else { + const char *name = SWIG_TypePrettyName(ty); +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); +#endif + } + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +PySwigObject_append(PyObject* v, PyObject* next) +{ + PySwigObject *sobj = (PySwigObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!PySwigObject_Check(next)) { + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +PySwigObject_next(PyObject* v) +#else +PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +PySwigObject_disown(PyObject *v) +#else +PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +PySwigObject_acquire(PyObject *v) +#else +PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +PySwigObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#else + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + PySwigObject *sobj = (PySwigObject *)v; + PyObject *obj = sobj->own ? Py_True : Py_False; + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + PySwigObject_acquire(v); + } else { + PySwigObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + PySwigObject_acquire(v,args); + } else { + PySwigObject_disown(v,args); + } +#endif + } + Py_INCREF(obj); + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +PySwigObject_getattr(PySwigObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +_PySwigObject_type(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + (char *)"PySwigObject", /* tp_name */ + sizeof(PySwigObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PySwigObject_dealloc, /* tp_dealloc */ + (printfunc)PySwigObject_print, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)PySwigObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)PySwigObject_compare, /* tp_compare */ + (reprfunc)PySwigObject_repr, /* tp_repr */ + &PySwigObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigObject_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* 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 */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + pyswigobject_type = tmp; + pyswigobject_type.ob_type = &PyType_Type; + type_init = 1; + } + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_New(void *ptr, swig_type_info *ty, int own) +{ + PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("", result, v->ty->name); + } else { + return PyString_FromFormat("", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->ty->name); + } else { + return PyString_FromString(v->ty->name); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); + return type; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == _PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PyObject *v) +{ + if (PySwigPacked_Check(v)) { + PySwigPacked *sobj = (PySwigPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +_PySwigPacked_type(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + (char *)"PySwigPacked", /* tp_name */ + sizeof(PySwigPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PySwigPacked_dealloc, /* tp_dealloc */ + (printfunc)PySwigPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)PySwigPacked_compare, /* tp_compare */ + (reprfunc)PySwigPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* 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 */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + pyswigpacked_type = tmp; + pyswigpacked_type.ob_type = &PyType_Type; + type_init = 1; + } + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (PySwigPacked_Check(obj)) { + PySwigPacked *sobj = (PySwigPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return PyString_FromString("this"); +} + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +SWIGRUNTIME PySwigObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + if (PySwigObject_Check(pyobj)) { + return (PySwigObject *) pyobj; + } else { + PyObject *obj = 0; +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } +#ifdef PyWeakref_CheckProxy + else if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + if (!obj) { + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !PySwigObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + PySwigObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (PySwigObject *)obj; + } +} + + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own) { + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + if (!obj) return SWIG_ERROR; + if (obj == Py_None) { + if (ptr) *ptr = 0; + return SWIG_OK; + } else { + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (PySwigObject *)sobj->next; + } else { + if (ptr) *ptr = SWIG_TypeCast(tc,vptr); + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) *own = sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + return SWIG_OK; + } else { + int res = SWIG_ERROR; + if (flags & SWIG_POINTER_IMPLICIT_CONV) { + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + } + return res; + } + } +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + + /* here we get the method pointer for callbacks */ + char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) { + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) return SWIG_ERROR; + } + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (!tc) return SWIG_ERROR; + *ptr = SWIG_TypeCast(tc,vptr); + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, whitout calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { + if (!ptr) { + return SWIG_Py_Void(); + } else { + int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + PyObject *robj = PySwigObject_New(ptr, type, own); + PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; + if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + if (inst) { + Py_DECREF(robj); + robj = inst; + } + } + return robj; + } +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +SWIG_Python_DestroyModule(void *vptr) +{ + swig_module_info *swig_module = (swig_module_info *) vptr; + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + PySwigClientData *data = (PySwigClientData *) ty->clientdata; + if (data) PySwigClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + PySwigObject *v = (PySwigObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : (char*)""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_char swig_types[0] +#define SWIGTYPE_p_npy_clongdouble swig_types[1] +#define SWIGTYPE_p_std__vectorTdouble_t swig_types[2] +#define SWIGTYPE_p_std__vectorTfloat_t swig_types[3] +#define SWIGTYPE_p_std__vectorTint_t swig_types[4] +#define SWIGTYPE_p_std__vectorTlong_double_t swig_types[5] +#define SWIGTYPE_p_std__vectorTnpy_cdouble_t swig_types[6] +#define SWIGTYPE_p_std__vectorTnpy_cfloat_t swig_types[7] +#define SWIGTYPE_p_std__vectorTnpy_clongdouble_t swig_types[8] +static swig_type_info *swig_types[10]; +static swig_module_info swig_module = {swig_types, 9, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#if (PY_VERSION_HEX <= 0x02000000) +# if !defined(SWIG_PYTHON_CLASSIC) +# warning "This python version probably requires to use swig with the '-classic' option" +# endif +#endif + +/*----------------------------------------------- + @(target):= _sparsetools.so + ------------------------------------------------*/ +#define SWIG_init init_sparsetools + +#define SWIG_name "_sparsetools" + +#define SWIGVERSION 0x010328 + + +#define SWIG_as_voidptr(a) const_cast(static_cast(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast(a)) + + +#include + + +namespace swig { + class PyObject_ptr { + protected: + PyObject *_obj; + + public: + PyObject_ptr() :_obj(0) + { + } + + PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj) + { + Py_XINCREF(_obj); + } + + PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj) + { + if (initial_ref) Py_XINCREF(_obj); + } + + PyObject_ptr & operator=(const PyObject_ptr& item) + { + Py_XINCREF(item._obj); + Py_XDECREF(_obj); + _obj = item._obj; + return *this; + } + + ~PyObject_ptr() + { + Py_XDECREF(_obj); + } + + operator PyObject *() const + { + return _obj; + } + + PyObject *operator->() const + { + return _obj; + } + }; +} + + +namespace swig { + struct PyObject_var : PyObject_ptr { + PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { } + + PyObject_var & operator = (PyObject* obj) + { + Py_XDECREF(_obj); + _obj = obj; + return *this; + } + }; +} + + +#define SWIG_FILE_WITH_INIT +#include "numpy/arrayobject.h" +#include "complex_ops.h" +#include "sparsetools.h" + + +#ifndef SWIG_FILE_WITH_INIT +# define NO_IMPORT_ARRAY +#endif +#include "stdio.h" +#include + +/* The following code originally appeared in enthought/kiva/agg/src/numeric.i, + * author unknown. It was translated from C++ to C by John Hunter. Bill + * Spotz has modified it slightly to fix some minor bugs, add some comments + * and some functionality. + */ + +/* Macros to extract array attributes. + */ +#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) +#define array_type(a) (int)(PyArray_TYPE(a)) +#define array_dimensions(a) (((PyArrayObject *)a)->nd) +#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) +#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) + +/* Given a PyObject, return a string describing its type. + */ +char* pytype_string(PyObject* py_obj) { + if (py_obj == NULL ) return "C NULL value"; + if (PyCallable_Check(py_obj)) return "callable" ; + if (PyString_Check( py_obj)) return "string" ; + if (PyInt_Check( py_obj)) return "int" ; + if (PyFloat_Check( py_obj)) return "float" ; + if (PyDict_Check( py_obj)) return "dict" ; + if (PyList_Check( py_obj)) return "list" ; + if (PyTuple_Check( py_obj)) return "tuple" ; + if (PyFile_Check( py_obj)) return "file" ; + if (PyModule_Check( py_obj)) return "module" ; + if (PyInstance_Check(py_obj)) return "instance" ; + + return "unkown type"; +} + +/* Given a Numeric typecode, return a string describing the type. + */ +char* typecode_string(int typecode) { + char* type_names[20] = {"char","unsigned byte","byte","short", + "unsigned short","int","unsigned int","long", + "float","double","complex float","complex double", + "object","ntype","unkown"}; + return type_names[typecode]; +} + +/* Make sure input has correct numeric type. Allow character and byte + * to match. Also allow int and long to match. + */ +int type_match(int actual_type, int desired_type) { + return PyArray_EquivTypenums(actual_type, desired_type); +} + +/* Given a PyObject pointer, cast it to a PyArrayObject pointer if + * legal. If not, set the python error string appropriately and + * return NULL./ + */ +PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) { + PyArrayObject* ary = NULL; + if (is_array(input) && (typecode == PyArray_NOTYPE || + PyArray_EquivTypenums(array_type(input), + typecode))) { + ary = (PyArrayObject*) input; + } + else if is_array(input) { + char* desired_type = typecode_string(typecode); + char* actual_type = typecode_string(array_type(input)); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. Array of type '%s' given", + desired_type, actual_type); + ary = NULL; + } + else { + char * desired_type = typecode_string(typecode); + char * actual_type = pytype_string(input); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. A %s was given", + desired_type, actual_type); + ary = NULL; + } + return ary; +} + +/* Convert the given PyObject to a Numeric array with the given + * typecode. On Success, return a valid PyArrayObject* with the + * correct type. On failure, the python error string will be set and + * the routine returns NULL. + */ +PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, + int* is_new_object) +{ + PyArrayObject* ary = NULL; + PyObject* py_obj; + if (is_array(input) && (typecode == PyArray_NOTYPE || type_match(array_type(input),typecode))) { + ary = (PyArrayObject*) input; + *is_new_object = 0; + } + else { + py_obj = PyArray_FromObject(input, typecode, 0, 0); + /* If NULL, PyArray_FromObject will have set python error value.*/ + ary = (PyArrayObject*) py_obj; + *is_new_object = 1; + } + return ary; +} + +/* Given a PyArrayObject, check to see if it is contiguous. If so, + * return the input pointer and flag it as not a new object. If it is + * not contiguous, create a new PyArrayObject using the original data, + * flag it as a new object and return the pointer. + */ +PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object, + int min_dims, int max_dims) +{ + PyArrayObject* result; + if (array_is_contiguous(ary)) { + result = ary; + *is_new_object = 0; + } + else { + result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary, + array_type(ary), + min_dims, + max_dims); + *is_new_object = 1; + } + return result; +} + +/* Convert a given PyObject to a contiguous PyArrayObject of the + * specified type. If the input object is not a contiguous + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ +PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, + &is_new1); + if (ary1) { + ary2 = make_contiguous(ary1, &is_new2, 0, 0); + if ( is_new1 && is_new2) { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; +} + +/* Test whether a python object is contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ +int require_contiguous(PyArrayObject* ary) { + int contiguous = 1; + if (!array_is_contiguous(ary)) { + PyErr_SetString(PyExc_TypeError, "Array must be contiguous. A discontiguous array was given"); + contiguous = 0; + } + return contiguous; +} + +/* Require the given PyArrayObject to have a specified number of + * dimensions. If the array has the specified number of dimensions, + * return 1. Otherwise, set the python error string and return 0. + */ +int require_dimensions(PyArrayObject* ary, int exact_dimensions) { + int success = 1; + if (array_dimensions(ary) != exact_dimensions) { + PyErr_Format(PyExc_TypeError, + "Array must be have %d dimensions. Given array has %d dimensions", + exact_dimensions, array_dimensions(ary)); + success = 0; + } + return success; +} + +/* Require the given PyArrayObject to have one of a list of specified + * number of dimensions. If the array has one of the specified number + * of dimensions, return 1. Otherwise, set the python error string + * and return 0. + */ +int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n) { + int success = 0; + int i; + char dims_str[255] = ""; + char s[255]; + for (i = 0; i < n && !success; i++) { + if (array_dimensions(ary) == exact_dimensions[i]) { + success = 1; + } + } + if (!success) { + for (i = 0; i < n-1; i++) { + sprintf(s, "%d, ", exact_dimensions[i]); + strcat(dims_str,s); + } + sprintf(s, " or %d", exact_dimensions[n-1]); + strcat(dims_str,s); + PyErr_Format(PyExc_TypeError, + "Array must be have %s dimensions. Given array has %d dimensions", + dims_str, array_dimensions(ary)); + } + return success; +} + +/* Require the given PyArrayObject to have a specified shape. If the + * array has the specified shape, return 1. Otherwise, set the python + * error string and return 0. + */ +int require_size(PyArrayObject* ary, int* size, int n) { + int i; + int success = 1; + int len; + char desired_dims[255] = "["; + char s[255]; + char actual_dims[255] = "["; + for(i=0; i < n;i++) { + if (size[i] != -1 && size[i] != array_size(ary,i)) { + success = 0; + } + } + if (!success) { + for (i = 0; i < n; i++) { + if (size[i] == -1) { + sprintf(s, "*,"); + } + else + { + sprintf(s, "%d,", size[i]); + } + strcat(desired_dims,s); + } + len = strlen(desired_dims); + desired_dims[len-1] = ']'; + for (i = 0; i < n; i++) { + sprintf(s, "%d,", array_size(ary,i)); + strcat(actual_dims,s); + } + len = strlen(actual_dims); + actual_dims[len-1] = ']'; + PyErr_Format(PyExc_TypeError, + "Array must be have shape of %s. Given array has shape of %s", + desired_dims, actual_dims); + } + return success; +} +/* End John Hunter translation (with modifications by Bill Spotz) */ + + + +/*! + Appends @a what to @a where. On input, @a where need not to be a tuple, but on + return it always is. + + @par Revision history: + - 17.02.2005, c +*/ +PyObject *helper_appendToTuple( PyObject *where, PyObject *what ) { + PyObject *o2, *o3; + + if ((!where) || (where == Py_None)) { + where = what; + } else { + if (!PyTuple_Check( where )) { + o2 = where; + where = PyTuple_New( 1 ); + PyTuple_SetItem( where, 0, o2 ); + } + o3 = PyTuple_New( 1 ); + PyTuple_SetItem( o3, 0, what ); + o2 = where; + where = PySequence_Concat( o2, o3 ); + Py_DECREF( o2 ); + Py_DECREF( o3 ); + } + return where; +} + + + + + + +#include +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast(v); + } + } + return res; +} + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_csrtocsc__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocsc__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocsc__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocsc__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocsc__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocsc__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocsc(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[6]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 5); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocsc__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocsc__SWIG_2(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocsc__SWIG_3(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocsc__SWIG_4(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocsc__SWIG_5(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocsc__SWIG_6(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocsc'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocsr(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[6]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 5); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocsr__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocsr__SWIG_2(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocsr__SWIG_3(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocsr__SWIG_4(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocsr__SWIG_5(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocsr__SWIG_6(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocsr'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtocoo(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[6]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 5); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocoo__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocoo__SWIG_2(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocoo__SWIG_3(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocoo__SWIG_4(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocoo__SWIG_5(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtocoo__SWIG_6(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocoo'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + float *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (float*) array6->data; + } + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(float)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (double*) array6->data; + } + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(double)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + long double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (long double*) array6->data; + } + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(long double)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cfloat *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cfloat*) array6->data; + } + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cfloat)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cdouble*) array6->data; + } + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cdouble)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_clongdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_clongdouble*) array6->data; + } + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_clongdouble)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsr(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[7]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 6); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_3(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_4(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_5(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_6(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsr'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csctocoo(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[6]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 5); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocoo__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocoo__SWIG_2(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocoo__SWIG_3(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocoo__SWIG_4(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocoo__SWIG_5(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csctocoo__SWIG_6(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocoo'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + float *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (float*) array6->data; + } + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(float)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (double*) array6->data; + } + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(double)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + long double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (long double*) array6->data; + } + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(long double)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cfloat *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cfloat*) array6->data; + } + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cfloat)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_cdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cdouble*) array6->data; + } + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cdouble)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + int *arg5 ; + npy_clongdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + std::vector *tmp9 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_clongdouble*) array6->data; + } + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_clongdouble)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cootocsc(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[7]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 6); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsc__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsc__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsc__SWIG_3(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsc__SWIG_4(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsc__SWIG_5(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsc__SWIG_6(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsc'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (float*) array8->data; + } + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (double*) array8->data; + } + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (long double*) array8->data; + } + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cfloat*) array8->data; + } + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cdouble*) array8->data; + } + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_clongdouble*) array8->data; + } + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrplcsr(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrplcsr__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrplcsr__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrplcsr__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrplcsr__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrplcsr__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrplcsr__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrplcsr'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (float*) array8->data; + } + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (double*) array8->data; + } + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (long double*) array8->data; + } + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cfloat*) array8->data; + } + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cdouble*) array8->data; + } + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_clongdouble*) array8->data; + } + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscplcsc(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscplcsc__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscplcsc__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscplcsc__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscplcsc__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscplcsc__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscplcsc__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscplcsc'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (float*) array8->data; + } + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (double*) array8->data; + } + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (long double*) array8->data; + } + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cfloat*) array8->data; + } + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cdouble*) array8->data; + } + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_clongdouble*) array8->data; + } + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmucsr(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmucsr__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmucsr__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmucsr__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmucsr__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmucsr__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmucsr__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmucsr'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (float*) array8->data; + } + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (double*) array8->data; + } + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (long double*) array8->data; + } + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cfloat*) array8->data; + } + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cdouble*) array8->data; + } + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_clongdouble*) array8->data; + } + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmucsc(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmucsc__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmucsc__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmucsc__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmucsc__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmucsc__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmucsc__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmucsc'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + float *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (float*) array6->data; + } + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(float)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (double*) array6->data; + } + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(double)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + long double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (long double*) array6->data; + } + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(long double)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + npy_cfloat *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cfloat*) array6->data; + } + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cfloat)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + npy_cdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cdouble*) array6->data; + } + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cdouble)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + npy_clongdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_clongdouble*) array6->data; + } + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_clongdouble)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrmux(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[7]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 6); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmux__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmux__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmux__SWIG_3(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmux__SWIG_4(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmux__SWIG_5(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrmux__SWIG_6(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmux'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + float *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (float*) array6->data; + } + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(float)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (double*) array6->data; + } + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(double)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + long double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (long double*) array6->data; + } + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(long double)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + npy_cfloat *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cfloat*) array6->data; + } + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cfloat)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + npy_cdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cdouble*) array6->data; + } + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cdouble)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + npy_clongdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + std::vector *tmp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_clongdouble*) array6->data; + } + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); + + resultobj = SWIG_Py_Void(); + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_clongdouble)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscmux(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[7]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 6); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmux__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmux__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmux__SWIG_3(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmux__SWIG_4(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmux__SWIG_5(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscmux__SWIG_6(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmux'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (float*) array8->data; + } + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (double*) array8->data; + } + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (long double*) array8->data; + } + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cfloat*) array8->data; + } + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cdouble*) array8->data; + } + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_clongdouble*) array8->data; + } + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrelmulcsr(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrelmulcsr__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrelmulcsr__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrelmulcsr__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrelmulcsr__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrelmulcsr__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrelmulcsr__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrelmulcsr'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + int *arg6 ; + int *arg7 ; + float *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (float*) array8->data; + } + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + int *arg6 ; + int *arg7 ; + double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (double*) array8->data; + } + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + int *arg6 ; + int *arg7 ; + long double *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (long double*) array8->data; + } + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cfloat *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cfloat*) array8->data; + } + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_cdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_cdouble*) array8->data; + } + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + int *arg6 ; + int *arg7 ; + npy_clongdouble *arg8 ; + std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg10 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; + PyArrayObject *array7 = NULL ; + int is_new_object7 ; + PyArrayObject *array8 = NULL ; + int is_new_object8 ; + std::vector *tmp9 ; + std::vector *tmp10 ; + std::vector *tmp11 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + { + tmp10 = new std::vector(); + arg10 = tmp10; + } + { + tmp11 = new std::vector(); + arg11 = tmp11; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + { + int size[1] = { + -1 + }; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; + } + { + int size[1] = { + -1 + }; + array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); + if (!array7 || !require_dimensions(array7,1) || !require_size(array7,size,1)) SWIG_fail; + arg7 = (int*) array7->data; + } + { + int size[1] = { + -1 + }; + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; + arg8 = (npy_clongdouble*) array8->data; + } + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + + resultobj = SWIG_Py_Void(); + { + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg10)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg10))[0]),sizeof(int)*length); + delete arg10; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg11)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + delete arg11; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } + { + if (is_new_object7 && array7) Py_DECREF(array7); + } + { + if (is_new_object8 && array8) Py_DECREF(array8); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cscelmulcsc(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[9]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 8); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscelmulcsc__SWIG_1(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscelmulcsc__SWIG_2(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscelmulcsc__SWIG_3(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cscelmulcsc__SWIG_4(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscelmulcsc__SWIG_5(self, args); + } + } + } + } + } + } + } + } + } + if (argc == 8) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[6]) && PyArray_CanCastSafely(PyArray_TYPE(argv[6]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cscelmulcsc__SWIG_6(self, args); + } + } + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscelmulcsc'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + float *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[2] = { + -1,-1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + spdiags(arg1,arg2,arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[2] = { + -1,-1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + spdiags(arg1,arg2,arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + long double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[2] = { + -1,-1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + spdiags(arg1,arg2,arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[2] = { + -1,-1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[2] = { + -1,-1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg7 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + void *argp5 = 0 ; + int res5 = 0 ; + std::vector *tmp6 ; + std::vector *tmp7 ; + std::vector *tmp8 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { + tmp7 = new std::vector(); + arg7 = tmp7; + } + { + tmp8 = new std::vector(); + arg8 = tmp8; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast(val3); + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "spdiags" "', argument " "5"" of type '" "npy_clongdouble const []""'"); + } + arg5 = reinterpret_cast(argp5); + spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + + resultobj = SWIG_Py_Void(); + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg7)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); + delete arg7; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg8)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + delete arg8; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + return resultobj; +fail: + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_spdiags(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[6]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 5); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_spdiags__SWIG_1(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_spdiags__SWIG_2(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_spdiags__SWIG_3(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_spdiags__SWIG_4(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_spdiags__SWIG_5(self, args); + } + } + } + } + } + } + if (argc == 5) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_spdiags__SWIG_6(self, args); + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'spdiags'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + float *arg5 ; + float *arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrtodense",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_FLOAT); + if (!temp6 || !require_contiguous(temp6)) SWIG_fail; + arg6 = (float*) temp6->data; + } + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + double *arg5 ; + double *arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrtodense",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_DOUBLE); + if (!temp6 || !require_contiguous(temp6)) SWIG_fail; + arg6 = (double*) temp6->data; + } + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + long double *arg5 ; + long double *arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrtodense",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long double*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_LONGDOUBLE); + if (!temp6 || !require_contiguous(temp6)) SWIG_fail; + arg6 = (long double*) temp6->data; + } + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cfloat *arg5 ; + npy_cfloat *arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrtodense",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_CFLOAT); + if (!temp6 || !require_contiguous(temp6)) SWIG_fail; + arg6 = (npy_cfloat*) temp6->data; + } + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_cdouble *arg5 ; + npy_cdouble *arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + PyArrayObject *temp6 = NULL ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrtodense",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_CDOUBLE); + if (!temp6 || !require_contiguous(temp6)) SWIG_fail; + arg6 = (npy_cdouble*) temp6->data; + } + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int *arg3 ; + int *arg4 ; + npy_clongdouble *arg5 ; + npy_clongdouble *arg6 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + PyArrayObject *array4 = NULL ; + int is_new_object4 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrtodense",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[1] = { + -1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + int size[1] = { + -1 + }; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; + } + { + int size[1] = { + -1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_clongdouble*) array5->data; + } + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "csrtodense" "', argument " "6"" of type '" "npy_clongdouble []""'"); + } + arg6 = reinterpret_cast(argp6); + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { + if (is_new_object4 && array4) Py_DECREF(array4); + } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_csrtodense(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[7]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 6); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtodense__SWIG_1(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtodense__SWIG_2(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtodense__SWIG_3(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtodense__SWIG_4(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtodense__SWIG_5(self, args); + } + } + } + } + } + } + } + if (argc == 6) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[3]) && PyArray_CanCastSafely(PyArray_TYPE(argv[3]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_csrtodense__SWIG_6(self, args); + } + } + } + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtodense'"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + float *arg3 ; + std::vector *arg4 = (std::vector *) 0 ; + std::vector *arg5 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + std::vector *tmp4 ; + std::vector *tmp5 ; + std::vector *tmp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + tmp4 = new std::vector(); + arg4 = tmp4; + } + { + tmp5 = new std::vector(); + arg5 = tmp5; + } + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[2] = { + -1,-1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_FLOAT, &is_new_object3); + if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (float*) array3->data; + } + densetocsr(arg1,arg2,(float const (*))arg3,arg4,arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + int length = (arg4)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg4))[0]),sizeof(int)*length); + delete arg4; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg5)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg5))[0]),sizeof(int)*length); + delete arg5; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(float)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + double *arg3 ; + std::vector *arg4 = (std::vector *) 0 ; + std::vector *arg5 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + std::vector *tmp4 ; + std::vector *tmp5 ; + std::vector *tmp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + tmp4 = new std::vector(); + arg4 = tmp4; + } + { + tmp5 = new std::vector(); + arg5 = tmp5; + } + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[2] = { + -1,-1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_DOUBLE, &is_new_object3); + if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (double*) array3->data; + } + densetocsr(arg1,arg2,(double const (*))arg3,arg4,arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + int length = (arg4)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg4))[0]),sizeof(int)*length); + delete arg4; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg5)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg5))[0]),sizeof(int)*length); + delete arg5; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(double)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + long double *arg3 ; + std::vector *arg4 = (std::vector *) 0 ; + std::vector *arg5 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + std::vector *tmp4 ; + std::vector *tmp5 ; + std::vector *tmp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + tmp4 = new std::vector(); + arg4 = tmp4; + } + { + tmp5 = new std::vector(); + arg5 = tmp5; + } + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[2] = { + -1,-1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGDOUBLE, &is_new_object3); + if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (long double*) array3->data; + } + densetocsr(arg1,arg2,(long double const (*))arg3,arg4,arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + int length = (arg4)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg4))[0]),sizeof(int)*length); + delete arg4; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg5)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg5))[0]),sizeof(int)*length); + delete arg5; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(long double)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + npy_cfloat *arg3 ; + std::vector *arg4 = (std::vector *) 0 ; + std::vector *arg5 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + std::vector *tmp4 ; + std::vector *tmp5 ; + std::vector *tmp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + tmp4 = new std::vector(); + arg4 = tmp4; + } + { + tmp5 = new std::vector(); + arg5 = tmp5; + } + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[2] = { + -1,-1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CFLOAT, &is_new_object3); + if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (npy_cfloat*) array3->data; + } + densetocsr(arg1,arg2,(npy_cfloat const (*))arg3,arg4,arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + int length = (arg4)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg4))[0]),sizeof(int)*length); + delete arg4; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg5)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg5))[0]),sizeof(int)*length); + delete arg5; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_cfloat)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + npy_cdouble *arg3 ; + std::vector *arg4 = (std::vector *) 0 ; + std::vector *arg5 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; + std::vector *tmp4 ; + std::vector *tmp5 ; + std::vector *tmp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + tmp4 = new std::vector(); + arg4 = tmp4; + } + { + tmp5 = new std::vector(); + arg5 = tmp5; + } + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + { + int size[2] = { + -1,-1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CDOUBLE, &is_new_object3); + if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (npy_cdouble*) array3->data; + } + densetocsr(arg1,arg2,(npy_cdouble const (*))arg3,arg4,arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + int length = (arg4)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg4))[0]),sizeof(int)*length); + delete arg4; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg5)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg5))[0]),sizeof(int)*length); + delete arg5; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_cdouble)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return resultobj; +fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + npy_clongdouble *arg3 ; + std::vector *arg4 = (std::vector *) 0 ; + std::vector *arg5 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + std::vector *tmp4 ; + std::vector *tmp5 ; + std::vector *tmp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + { + tmp4 = new std::vector(); + arg4 = tmp4; + } + { + tmp5 = new std::vector(); + arg5 = tmp5; + } + { + tmp6 = new std::vector(); + arg6 = tmp6; + } + if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "densetocsr" "', argument " "3"" of type '" "npy_clongdouble const []""'"); + } + arg3 = reinterpret_cast(argp3); + densetocsr(arg1,arg2,(npy_clongdouble const (*))arg3,arg4,arg5,arg6); + + resultobj = SWIG_Py_Void(); + { + int length = (arg4)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg4))[0]),sizeof(int)*length); + delete arg4; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg5)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg5))[0]),sizeof(int)*length); + delete arg5; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_clongdouble)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_densetocsr(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[4]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 3); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_densetocsr__SWIG_1(self, args); + } + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_densetocsr__SWIG_2(self, args); + } + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_densetocsr__SWIG_3(self, args); + } + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_densetocsr__SWIG_4(self, args); + } + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_densetocsr__SWIG_5(self, args); + } + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CLONGDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_densetocsr__SWIG_6(self, args); + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'densetocsr'"); + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"csrtocsc", _wrap_csrtocsc, METH_VARARGS, NULL}, + { (char *)"csctocsr", _wrap_csctocsr, METH_VARARGS, NULL}, + { (char *)"csrtocoo", _wrap_csrtocoo, METH_VARARGS, NULL}, + { (char *)"cootocsr", _wrap_cootocsr, METH_VARARGS, NULL}, + { (char *)"csctocoo", _wrap_csctocoo, METH_VARARGS, NULL}, + { (char *)"cootocsc", _wrap_cootocsc, METH_VARARGS, NULL}, + { (char *)"csrplcsr", _wrap_csrplcsr, METH_VARARGS, NULL}, + { (char *)"cscplcsc", _wrap_cscplcsc, METH_VARARGS, NULL}, + { (char *)"csrmucsr", _wrap_csrmucsr, METH_VARARGS, NULL}, + { (char *)"cscmucsc", _wrap_cscmucsc, METH_VARARGS, NULL}, + { (char *)"csrmux", _wrap_csrmux, METH_VARARGS, NULL}, + { (char *)"cscmux", _wrap_cscmux, METH_VARARGS, NULL}, + { (char *)"csrelmulcsr", _wrap_csrelmulcsr, METH_VARARGS, NULL}, + { (char *)"cscelmulcsc", _wrap_cscelmulcsc, METH_VARARGS, NULL}, + { (char *)"spdiags", _wrap_spdiags, METH_VARARGS, NULL}, + { (char *)"csrtodense", _wrap_csrtodense, METH_VARARGS, NULL}, + { (char *)"densetocsr", _wrap_densetocsr, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_npy_clongdouble = {"_p_npy_clongdouble", "npy_clongdouble *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTdouble_t = {"_p_std__vectorTdouble_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTfloat_t = {"_p_std__vectorTfloat_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTint_t = {"_p_std__vectorTint_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTlong_double_t = {"_p_std__vectorTlong_double_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTnpy_cdouble_t = {"_p_std__vectorTnpy_cdouble_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTnpy_cfloat_t = {"_p_std__vectorTnpy_cfloat_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTnpy_clongdouble_t = {"_p_std__vectorTnpy_clongdouble_t", "std::vector *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_char, + &_swigt__p_npy_clongdouble, + &_swigt__p_std__vectorTdouble_t, + &_swigt__p_std__vectorTfloat_t, + &_swigt__p_std__vectorTint_t, + &_swigt__p_std__vectorTlong_double_t, + &_swigt__p_std__vectorTnpy_cdouble_t, + &_swigt__p_std__vectorTnpy_cfloat_t, + &_swigt__p_std__vectorTnpy_clongdouble_t, +}; + +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_npy_clongdouble[] = { {&_swigt__p_npy_clongdouble, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTdouble_t[] = { {&_swigt__p_std__vectorTdouble_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTfloat_t[] = { {&_swigt__p_std__vectorTfloat_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTint_t[] = { {&_swigt__p_std__vectorTint_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTlong_double_t[] = { {&_swigt__p_std__vectorTlong_double_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTnpy_cdouble_t[] = { {&_swigt__p_std__vectorTnpy_cdouble_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTnpy_cfloat_t[] = { {&_swigt__p_std__vectorTnpy_cfloat_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTnpy_clongdouble_t[] = { {&_swigt__p_std__vectorTnpy_clongdouble_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_char, + _swigc__p_npy_clongdouble, + _swigc__p_std__vectorTdouble_t, + _swigc__p_std__vectorTfloat_t, + _swigc__p_std__vectorTint_t, + _swigc__p_std__vectorTlong_double_t, + _swigc__p_std__vectorTnpy_cdouble_t, + _swigc__p_std__vectorTnpy_cfloat_t, + _swigc__p_std__vectorTnpy_clongdouble_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { + return PyString_FromString(""); + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); + return str; + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", PyString_AsString(str)); + Py_DECREF(str); + return 0; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + varlink_type = tmp; + varlink_type.ob_type = &PyType_Type; + type_init = 1; + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals() { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + PyObject *m, *d; + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + + + + import_array(); + +} + Deleted: trunk/Lib/sparse/sparsetools/spblas.f.src =================================================================== --- trunk/Lib/sparse/sparsetools/spblas.f.src 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/spblas.f.src 2007-01-06 06:34:41 UTC (rev 2496) @@ -1,432 +0,0 @@ -c -*- fortran -*- -c author: travis e. oliphant, 2004 -c -c computational tools for sparse matrices in <_t> -c -c add two matrices in compressed sparse column format -c this assumes that the rowa indices are sorted for each column -c and indexes are 0-based - - subroutine <_c>cscadd(n,a,rowa,ptra,nnzamax,b,rowb,ptrb,nnzbmax, - $ c,rowc,ptrc,nnzcmax,ierr) - <_t> a(0:nnzamax-1), b(0:nnzbmax-1) - <_t> c(0:nnzcmax-1), val - integer n, rowa(0:nnzamax-1), rowb(0:nnzbmax-1), rowc(0:nnzcmax-1) - integer ptra(0:n), ptrb(0:n), ptrc(0:n), nnzamax, nnzbmax - integer ia, ib, ra, rb, j, nnzcmax - integer ierr, nnzc - - ierr=0 - nnzc=0 - ia=ptra(0) - ib=ptrb(0) - -c is there a need to initialize the output arrays? assume no for now. -c do j = 0, n -c ptrc(j) = 0 -c end do -c do j = 0, nnzcmax-1 -c rowc(j) = 0 -c c(j) = 0.0 -c end do - - do j = 0, n-1 - iamax = ptra(j+1) - ibmax = ptrb(j+1) - do while ((ia.lt.iamax).and.(ib.lt.ibmax)) - ra = rowa(ia) - rb = rowb(ib) - if (ra.eq.rb) then -c this is a common element - val = a(ia) + b(ib) - ia = ia + 1 - ib = ib + 1 - if (val.eq.0.0) goto 10 - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = val - rowc(nnzc) = ra - else if (ra .lt. rb) then -c a has this but not b - val = a(ia) - ia = ia + 1 - if (val.eq.0.0) goto 10 - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = val - rowc(nnzc) = ra - else -c b has this but not a - val = b(ib) - ib = ib + 1 - if (val.eq.0.0) goto 10 - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = val - rowc(nnzc) = rb - end if - ptrc(j+1) = ptrc(j+1) + 1 - nnzc = nnzc + 1 - 10 continue - end do - - if (ia .eq. iamax) then -c all finished with a for this column just copy the rest from b - do while (ib .lt. ibmax) - val = b(ib) - rb = rowb(ib) - ib = ib+1 - if (val.ne.0.0) then - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = val - rowc(nnzc) = rb - ptrc(j+1) = ptrc(j+1) + 1 - nnzc = nnzc + 1 - end if - end do - else if (ib .eq. ibmax) then -c all finished with b for this column just copy the rest from a - do while (ia .lt. iamax) - val = a(ia) - ra = rowa(ia) - ia = ia + 1 - if (val.ne.0.0) then - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = val - rowc(nnzc) = ra - ptrc(j+1) = ptrc(j+1) + 1 - nnzc = nnzc + 1 - end if - end do - end if - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do k = 1, n - cumsum = cumsum + ptrc(k) - ptrc(k) = cumsum - end do - return - - - 999 continue - ierr = 1 - return - end subroutine <_c>cscadd - -c element-by-element multiplication -c can have at most the minimum of nnzamax and nnzbmax - - subroutine <_c>cscmul(n,a,rowa,ptra,nnzamax,b,rowb,ptrb,nnzbmax, - $ c,rowc,ptrc,nnzcmax,ierr) - <_t> a(0:nnzamax-1), b(0:nnzbmax-1) - <_t> c(0:nnzcmax-1), val - integer n, rowa(0:nnzamax-1), rowb(0:nnzbmax-1), rowc(0:nnzcmax-1) - integer ptra(0:n), ptrb(0:n), ptrc(0:n), nnzamax, nnzbmax - integer ia, ib, ra, rb, j, nnzcmax - integer ierr, k, cumsum - - ierr=0 - nnzc=0 - ia=ptra(0) - ib=ptrb(0) - do j = 0, n-1 - iamax = ptra(j+1) - ibmax = ptrb(j+1) - do while ((ia.lt.iamax).and.(ib.lt.ibmax)) - ra = rowa(ia) - rb = rowb(ib) - if (ra.eq.rb) then -c this is a common element - val = a(ia)*b(ib) - ia = ia + 1 - ib = ib + 1 - if (val.eq.0.0) goto 10 - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = val - rowc(nnzc) = ra - ptrc(j+1) = ptrc(j+1) + 1 - nnzc = nnzc + 1 - else if (ra .lt. rb) then -c a has this but not b - ia = ia + 1 - else -c b has this but not a - ib = ib + 1 - end if - 10 continue - end do - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do k = 1, n - cumsum = cumsum + ptrc(k) - ptrc(k) = cumsum - end do - - return - - 999 continue - ierr = 1 - return - end subroutine <_c>cscmul - - -c matrix-vector multiplication - - subroutine <_c>cscmux(a,rowa,ptra,nnzamax,ncol,x,mrow,y) - <_t> a(0:nnzamax-1), x(0:ncol-1), y(0:mrow-1) - integer rowa(0:nnzamax-1), ptra(0:ncol) - integer nnzamax, mrow, ncol - integer i, j, ia, ra - - do i = 0, mrow-1 - y(i) = 0.0 - end do - - do j = 0, ncol-1 - do ia = ptra(j), ptra(j+1)-1 - ra = rowa(ia) - y(ra) = y(ra) + a(ia)*x(j) - end do - end do - - return - end subroutine <_c>cscmux - - - subroutine <_c>csrmux(a,cola,ptra,nnzamax,ncol,x,mrow,y) - <_t> a(0:nnzamax-1),x(0:ncol-1),y(0:mrow-1) - integer cola(0:nnzamax-1), ptra(0:mrow) - integer nnzamax, mrow, ncol - integer i, ja, ca - - do i = 0, mrow-1 - y(i) = 0.0 - do ja = ptra(i), ptra(i+1)-1 - ca = cola(ja) - y(i) = y(i) + a(ja)*x(ca) - end do - end do - - return - end subroutine <_c>csrmux - - -c matrix multiplication -c c = a * b -c -c where c is mxn csc matrix -c a is mxk csc matrix -c b is kxn csr matrix -c -c irow and kcol give position to start -c nnzc gives current last element in output array (initialize to 0) -c intended to recall so that calculation can continue -c if memory ran-out at last attempt - - - - subroutine <_c>cscmucsr(m,k,n, a,rowa,ptra,nnzamax, b,colb,ptrb, - $ nnzbmax, c,rowc,ptrc,nnzcmax, irow,kcol,ierr) - - <_t> a(0:nnzamax-1), b(0:nnzbmax-1), c(0:nnzcmax-1) - integer rowa(0:nnzamax-1), colb(0:nnzbmax-1), rowc(0:nnzcmax-1) - integer ptra(0:k), ptrb(0:k), ptrc(0:n) - integer nnzamax, nnzbmax, nnzcmax - integer m, k, n, irow, kcol, ierr, cumsum - - integer kk, ii, jjb, jb, cb, ia, nnzc - <_t> val - - - nnzc = ierr - ierr = 0 - do kk = kcol, n-1 - do ii = irow, m-1 - if (nnzc.ge.nnzcmax) goto 999 - irow = 0 - val = 0.0 -c loop through the column array of b using the ptrb array -c so that we know which row we are on. - do jjb = 0, k-1 - do jb = ptrb(jjb), ptrb(jjb+1)-1 - cb = colb(jb) - if (cb.eq.kk) then -c see if aij is nonzero and if so add to val - do ia = ptra(jjb), ptra(jjb+1)-1 - if (rowa(ia).eq.ii) then - val = val + a(ia)*b(jb) - end if - end do - end if - end do - end do - if (val.ne.0.0) then -c there is a non-zero value for this value of i and k - c(nnzc) = val - rowc(nnzc) = ii - ptrc(kk+1) = ptrc(kk+1) + 1 - nnzc = nnzc+1 - end if - end do - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do kk = 1, n - cumsum = cumsum + ptrc(kk) - ptrc(kk) = cumsum - end do - return - - return - - 999 continue - kcol = kk - irow = ii - ierr = nnzc - - return - end subroutine <_c>cscmucsr - - - -c matrix multiplication -c c = a * b -c -c where c is mxn csc matrix -c a is mxk csr matrix -c b is kxn csc matrix -c -c irow and jcol give position to start -c bnum gives current size of output array -c intended to recall so that calculation can continue -c where it left off if memory runs-out during calculation -c - subroutine <_c>csrmucsc(m,n,a,cola,ptra,nnzamax,b,rowb,ptrb, - $ nnzbmax,c,rowc,ptrc,nnzcmax,irow,kcol,ierr) - - <_t> a(0:nnzamax-1), b(0:nnzbmax-1), c(0:nnzcmax-1) - integer cola(0:nnzamax-1), rowb(0:nnzbmax-1), rowc(0:nnzcmax-1) - integer ptra(0:m), ptrb(0:n), ptrc(0:n) - integer nnzamax, nnzbmax, nnzcmax - integer m, n, irow, kcol, ierr, cumsum - - integer kk, ii, nnzc - <_t> val - - nnzc = ierr - ierr = 0 - do kk = kcol, n-1 - do ii = irow, m-1 - if (nnzc.ge.nnzcmax) goto 999 - irow = 0 - val = 0.0 -c loop through the non-zero rows of b - do ib = ptrb(kk), ptrb(kk+1)-1 - rb = rowb(ib) - do ja = ptra(ii), ptra(ii+1)-1 - if (cola(ja).eq.rb) then - val = val + a(ja)*b(ib) - end if - end do - end do - if (val.ne.0.0) then -c there is a non-zero value for this value of i and k - c(nnzc) = val - rowc(nnzc) = ii - ptrc(kk+1) = ptrc(kk+1) + 1 - nnzc = nnzc+1 - end if - end do - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do kk = 1, n - cumsum = cumsum + ptrc(kk) - ptrc(kk) = cumsum - end do - return - - - return - - 999 continue - kcol = kk - irow = ii - ierr = nnzc - - return - end subroutine <_c>csrmucsc - - -c matrix-matrix multiplication -c -c c = a * b where a, b, and c are -c compressed sparse column matrices -c -c or it computes -c -c c = b * a where b, a, and c are -c compressed sparse row matrices -c -c intentended for re-entry if nnzcmax is not big enough - - subroutine <_c>cscmucsc(m,k,n,a,rowa,ptra,nnzamax,b,rowb,ptrb, - $ nnzbmax,c,rowc,ptrc,nnzcmax,irow,kcol,ierr) - - <_t> a(0:nnzamax-1), b(0:nnzbmax-1), c(0:nnzcmax-1) - integer rowa(0:nnzamax-1), rowb(0:nnzbmax-1), rowc(0:nnzcmax-1) - integer ptra(0:k), ptrb(0:n), ptrc(0:n) - integer nnzamax, nnzbmax, nnzcmax - integer m, k, n, irow, kcol, ierr - - integer kk, ii, jb, ia, ra, nnzc, cumsum - <_t> val - - nnzc = ierr - ierr = 0 - do kk = kcol, n-1 - do ii = irow, m-1 - if (nnzc.ge.nnzcmax) goto 999 -c reset the irow to 0 - irow = 0 - val = 0.0 -c loop through the row array of b for this column - do jb = ptrb(kk), ptrb(kk+1)-1 - ra = rowb(jb) - do ia = ptra(ra), ptra(ra+1)-1 -c see if aij is nonzero and if so add to val - if (rowa(ia).eq.ii) then - val = val + a(ia)*b(jb) - end if - end do - end do - if (val.ne.0.0) then -c there is a non-zero value for this value of i and k - c(nnzc) = val - rowc(nnzc) = ii - ptrc(kk+1) = ptrc(kk+1) + 1 - nnzc = nnzc+1 - end if - end do - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do kk = 1, n - cumsum = cumsum + ptrc(kk) - ptrc(kk) = cumsum - end do - return - - 999 continue - kcol = kk - irow = ii - ierr = nnzc - - return - end subroutine <_c>cscmucsc - - Deleted: trunk/Lib/sparse/sparsetools/spconv.f.src =================================================================== --- trunk/Lib/sparse/sparsetools/spconv.f.src 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools/spconv.f.src 2007-01-06 06:34:41 UTC (rev 2496) @@ -1,354 +0,0 @@ -c -*- fortran -*- -c convert csc matrix a to csr matrix b -c convert csr matrix a to csc matrix b -c transpose csc matrix -c transpose csr matrix -c all depends on how you interpret the results - - subroutine <_c>transp(m,n,a,rowa,ptra,nnzamax,b,colb,ptrb) - <_t> a(0:nnzamax-1), b(0:nnzamax-1) - integer rowa(0:nnzamax-1), colb(0:nnzamax-1) - integer ptra(0:n), ptrb(0:m) - integer j, bnum, cola, ia, ra - - ptrb(0) = 0 - bnum = 0 - do j = 0, m-1 - do cola = 0, n-1 - do ia = ptra(cola), ptra(cola+1)-1 - ra = rowa(ia) - if (ra.eq.j) then - b(bnum) = a(ia) - colb(bnum) = cola - bnum = bnum+1 - end if - end do - end do - ptrb(j+1) = bnum - end do - - return - end subroutine <_c>transp - -c returns the index into the data array -c and the value - subroutine <_c>cscgetel(a,rowa,ptra,nnzamax,n,row,col,ind,val) - - <_t> a(0:nnzamax-1), val - integer rowa(0:nnzamax-1), ptra(0:n) - integer nnzamax, row, col, ind - - integer ia - - ind = -1 - val = 0.0 - do ia = ptra(col), ptra(col+1)-1 - if (rowa(ia).eq.row) then - ind = ia - val = a(ia) - goto 10 - end if - end do - - 10 continue - return - - end subroutine <_c>cscgetel - - -c set an element into the data array (assumes there is room) -c - subroutine <_c>cscsetel(a,rowa,ptra,nnzamax,n,row,col,val) - - <_t> a(0:nnzamax-1), val - integer rowa(0:nnzamax-1), ptra(0:n) - integer nnza, n, row, col, nnzamax - - integer ra, newia - - nnza = ptra(n) - newia = ptra(col) - do ia = newia, ptra(col+1)-1 - ra = rowa(ia) - if (ra.eq.row) then -c just replace and be done - a(ia) = val - goto 10 - else if (ra.gt.row) then - newia = ia - goto 5 - end if - end do - -c we are past where it should be stored -c (assumes sorted) so make room for this new element -c here so that it will run if this is the first entry in the -c column - 5 continue - ia = newia - do iia = nnza, ia+1, -1 - a(iia) = a(iia-1) - rowa(iia) = rowa(iia-1) - end do - a(ia) = val - rowa(ia) = row - do iia = col+1, n - ptra(iia) = ptra(iia)+1 - end do - - return - - 10 continue - - return - end subroutine <_c>cscsetel - -c assumes sorted by column and then row - - subroutine <_c>cootocsc(n,vals,row,col,nnz,a,rowa,ptra,nnzamax, - $ ierr) - - <_t> vals(0:nnz-1), a(0:nnzamax-1) - integer rowa(0:nnzamax-1), ptra(0:n) - integer row(0:nnz-1), col(0:nnz-1) - integer n, nnzamax, nnz, ierr - - <_t> val - integer j, k, cumsum - - if (nnz.gt.nnzamax) goto 999 - ierr=0 - nnza=0 - do k = 0, n-1 - ptra(k) = 0 - end do - do ia = 0, nnzamax-1 - a(ia) = 0.0 - rowa(ia) = 0 - end do - do k = 0, nnz-1 - j = col(k) - val = vals(k) - if (val.ne.0.0) then - a(nnza) = val - rowa(nnza) = row(k) - ptra(j+1) = ptra(j+1) + 1 - nnza = nnza + 1 - end if - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do k = 1, n - cumsum = cumsum + ptra(k) - ptra(k) = cumsum - end do - return - - return - - 999 continue - ierr=1 - return - end subroutine <_c>cootocsc - - subroutine <_c>csctocoo(n, vals, row, col, a, rowa, ptra, nnzamax) - <_t> vals(0:nnzamax-1), a(0:nnzamax-1) - integer rowa(0:nnzamax-1), ptra(0:n) - integer row(0:nnzamax-1), col(0:nnzamax-1) - integer n, nnzamax - - integer i, j, k - - j = 0 - do k = 0, n-1 - do i = ptra(k), ptra(k+1)-1 - row(j) = rowa(i) - col(j) = k - vals(j) = a(i) - j = j + 1 - end do - end do - - return - end subroutine <_c>csctocoo - -c intended for re-entry in case a is too small - - subroutine <_c>fulltocsc(m,n,fulla,a,rowa,ptra,nnzamax, - $ irow,jcol,ierr) - - <_t> fulla(0:m-1,0:n-1), a(0:nnzamax-1) - integer rowa(0:nnzamax-1), ptra(0:n) - integer m, n, nnzamax, irow, jcol, ierr - - <_t> val - integer nnza, i, j, k, cumsum - - ierr=0 - nnza = ierr - do j = jcol, n-1 - do i = irow, m-1 - val = fulla(i,j) - if (val.ne.0.0) then - if (nnza.ge.nnzamax) goto 999 - a(nnza) = val - rowa(nnza) = i - ptra(j+1) = ptra(j+1) + 1 - nnza = nnza + 1 - end if - end do - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do k = 1, n - cumsum = cumsum + ptra(k) - ptra(k) = cumsum - end do - return - - 999 continue - ierr=nnza - irow = i - jcol = j - return - end subroutine <_c>fulltocsc - - - subroutine <_c>csctofull(m, n, fulla, a, rowa, ptra, nnzamax) - - <_t> fulla(0:m-1, 0:n-1), a(0:nnzamax-1) - integer rowa(0:nnzamax-1), ptra(0:n) - integer m, n, nnzamax - - integer ia, k -c integer i, j - -c do j = 0, n-1 -c do i = 0, m-1 -c fulla(i,j) = 0.0 -c end do -c end do - - do k = 0, n-1 - do ia = ptra(k), ptra(k+1)-1 - fulla(rowa(ia),k) = a(ia) - end do - end do - - return - end subroutine <_c>csctofull - - -c extract a sub-matrix from a sparse matrix -c c = a(ibeg:iend, jbeg:jend) (inclusive of end-points) -c -c intended for re-entry if nnzcmax is not big enough -c irow and jcol should initially be 0 and 0 - - subroutine <_c>cscextract(n,a,rowa,ptra,nnzamax,ibeg,iend,jbeg, - $ jend, c, rowc, ptrc, nnzcmax, irow, jcol, ierr) - - <_t> a(0:nnzamax-1), c(0:nnzcmax-1) - integer rowa(0:nnzamax-1), rowc(0:nnzamax-1) - integer ptra(0:n), ptrc(0:jend-jbeg+1) - integer ibeg, iend, jbeg, jend - integer nnzamax, nnzcmax, irow, jcol, ierr - - integer nnza, nc, j, iabeg, ia, k, cumsum - - nc = jend-jbeg+1 - - nnza = ptra(n) - nnzc = ierr - - if (jcol .lt. jbeg) jcol = jbeg - - do j = jcol, jend - jc = j - jbeg -c look through row indices in this column, copy all those that are -c in required range. - iabeg = max(irow,ptra(j)) - do ia = iabeg, ptra(j+1)-1 - ra = rowa(ia) - if ((ra.le.iend).and.(ra.ge.ibeg)) then - if (nnzc.ge.nnzcmax) goto 999 - c(nnzc) = a(ia) - rowc(nnzc) = ra-ibeg - ptrc(jc+1) = ptrc(jc+1) + 1 - nnzc = nnzc + 1 - end if - end do - end do - -c successful completion (fix the ptr array) - cumsum = 0 - do k = 1, n - cumsum = cumsum + ptrc(k) - ptrc(k) = cumsum - end do - return - - - return - - 999 continue - ierr = nnzc - irow = ia - jcol = j - return - end subroutine <_c>cscextract - - - - subroutine <_c>diatocsc(m,n,diags,numdia,diasize,offsets, - $ a,rowa,ptra,nzmax, ierr) - - integer n, numdia, diasize, nzmax, ierr - <_t> diags(0:numdia-1, 0:diasize-1), a(0:nzmax-1) - <_t> val - integer offsets(0:numdia-1), rowa(0:nzmax-1) - integer ptra(0:n) - - integer col, nnza, jj, row, idiag, ia - - nnza = 0 - ierr = 0 -c write (*,*) "SDSD", m, n, numdia, diasize, nzmax - do col = 0, n-1 -c Loop through the offsets - do jj = 0, numdia-1 - row = col - offsets(jj) - if ((row.ge.0).and.(row.lt.m)) then - idiag = min(row, col) - val = diags(jj, idiag) - if (val.ne.0.0) then - if (nnza.ge.nzmax) goto 999 -c find place to insert this row (inserted in sorted order) - ia = ptra(col) - 10 if ((ia.lt.ptra(col+1)).and.(rowa(ia).lt.row)) then - ia = ia + 1 - goto 10 - end if - do iia = nnza, ia+1, -1 - a(iia) = a(iia-1) - rowa(iia) = rowa(iia-1) - end do - a(ia) = val - rowa(ia) = row - nnza = nnza + 1 - end if - end if - end do - ptra(col+1) = nnza - end do - - return - - 999 continue - ierr = 1 - return - - - end subroutine <_c>diatocsc Deleted: trunk/Lib/sparse/sparsetools.txt =================================================================== --- trunk/Lib/sparse/sparsetools.txt 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/sparsetools.txt 2007-01-06 06:34:41 UTC (rev 2496) @@ -1,129 +0,0 @@ -This is a list of the functions we need to replace sparsekit --- needed in all 4 precision formats (c, z, s, d) - -coocsr -- converts coordinate to csr format - (nrow, nnz, a, ir, jc, ao, jao, iao) - nrow -- dimension of the matrix - nnz -- number of nonzero elements in matrix - a,ir,jc -- matrix in coordinate format a(k), ir(k), jc(k) - store then nnz nonzero elements of the matrix - - ao, jao, iao --- matrix in general sparse matrix format (CSR) - ao containing values, jao containing column indices - and iao being the pointer to the beginning of the row - in arrays a0 and jao - -getelm -- return a(i,j) for any (i,j) from a CSR-stored matrix - (i,j, a,ja,ia, iadd, sorted) - - i,j -- row and column of element sought - a,ja,ia --- matrix in CSR format - sorted --- logical indicating whether the matrix is known to - have its column indices sorted in increasing order - getelm -- value of a(i,j) - iadd -- address of element a(i,j) in arrays (a,ja) if found - zero otherwise - -submat -- extracts the submatrix A(i1:i2,j1:j2) and puts the result in matrix - ao, iao, jao - (n, job, i1, i2, j1, j2, a, ja, ia, nr, nr, nc, ao, jao, iao) - n -- row dimension of matrix - i1,i2, j1, j2 --- slice select (i1 <= i2 and j1 <= j2) - a,ja,ia -- matrix in CSR format - job -- job indicator: if job != 1 then the real values in a are - NOT extracted, only the column indices are. - otherwise values as well as column indices are - extracted. - - nr - number of rows of submatrix - nc - number of columns of submatrix - ao, jao, iao -- extracted matrix in general sparse format with - jao containing the column indices and iao being the - pointer to the beginning of the row in arrays a, ja. - -aplb -- computes C = A + B - (nrow, ncol, job, a, ja, ia, b, jb, ib, c, jc, ic, nzmax, iw, ierr) - nrow x ncol --- row dimension of A and B - job --- integer job indicator (when job =0 only the - structure (ie jc, ic) is computed and the - values are ignored. - - a,ja,ia -- matrix A in CSR format - b,jb,ib -- matrix B in CSR format - nzmax -- the length of arrays c and jc. amub will stop if result - matrix has more elements than nzmax. - - Return: - - c,jc,ic -- resulting matrix C = A + B - ierr -- integer serving as error message - 0 -- normal return - >0 means aplb stopped while computing the ith - row with i=ierr because number of elements in C > nzmax - -amub -- computes C = A * B - (nrow, ncol, job, a, ja, ia, b, jb, ib, c, jc, ic, nzmax, iw, ierr) - nrow x ncol --- row dimension of A and B - job --- integer job indicator (when job =0 only the - structure (ie jc, ic) is computed and the - values are ignored. - - a,ja,ia -- matrix A in CSR format - b,jb,ib -- matrix B in CSR format - nzmax -- the length of arrays c and jc. amub will stop if result - matrix has more elements than nzmax. - - Return: - - c,jc,ic -- resulting matrix C = A * B - ierr -- integer serving as error message - 0 -- normal return - >0 means amub stopped while computing the ith - row with i=ierr because number of elements in C > nzmax - - - -amux -- matrix by vector using the dot product form - (n, x, y, a, ja, ia) - n -- row dimension of A - x -- array of length equal to the column dimension of A - a, ja, ia -- input matrix in CSR format - - y -- array of length n, containing the product y = Ax - -transp -- in place transposition routine. (could use csrcsc instead for not inplace) - (nrow, ncol, a, ja, ia, iwk, ierr) - - nrow x ncol --- the row x column dimension of A - a, ja, ia -- CSR format matrix (ia is nrow+1 elements) - iwk -- integer work array of same length as ja - - On return: - ncol -- actual row dimension of transpose of input matrix - a,ja, ia --- transposed matrix in CSR format - - ierr -- integer error message. If the number of rows for the - transposed matrix exceeds the input value of ncol - then ierr is set to that number and transp quits - Otherwise ierr is set to 0. - - - -diacsr --- construct CSR matrix from diagonals - (m,n,job, idiag, diag, ndiag, ioff, a, ja, ia) - - m,n -- sparse array will be mxn - job -- if job==0 then check for each entry in diag - whether this entry is zero. If it is then do not - include it in the output matrix. - - idiag -- integer equal to the number of diagonals - diag -- array of size (ndiag x idiag) containing the diagonals to - be placed in A - ndiag -- integer equal to the first dimension of array diag - ioff -- integer array of length idiag containing the offsets of - the diagonals to be extracted. - - on return: - - a, ja, ia --- matrix stored in CSR format - Modified: trunk/Lib/sparse/tests/test_sparse.py =================================================================== --- trunk/Lib/sparse/tests/test_sparse.py 2007-01-06 06:01:15 UTC (rev 2495) +++ trunk/Lib/sparse/tests/test_sparse.py 2007-01-06 06:34:41 UTC (rev 2496) @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Authors: Travis Oliphant, Ed Schofield, Robert Cimrman, and others +# Authors: Travis Oliphant, Ed Schofield, Robert Cimrman, Nathan Bell, and others """ Test functions for sparse matrices @@ -363,8 +363,105 @@ # assert_array_equal(B[(1,2,3),:], A[(1,2,3),:].todense()) +class _test_arith: + """ + Test real/complex arithmetic + """ + def arith_init(self): + #these can be represented exactly in FP (so arithmetic should be exact) + self.A = matrix([[-1.5,0,0,2.25],[3.125,0,-0.125,0],[0,-5.375,0,0]],float64) + self.B = matrix([[0,3.375,0,-7.875],[6.625,4.75,0,0],[3.5,6.0625,0,1]],float64) + + self.C = matrix([[0.375,0,-5,2.5],[0,7.25,0,-4.875],[0,-0.0625,0,0]],complex128) + self.C.imag = matrix([[1.25,0,0,-3.875],[0,4.125,0,2.75],[-0.0625,0,0,1]],float64) -class test_csr(_test_cs, _test_horiz_slicing, ScipyTestCase): + #fractions are all x/16ths + assert_array_equal((self.A*16).astype(numpy.int32),16*self.A) + assert_array_equal((self.B*16).astype(numpy.int32),16*self.B) + assert_array_equal((self.C.real*16).astype(numpy.int32),16*self.C.real) + assert_array_equal((self.C.imag*16).astype(numpy.int32),16*self.C.imag) + + self.Asp = self.spmatrix(self.A) + self.Bsp = self.spmatrix(self.B) + self.Csp = self.spmatrix(self.C) + + self.dtypes = [float32,float64,complex64,complex128] + + def check_pl(self): + self.arith_init() + + #basic tests + assert_array_equal(self.A+self.B,(self.Asp+self.Bsp).todense()) + assert_array_equal(self.A+self.C,(self.Asp+self.Csp).todense()) + + #check conversions + for x in self.dtypes: + for y in self.dtypes: + for z in self.dtypes: + A = self.A.astype(x) + B = self.B.astype(y) + C = self.C.astype(z) + + Asp = self.spmatrix(A) + Bsp = self.spmatrix(B) + Csp = self.spmatrix(C) + + D1 = A + B + D2 = A + C + D3 = B + C + + S1 = Asp + Bsp + S2 = Asp + Csp + S3 = Bsp + Csp + + assert_array_equal(D1,S1.todense()) + assert_array_equal(D2,S2.todense()) + assert_array_equal(D3,S3.todense()) + + assert_array_equal(D1.dtype,S1.dtype) + assert_array_equal(D2.dtype,S2.dtype) + assert_array_equal(D3.dtype,S3.dtype) + + + def check_mu(self): + self.arith_init() + + #basic tests + assert_array_equal(self.A*self.B.T,(self.Asp*self.Bsp.T).todense()) + assert_array_equal(self.A*self.C.T,(self.Asp*self.Csp.T).todense()) + + #check conversions + for x in self.dtypes: + for y in self.dtypes: + for z in self.dtypes: + A = self.A.astype(x) + B = self.B.astype(y) + C = self.C.astype(z) + + Asp = self.spmatrix(A) + Bsp = self.spmatrix(B) + Csp = self.spmatrix(C) + + D1 = A * B.T + D2 = A * C.T + D3 = B * C.T + + S1 = Asp * Bsp.T + S2 = Asp * Csp.T + S3 = Bsp * Csp.T + + assert_array_equal(D1,S1.todense()) + assert_array_equal(D2,S2.todense()) + assert_array_equal(D3,S3.todense()) + + assert_array_equal(D1.dtype,S1.dtype) + assert_array_equal(D2.dtype,S2.dtype) + assert_array_equal(D3.dtype,S3.dtype) + + + + +class test_csr(_test_cs, _test_horiz_slicing, _test_arith, ScipyTestCase): spmatrix = csr_matrix def check_constructor1(self): @@ -417,7 +514,7 @@ assert(e.A.dtype.type == mytype) -class test_csc(_test_cs, _test_vert_slicing, ScipyTestCase): +class test_csc(_test_cs, _test_vert_slicing, _test_arith, ScipyTestCase): spmatrix = csc_matrix def check_constructor1(self): @@ -639,7 +736,27 @@ assert_array_equal(a.toarray(), b) class test_coo(ScipyTestCase): + def check_constructor1(self): + row = numpy.array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2]) + col = numpy.array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1]) + data = numpy.array([ 6., 10., 3., 9., 1., 4., + 11., 2., 8., 5., 7.]) + + coo = coo_matrix((data,(row,col)),(4,3)) + + assert_array_equal(arange(12).reshape(4,3),coo.todense()) + def check_constructor2(self): + #duplicate entries should be summed + row = numpy.array([0,1,2,2,2,2,0,0,2,2]) + col = numpy.array([0,2,0,2,1,1,1,0,0,2]) + data = numpy.array([2,9,-4,5,7,0,-1,2,1,-5]) + coo = coo_matrix((data,(row,col)),(3,3)) + + mat = matrix([[4,-1,0],[0,0,9],[-3,7,0]]) + + assert_array_equal(mat,coo.todense()) + def check_normalize( self ): row = numpy.array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2]) From scipy-svn at scipy.org Sat Jan 6 02:19:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 01:19:38 -0600 (CST) Subject: [Scipy-svn] r2497 - trunk/Lib/sparse Message-ID: <20070106071938.CEB7539C125@new.scipy.org> Author: timl Date: 2007-01-06 01:19:28 -0600 (Sat, 06 Jan 2007) New Revision: 2497 Modified: trunk/Lib/sparse/sparse.py Log: fix typo Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-06 06:34:41 UTC (rev 2496) +++ trunk/Lib/sparse/sparse.py 2007-01-06 07:19:28 UTC (rev 2497) @@ -798,7 +798,7 @@ cd = conj(self.data) else: cd = self.data - y = sparsetool.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) + y = sparsetools.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an From scipy-svn at scipy.org Sat Jan 6 02:40:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 01:40:01 -0600 (CST) Subject: [Scipy-svn] r2498 - trunk/Lib/sparse Message-ID: <20070106074001.EF86E39C126@new.scipy.org> Author: wnbell Date: 2007-01-06 01:39:53 -0600 (Sat, 06 Jan 2007) New Revision: 2498 Modified: trunk/Lib/sparse/sparse.py Log: enures coo_matrix.shape is an int tuple (even when it is given as a float tuple) Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-06 07:19:28 UTC (rev 2497) +++ trunk/Lib/sparse/sparse.py 2007-01-06 07:39:53 UTC (rev 2498) @@ -50,7 +50,6 @@ -#these four don't appear to be used anymore (Jan 6th, 2007) _coerce_rules = {('f', 'f'):'f', ('f', 'd'):'d', ('f', 'F'):'F', ('f', 'D'):'D', ('d', 'f'):'d', ('d', 'd'):'d', ('d', 'F'):'D', ('d', 'D'):'D', ('F', 'f'):'F', @@ -577,6 +576,9 @@ self._check() def _check(self): + # some functions pass floats + self.shape = tuple([int(x) for x in self.shape]) + M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind) @@ -598,9 +600,8 @@ "Last value of index list should be less than "\ "the size of data list" if (self.rowind.dtype != numpy.intc): - raise TypeError, "rowind indices must be of type numpy.intc" - if (self.indptr.dtype != numpy.intc): - raise TypeError, "inptr indices must be of type numpy.intc" + self.rowind = self.rowind.astype(numpy.intc) + self.indptr = self.indptr.astype(numpy.intc) self.nnz = nnz self.nzmax = nzmax self.dtype = self.data.dtype @@ -798,7 +799,7 @@ cd = conj(self.data) else: cd = self.data - y = sparsetools.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) + y = sparsetool.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an @@ -1107,6 +1108,8 @@ self._check() def _check(self): + # some functions pass floats + self.shape = tuple([int(x) for x in self.shape]) M, N = self.shape nnz = self.indptr[-1] @@ -1126,9 +1129,8 @@ "last value of index list should be less than "\ "the size of data list" if (self.colind.dtype != numpy.intc): - raise TypeError, "colind indices must be of type numpy.intc" - if (self.indptr.dtype != numpy.intc): - raise TypeError, "inptr indices must be of type numpy.intc" + self.colind = self.colind.astype(numpy.intc) + self.indptr = self.indptr.astype(numpy.intc) self.nnz = nnz self.nzmax = nzmax self.dtype = self.data.dtype @@ -2128,8 +2130,8 @@ # Use 2 steps to ensure dims has length 2. M, N = dims self.shape = (M, N) - self.row = asarray(ij[0]) - self.col = asarray(ij[1]) + self.row = asarray(ij[0],dtype=numpy.intc) + self.col = asarray(ij[1],dtype=numpy.intc) self.data = asarray(obj, dtype=self.dtype) self._check() @@ -2142,9 +2144,12 @@ raise ValueError, "row, column, and data array must all be "\ "the same length" if (self.row.dtype != numpy.intc): - raise TypeError, "row indices must be of type numpy.intc" + self.row = self.row.astype(numpy.intc) if (self.col.dtype != numpy.intc): - raise TypeError, "col indices must be of type numpy.intc" + self.col = self.col.astype(numpy.intc) + + # some functions pass floats + self.shape = tuple([int(x) for x in self.shape]) self.nnz = nnz self.ftype = _transtabl.get(self.dtype.char,'') @@ -2177,7 +2182,7 @@ if self.nnz == 0: return csc_matrix(self.shape, dtype=self.dtype) else: - indptr,rowind,data = sparsetools.cootocsc(self.shape[0],self.shape[1],self.size,self.row,self.col,self.data) + indptr,rowind,data = sparsetools.cootocsc(self.shape[0],self.shape[1],self.size,self.row,self.col,self.data) return csc_matrix((data,rowind,indptr),self.shape) From scipy-svn at scipy.org Sat Jan 6 02:56:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 01:56:27 -0600 (CST) Subject: [Scipy-svn] r2499 - in trunk/Lib: linsolve/umfpack sparse Message-ID: <20070106075627.59CF539C122@new.scipy.org> Author: wnbell Date: 2007-01-06 01:56:20 -0600 (Sat, 06 Jan 2007) New Revision: 2499 Modified: trunk/Lib/linsolve/umfpack/umfpack.py trunk/Lib/sparse/sparse.py Log: added ensure_sorted_indices() to csr_matrix and csc_matrix updated umfpack to sort indices Modified: trunk/Lib/linsolve/umfpack/umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-06 07:39:53 UTC (rev 2498) +++ trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-06 07:56:20 UTC (rev 2499) @@ -337,6 +337,9 @@ sparsity pattern.""" self.free_symbolic() + #row/column indices cannot be assumed to be sorted + mtx.ensure_sorted_indices(inplace=True) + indx = self._getIndx( mtx ) if self.isReal: status, self._symbolic\ @@ -370,6 +373,9 @@ self.free_numeric() + #row/column indices cannot be assumed to be sorted + mtx.ensure_sorted_indices(inplace=True) + if self._symbolic is None: self.symbolic( mtx ) Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-06 07:39:53 UTC (rev 2498) +++ trunk/Lib/sparse/sparse.py 2007-01-06 07:56:20 UTC (rev 2499) @@ -971,6 +971,17 @@ self.nzmax = nnz self._check() + def ensure_sorted_indices(self,inplace=False): + """Return a copy of this matrix where the row indices are sorted + """ + if inplace: + temp = self.tocsr().tocsc() + self.rowind = temp.rowind + self.indptr = temp.indptr + self.data = temp.data + else: + return self.tocsr().tocsc() + def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() @@ -1463,6 +1474,18 @@ self.nzmax = nnz self._check() + def ensure_sorted_indices(self,inplace=False): + """Return a copy of this matrix where the column indices are sorted + """ + if inplace: + temp = self.tocsc().tocsr() + self.colind = temp.colind + self.indptr = temp.indptr + self.data = temp.data + else: + return self.tocsc().tocsr() + + def copy(self): new = csr_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() From scipy-svn at scipy.org Sat Jan 6 05:00:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 04:00:05 -0600 (CST) Subject: [Scipy-svn] r2500 - trunk/Lib/sparse Message-ID: <20070106100005.38AE239C0E3@new.scipy.org> Author: timl Date: 2007-01-06 03:59:58 -0600 (Sat, 06 Jan 2007) New Revision: 2500 Modified: trunk/Lib/sparse/sparse.py Log: fix 64 bit bugs in sparse.py Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-06 07:56:20 UTC (rev 2499) +++ trunk/Lib/sparse/sparse.py 2007-01-06 09:59:58 UTC (rev 2500) @@ -532,11 +532,11 @@ if copy: self.data = array(s) self.rowind = array(rowind) - self.indptr = array(indptr) + self.indptr = array(indptr, dtype=intc) else: self.data = asarray(s) self.rowind = asarray(rowind) - self.indptr = asarray(indptr) + self.indptr = asarray(indptr, dtype=intc) except: raise ValueError, "unrecognized form for csc_matrix constructor" else: @@ -1078,11 +1078,11 @@ if copy: self.data = array(s, dtype=self.dtype) self.colind = array(colind) - self.indptr = array(indptr) + self.indptr = array(indptr, dtype=intc) else: self.data = asarray(s, dtype=self.dtype) self.colind = asarray(colind) - self.indptr = asarray(indptr) + self.indptr = asarray(indptr, dtype=intc) else: # (data, ij) format self.dtype = getdtype(dtype, s) @@ -2704,7 +2704,7 @@ diags = diags.astype('d') if not hasattr(offsets, '__len__' ): offsets = (offsets,) - offsets = array(offsets, copy=False) + offsets = array(offsets, copy=False, dtype=numpy.intc) assert(len(offsets) == diags.shape[0]) indptr,rowind,data = sparsetools.spdiags(M,N,len(offsets),offsets,diags) return csc_matrix((data,rowind,indptr),(M,N)) From scipy-svn at scipy.org Sat Jan 6 23:21:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 6 Jan 2007 22:21:03 -0600 (CST) Subject: [Scipy-svn] r2501 - in trunk/Lib/sparse: . sparsetools Message-ID: <20070107042103.B775539C15A@new.scipy.org> Author: rkern Date: 2007-01-06 22:20:54 -0600 (Sat, 06 Jan 2007) New Revision: 2501 Modified: trunk/Lib/sparse/setup.py trunk/Lib/sparse/sparsetools/sparsetools.i trunk/Lib/sparse/sparsetools/sparsetools.py trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx Log: I regenerated the extension module with SWIG 1.3.31 to incorporate a fix from the SWIG runtime. There were several instances of assigning const char* to plain-old char* that g++ 4 was creating errors for me. I also added a #include "Python.h" before the numpy headers are #included. Otherwise, the module did not compile for me on OS X with Python 2.5. Modified: trunk/Lib/sparse/setup.py =================================================================== --- trunk/Lib/sparse/setup.py 2007-01-06 09:59:58 UTC (rev 2500) +++ trunk/Lib/sparse/setup.py 2007-01-07 04:20:54 UTC (rev 2501) @@ -11,21 +11,13 @@ config.add_data_dir('tests') - #config.add_library('sparsekit_src', - # sources = [join('sparsekit','*.f')] - # ) - -## sources = ['spblas.f.src','spconv.f.src','sparsetools.pyf.src'] -## sources = [join('sparsetools',x) for x in sources] - -## config.add_extension('sparsetools', -## sources = sources, -## ) - sources = ['sparsetools_wrap.cxx','sparsetools.py'] - sources = [join('sparsetools',x) for x in sources] - + # Adding a Python file as a "source" file for an extension is something of + # a hack, but it works to put it in the right place. + sources = [join('sparsetools', x) for x in + ['sparsetools.py', 'sparsetools_wrap.cxx']] config.add_extension('_sparsetools', - sources = sources, + sources=sources, + include_dirs=['sparsetools'], ) return config Modified: trunk/Lib/sparse/sparsetools/sparsetools.i =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.i 2007-01-06 09:59:58 UTC (rev 2500) +++ trunk/Lib/sparse/sparsetools/sparsetools.i 2007-01-07 04:20:54 UTC (rev 2501) @@ -6,6 +6,7 @@ %{ #define SWIG_FILE_WITH_INIT +#include "Python.h" #include "numpy/arrayobject.h" #include "complex_ops.h" #include "sparsetools.h" Modified: trunk/Lib/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-06 09:59:58 UTC (rev 2500) +++ trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-07 04:20:54 UTC (rev 2501) @@ -1,10 +1,16 @@ -# This file was created automatically by SWIG 1.3.28. +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.31 +# # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. import _sparsetools import new new_instancemethod = new.instancemethod +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): @@ -27,6 +33,11 @@ if method: return method(self) raise AttributeError,name +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + import types try: _object = types.ObjectType @@ -40,7 +51,7 @@ def csrtocsc(*args): - """ + """ csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, @@ -58,10 +69,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csrtocsc(*args) + return _sparsetools.csrtocsc(*args) def csctocsr(*args): - """ + """ csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, @@ -79,10 +90,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csctocsr(*args) + return _sparsetools.csctocsr(*args) def csrtocoo(*args): - """ + """ csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, @@ -100,10 +111,10 @@ std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csrtocoo(*args) + return _sparsetools.csrtocoo(*args) def cootocsr(*args): - """ + """ cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) @@ -123,10 +134,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.cootocsr(*args) + return _sparsetools.cootocsr(*args) def csctocoo(*args): - """ + """ csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, @@ -144,10 +155,10 @@ std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csctocoo(*args) + return _sparsetools.csctocoo(*args) def cootocsc(*args): - """ + """ cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) @@ -167,10 +178,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.cootocsc(*args) + return _sparsetools.cootocsc(*args) def csrplcsr(*args): - """ + """ csrplcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -190,10 +201,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrplcsr(*args) + return _sparsetools.csrplcsr(*args) def cscplcsc(*args): - """ + """ cscplcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -213,10 +224,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscplcsc(*args) + return _sparsetools.cscplcsc(*args) def csrmucsr(*args): - """ + """ csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -236,10 +247,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrmucsr(*args) + return _sparsetools.csrmucsr(*args) def cscmucsc(*args): - """ + """ cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -259,10 +270,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscmucsc(*args) + return _sparsetools.cscmucsc(*args) def csrmux(*args): - """ + """ csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, std::vector<(float)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, @@ -276,10 +287,10 @@ csrmux(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ - return _sparsetools.csrmux(*args) + return _sparsetools.csrmux(*args) def cscmux(*args): - """ + """ cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, std::vector<(float)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, @@ -293,10 +304,10 @@ cscmux(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ - return _sparsetools.cscmux(*args) + return _sparsetools.cscmux(*args) def csrelmulcsr(*args): - """ + """ csrelmulcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -316,10 +327,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrelmulcsr(*args) + return _sparsetools.csrelmulcsr(*args) def cscelmulcsc(*args): - """ + """ cscelmulcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -339,10 +350,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscelmulcsc(*args) + return _sparsetools.cscelmulcsc(*args) def spdiags(*args): - """ + """ spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(float)> Ax) @@ -362,10 +373,10 @@ std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(npy_clongdouble)> Ax) """ - return _sparsetools.spdiags(*args) + return _sparsetools.spdiags(*args) def csrtodense(*args): - """ + """ csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, long double Ax, @@ -377,10 +388,10 @@ csrtodense(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, npy_clongdouble Mx) """ - return _sparsetools.csrtodense(*args) + return _sparsetools.csrtodense(*args) def densetocsr(*args): - """ + """ densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(float)> Ax) densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, @@ -394,5 +405,5 @@ densetocsr(int n_row, int n_col, npy_clongdouble Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(npy_clongdouble)> Ax) """ - return _sparsetools.densetocsr(*args) + return _sparsetools.densetocsr(*args) Modified: trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-06 09:59:58 UTC (rev 2500) +++ trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-07 04:20:54 UTC (rev 2501) @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.28 + * Version 1.3.31 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -27,12 +27,10 @@ }; #endif -/*********************************************************************** - * +/* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. - * - ************************************************************************/ + * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR @@ -89,7 +87,13 @@ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif -/* exporting methods for Windows DLLs */ +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) @@ -98,7 +102,11 @@ # define SWIGEXPORT __declspec(dllexport) # endif # else -# define SWIGEXPORT +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif # endif #endif @@ -111,21 +119,25 @@ # endif #endif +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + /* Python.h has to appear first */ #include -/*********************************************************************** +/* ----------------------------------------------------------------------------- * swigrun.swg * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * - ************************************************************************/ + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" +#define SWIG_RUNTIME_VERSION "3" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -346,7 +358,7 @@ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (int)(*f1 - *f2); + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (l1 - f1) - (l2 - f2); } @@ -702,13 +714,11 @@ -/* Python.h has to appear first */ -#include /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf +# define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif @@ -718,7 +728,7 @@ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE -#define SWIG_PYBUFFER_SIZE 1024 +# define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * @@ -729,36 +739,70 @@ va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 -#define PyObject_Del(op) PyMem_DEL((op)) +# define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL -#define PyObject_DEL PyObject_Del +# define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 -#define PyExc_StopIteration PyExc_RuntimeError -#define PyObject_GenericGetAttr 0 -#define Py_NotImplemented PyExc_RuntimeError +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif #endif +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 -#define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif #endif +/* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 -#define PySequence_Size PySequence_Length +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif #endif +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +#endif + /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ @@ -933,15 +977,17 @@ #endif -/*********************************************************************** +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * * pyrun.swg * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. * - * Author : David Beazley (beazley at cs.uchicago.edu) - ************************************************************************/ + * ----------------------------------------------------------------------------- */ /* Common SWIG API */ @@ -1149,7 +1195,7 @@ SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { - PyObject *none = Py_BuildValue(""); + PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } @@ -1171,7 +1217,6 @@ return none; } - /* PySwigClientData */ typedef struct { @@ -1207,7 +1252,7 @@ PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); /* the klass element */ data->klass = obj; - Py_INCREF(obj); + Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; @@ -1216,15 +1261,17 @@ } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); #else - data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, (char *)"__new__"); - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } Py_INCREF(data->newargs); -#endif } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); @@ -1252,7 +1299,6 @@ SWIGRUNTIME void PySwigClientData_Del(PySwigClientData* data) { - Py_XDECREF(data->klass); Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); @@ -1305,14 +1351,22 @@ } SWIGRUNTIME PyObject * +#ifdef METH_NOARGS PySwigObject_repr(PySwigObject *v) +#else +PySwigObject_repr(PySwigObject *v, PyObject *args) +#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); Py_DECREF(hex); if (v->next) { +#ifdef METH_NOARGS PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); +#else + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); +#endif PyString_ConcatAndDel(&repr,nrep); } return repr; @@ -1321,7 +1375,11 @@ SWIGRUNTIME int PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { +#ifdef METH_NOARGS PyObject *repr = PySwigObject_repr(v); +#else + PyObject *repr = PySwigObject_repr(v, NULL); +#endif if (repr) { fputs(PyString_AsString(repr), fp); Py_DECREF(repr); @@ -1470,7 +1528,7 @@ else { PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = sobj->own ? Py_True : Py_False; + PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { @@ -1486,7 +1544,6 @@ } #endif } - Py_INCREF(obj); return obj; } } @@ -1499,6 +1556,7 @@ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else @@ -1509,6 +1567,7 @@ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif @@ -1856,14 +1915,13 @@ if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } + } else { #ifdef PyWeakref_CheckProxy - else if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } #endif - if (!obj) { obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); @@ -1891,7 +1949,6 @@ } } - /* Acquire a pointer value */ SWIGRUNTIME int @@ -1997,7 +2054,7 @@ void *vptr = 0; /* here we get the method pointer for callbacks */ - char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) { desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; @@ -2071,6 +2128,14 @@ } return inst; #else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst; + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + return (PyObject *) inst; +#else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; @@ -2082,11 +2147,56 @@ Py_DECREF(inst); return NULL; } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif +#endif } +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + return NULL; + } else { + PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + PySwigObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + /* Create a new pointer object */ SWIGRUNTIME PyObject * @@ -2204,7 +2314,35 @@ } } +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = PyString_FromString(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); + } else { + swig_module_info *swig_module = SWIG_Python_GetModule(); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCObject_FromVoidPtr(descriptor, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + /* For backward compatibility only */ @@ -2345,7 +2483,7 @@ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) -# warning "This python version probably requires to use swig with the '-classic' option" +# error "This python version requires swig to be run with the '-classic' option" # endif #endif @@ -2356,11 +2494,12 @@ #define SWIG_name "_sparsetools" -#define SWIGVERSION 0x010328 +#define SWIGVERSION 0x010331 +#define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) const_cast(static_cast(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast(a)) +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) #include @@ -2427,6 +2566,7 @@ #define SWIG_FILE_WITH_INIT +#include "Python.h" #include "numpy/arrayobject.h" #include "complex_ops.h" #include "sparsetools.h" @@ -2862,7 +3002,7 @@ if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { - if (val) *val = static_cast(v); + if (val) *val = static_cast< int >(v); } } return res; @@ -2917,12 +3057,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -2948,7 +3088,6 @@ arg5 = (float*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3041,12 +3180,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -3072,7 +3211,6 @@ arg5 = (double*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3165,12 +3303,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -3196,7 +3334,6 @@ arg5 = (long double*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3289,12 +3426,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -3320,7 +3457,6 @@ arg5 = (npy_cfloat*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3413,12 +3549,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -3444,7 +3580,6 @@ arg5 = (npy_cdouble*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3537,12 +3672,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -3568,7 +3703,6 @@ arg5 = (npy_clongdouble*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3813,7 +3947,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n csrtocsc<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -3864,12 +3998,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -3895,7 +4029,6 @@ arg5 = (float*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3988,12 +4121,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4019,7 +4152,6 @@ arg5 = (double*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4112,12 +4244,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4143,7 +4275,6 @@ arg5 = (long double*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4236,12 +4367,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4267,7 +4398,6 @@ arg5 = (npy_cfloat*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4360,12 +4490,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4391,7 +4521,6 @@ arg5 = (npy_cdouble*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4484,12 +4613,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4515,7 +4644,6 @@ arg5 = (npy_clongdouble*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4760,7 +4888,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n csctocsr<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -4811,12 +4939,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4842,7 +4970,6 @@ arg5 = (float*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4935,12 +5062,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -4966,7 +5093,6 @@ arg5 = (double*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5059,12 +5185,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -5090,7 +5216,6 @@ arg5 = (long double*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5183,12 +5308,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -5214,7 +5339,6 @@ arg5 = (npy_cfloat*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5307,12 +5431,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -5338,7 +5462,6 @@ arg5 = (npy_cdouble*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5431,12 +5554,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -5462,7 +5585,6 @@ arg5 = (npy_clongdouble*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5707,7 +5829,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocoo'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n csrtocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -5762,17 +5884,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -5798,7 +5920,6 @@ arg6 = (float*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -5895,17 +6016,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -5931,7 +6052,6 @@ arg6 = (double*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6028,17 +6148,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -6064,7 +6184,6 @@ arg6 = (long double*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6161,17 +6280,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -6197,7 +6316,6 @@ arg6 = (npy_cfloat*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6294,17 +6412,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -6330,7 +6448,6 @@ arg6 = (npy_cdouble*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6427,17 +6544,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -6463,7 +6580,6 @@ arg6 = (npy_clongdouble*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6744,7 +6860,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n cootocsr<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -6795,12 +6911,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -6826,7 +6942,6 @@ arg5 = (float*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -6919,12 +7034,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -6950,7 +7065,6 @@ arg5 = (double*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7043,12 +7157,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -7074,7 +7188,6 @@ arg5 = (long double*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7167,12 +7280,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -7198,7 +7311,6 @@ arg5 = (npy_cfloat*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7291,12 +7403,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -7322,7 +7434,6 @@ arg5 = (npy_cdouble*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7415,12 +7526,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -7446,7 +7557,6 @@ arg5 = (npy_clongdouble*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7691,7 +7801,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocoo'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n csctocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -7746,17 +7856,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -7782,7 +7892,6 @@ arg6 = (float*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -7879,17 +7988,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -7915,7 +8024,6 @@ arg6 = (double*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8012,17 +8120,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -8048,7 +8156,6 @@ arg6 = (long double*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8145,17 +8252,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -8181,7 +8288,6 @@ arg6 = (npy_cfloat*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8278,17 +8384,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -8314,7 +8420,6 @@ arg6 = (npy_cdouble*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8411,17 +8516,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -8447,7 +8552,6 @@ arg6 = (npy_clongdouble*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8728,7 +8832,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n cootocsc<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -8791,12 +8895,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -8846,7 +8950,6 @@ arg8 = (float*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -8969,12 +9072,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -9024,7 +9127,6 @@ arg8 = (double*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9147,12 +9249,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -9202,7 +9304,6 @@ arg8 = (long double*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9325,12 +9426,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -9380,7 +9481,6 @@ arg8 = (npy_cfloat*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9503,12 +9603,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -9558,7 +9658,6 @@ arg8 = (npy_cdouble*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9681,12 +9780,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -9736,7 +9835,6 @@ arg8 = (npy_clongdouble*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10089,7 +10187,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrplcsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrplcsr'.\n Possible C/C++ prototypes are:\n csrplcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -10152,12 +10250,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -10207,7 +10305,6 @@ arg8 = (float*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10330,12 +10427,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -10385,7 +10482,6 @@ arg8 = (double*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10508,12 +10604,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -10563,7 +10659,6 @@ arg8 = (long double*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10686,12 +10781,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -10741,7 +10836,6 @@ arg8 = (npy_cfloat*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10864,12 +10958,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -10919,7 +11013,6 @@ arg8 = (npy_cdouble*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11042,12 +11135,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -11097,7 +11190,6 @@ arg8 = (npy_clongdouble*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11450,7 +11542,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscplcsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscplcsc'.\n Possible C/C++ prototypes are:\n cscplcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -11513,12 +11605,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -11568,7 +11660,6 @@ arg8 = (float*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11691,12 +11782,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -11746,7 +11837,6 @@ arg8 = (double*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11869,12 +11959,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -11924,7 +12014,6 @@ arg8 = (long double*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12047,12 +12136,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -12102,7 +12191,6 @@ arg8 = (npy_cfloat*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12225,12 +12313,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -12280,7 +12368,6 @@ arg8 = (npy_cdouble*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12403,12 +12490,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -12458,7 +12545,6 @@ arg8 = (npy_clongdouble*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12811,7 +12897,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmucsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n csrmucsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -12874,12 +12960,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -12929,7 +13015,6 @@ arg8 = (float*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13052,12 +13137,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -13107,7 +13192,6 @@ arg8 = (double*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13230,12 +13314,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -13285,7 +13369,6 @@ arg8 = (long double*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13408,12 +13491,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -13463,7 +13546,6 @@ arg8 = (npy_cfloat*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13586,12 +13668,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -13641,7 +13723,6 @@ arg8 = (npy_cdouble*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13764,12 +13845,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -13819,7 +13900,6 @@ arg8 = (npy_clongdouble*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -14172,7 +14252,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmucsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n cscmucsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -14215,12 +14295,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -14254,7 +14334,6 @@ arg6 = (float*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14331,12 +14410,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -14370,7 +14449,6 @@ arg6 = (double*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14447,12 +14525,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -14486,7 +14564,6 @@ arg6 = (long double*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14563,12 +14640,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -14602,7 +14679,6 @@ arg6 = (npy_cfloat*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14679,12 +14755,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -14718,7 +14794,6 @@ arg6 = (npy_cdouble*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14795,12 +14870,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -14834,7 +14909,6 @@ arg6 = (npy_clongdouble*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15101,7 +15175,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmux'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n csrmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n csrmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n csrmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n csrmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n csrmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n csrmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); return NULL; } @@ -15144,12 +15218,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -15183,7 +15257,6 @@ arg6 = (float*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15260,12 +15333,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -15299,7 +15372,6 @@ arg6 = (double*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15376,12 +15448,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -15415,7 +15487,6 @@ arg6 = (long double*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15492,12 +15563,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -15531,7 +15602,6 @@ arg6 = (npy_cfloat*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15608,12 +15678,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -15647,7 +15717,6 @@ arg6 = (npy_cdouble*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15724,12 +15793,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -15763,7 +15832,6 @@ arg6 = (npy_clongdouble*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -16030,7 +16098,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmux'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n cscmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n cscmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n cscmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n cscmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n cscmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n cscmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); return NULL; } @@ -16093,12 +16161,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -16148,7 +16216,6 @@ arg8 = (float*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16271,12 +16338,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -16326,7 +16393,6 @@ arg8 = (double*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16449,12 +16515,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -16504,7 +16570,6 @@ arg8 = (long double*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16627,12 +16692,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -16682,7 +16747,6 @@ arg8 = (npy_cfloat*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16805,12 +16869,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -16860,7 +16924,6 @@ arg8 = (npy_cdouble*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16983,12 +17046,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -17038,7 +17101,6 @@ arg8 = (npy_clongdouble*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17391,7 +17453,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrelmulcsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrelmulcsr'.\n Possible C/C++ prototypes are:\n csrelmulcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -17454,12 +17516,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -17509,7 +17571,6 @@ arg8 = (float*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17632,12 +17693,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -17687,7 +17748,6 @@ arg8 = (double*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17810,12 +17870,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -17865,7 +17925,6 @@ arg8 = (long double*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17988,12 +18047,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -18043,7 +18102,6 @@ arg8 = (npy_cfloat*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18166,12 +18224,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -18221,7 +18279,6 @@ arg8 = (npy_cdouble*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18344,12 +18401,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -18399,7 +18456,6 @@ arg8 = (npy_clongdouble*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18752,7 +18808,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscelmulcsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscelmulcsc'.\n Possible C/C++ prototypes are:\n cscelmulcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -18803,17 +18859,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -18831,7 +18887,6 @@ arg5 = (float*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -18918,17 +18973,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -18946,7 +19001,6 @@ arg5 = (double*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19033,17 +19087,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -19061,7 +19115,6 @@ arg5 = (long double*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19148,17 +19201,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -19176,7 +19229,6 @@ arg5 = (npy_cfloat*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19263,17 +19315,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -19291,7 +19343,6 @@ arg5 = (npy_cdouble*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19378,17 +19429,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { int size[1] = { -1 @@ -19401,9 +19452,8 @@ if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "spdiags" "', argument " "5"" of type '" "npy_clongdouble const []""'"); } - arg5 = reinterpret_cast(argp5); + arg5 = reinterpret_cast< npy_clongdouble * >(argp5); spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19642,7 +19692,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'spdiags'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n spdiags<(float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long double)>(int const,int const,int const,int const [],long double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cfloat)>(int const,int const,int const,int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cdouble)>(int const,int const,int const,int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_clongdouble)>(int const,int const,int const,int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -19678,12 +19728,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -19714,7 +19764,6 @@ arg6 = (float*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19771,12 +19820,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -19807,7 +19856,6 @@ arg6 = (double*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19864,12 +19912,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -19900,7 +19948,6 @@ arg6 = (long double*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19957,12 +20004,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -19993,7 +20040,6 @@ arg6 = (npy_cfloat*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20050,12 +20096,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -20086,7 +20132,6 @@ arg6 = (npy_cdouble*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20144,12 +20189,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[1] = { -1 @@ -20178,9 +20223,8 @@ if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "csrtodense" "', argument " "6"" of type '" "npy_clongdouble []""'"); } - arg6 = reinterpret_cast(argp6); + arg6 = reinterpret_cast< npy_clongdouble * >(argp6); csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20434,7 +20478,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtodense'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n csrtodense<(float)>(int const,int const,int const [],int const [],float const [],float [])\n csrtodense<(double)>(int const,int const,int const [],int const [],double const [],double [])\n csrtodense<(long double)>(int const,int const,int const [],int const [],long double const [],long double [])\n csrtodense<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat [])\n csrtodense<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble [])\n csrtodense<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble [])\n"); return NULL; } @@ -20477,12 +20521,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[2] = { -1,-1 @@ -20492,7 +20536,6 @@ arg3 = (float*) array3->data; } densetocsr(arg1,arg2,(float const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20565,12 +20608,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[2] = { -1,-1 @@ -20580,7 +20623,6 @@ arg3 = (double*) array3->data; } densetocsr(arg1,arg2,(double const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20653,12 +20695,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[2] = { -1,-1 @@ -20668,7 +20710,6 @@ arg3 = (long double*) array3->data; } densetocsr(arg1,arg2,(long double const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20741,12 +20782,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[2] = { -1,-1 @@ -20756,7 +20797,6 @@ arg3 = (npy_cfloat*) array3->data; } densetocsr(arg1,arg2,(npy_cfloat const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20829,12 +20869,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { int size[2] = { -1,-1 @@ -20844,7 +20884,6 @@ arg3 = (npy_cdouble*) array3->data; } densetocsr(arg1,arg2,(npy_cdouble const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20917,19 +20956,18 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "densetocsr" "', argument " "3"" of type '" "npy_clongdouble const []""'"); } - arg3 = reinterpret_cast(argp3); + arg3 = reinterpret_cast< npy_clongdouble * >(argp3); densetocsr(arg1,arg2,(npy_clongdouble const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -21096,7 +21134,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'densetocsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n densetocsr<(float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long double)>(int const,int const,long double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cfloat)>(int const,int const,npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cdouble)>(int const,int const,npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_clongdouble)>(int const,int const,npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -21178,7 +21216,7 @@ #ifdef __cplusplus } #endif -/************************************************************************* +/* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to @@ -21190,9 +21228,9 @@ * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. - + * * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop though that array, and handle each type individually. + * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a @@ -21204,7 +21242,7 @@ * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. - + * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding @@ -21217,7 +21255,7 @@ * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. -**/ + * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { @@ -21230,30 +21268,47 @@ #define SWIGRUNTIME_DEBUG #endif + SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; - swig_module_info *module_head; - static int init_run = 0; + swig_module_info *module_head, *iter; + int found; clientdata = clientdata; - if (init_run) return; - init_run = 1; + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + } - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); - if (module_head) { + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; - } else { - /* This is the first module loaded */ - swig_module.next = &swig_module; - SWIG_SetModule(clientdata, &swig_module); } /* Now work on filling in swig_module.types */ @@ -21566,7 +21621,7 @@ } SWIGINTERN PyObject * - SWIG_globals() { + SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; @@ -21611,11 +21666,11 @@ swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { - char *c = methods[i].ml_doc; + const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; - char *name = c + 10; + const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { From scipy-svn at scipy.org Mon Jan 8 00:25:59 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 7 Jan 2007 23:25:59 -0600 (CST) Subject: [Scipy-svn] r2502 - trunk/Lib/sparse/sparsetools Message-ID: <20070108052559.9A76839C04D@new.scipy.org> Author: wnbell Date: 2007-01-07 23:25:56 -0600 (Sun, 07 Jan 2007) New Revision: 2502 Modified: trunk/Lib/sparse/sparsetools/numpy.i trunk/Lib/sparse/sparsetools/sparsetools.py trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx Log: Changed (int) and ("%d") to (npy_intp) and ("%" NPY_INTP_FMT) where appropriate This is necessary on 64bit systems Modified: trunk/Lib/sparse/sparsetools/numpy.i =================================================================== --- trunk/Lib/sparse/sparsetools/numpy.i 2007-01-07 04:20:54 UTC (rev 2501) +++ trunk/Lib/sparse/sparsetools/numpy.i 2007-01-08 05:25:56 UTC (rev 2502) @@ -20,6 +20,7 @@ #define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) #define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) + /* Given a PyObject, return a string describing its type. */ char* pytype_string(PyObject* py_obj) { @@ -216,7 +217,7 @@ * array has the specified shape, return 1. Otherwise, set the python * error string and return 0. */ -int require_size(PyArrayObject* ary, int* size, int n) { +int require_size(PyArrayObject* ary, npy_intp * size, int n) { int i; int success = 1; int len; @@ -235,14 +236,14 @@ } else { - sprintf(s, "%d,", size[i]); + sprintf(s,"%" NPY_INTP_FMT ",", size[i]); } strcat(desired_dims,s); } len = strlen(desired_dims); desired_dims[len-1] = ']'; for (i = 0; i < n; i++) { - sprintf(s, "%d,", array_size(ary,i)); + sprintf(s,"%" NPY_INTP_FMT ",", array_size(ary,i)); strcat(actual_dims,s); } len = strlen(actual_dims); @@ -284,7 +285,7 @@ /* One dimensional input arrays */ %define TYPEMAP_IN1(type,typecode) %typemap(in) type* IN_ARRAY1 (PyArrayObject* array=NULL, int is_new_object) { - int size[1] = {-1}; + npy_intp size[1] = {-1}; array = obj_to_array_contiguous_allow_conversion($input, typecode, &is_new_object); if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; $1 = (type*) array->data; @@ -330,7 +331,7 @@ %define TYPEMAP_IN2(type,typecode) %typemap(in) (type* IN_ARRAY2) (PyArrayObject* array=NULL, int is_new_object) { - int size[2] = {-1,-1}; + npy_intp size[2] = {-1,-1}; array = obj_to_array_contiguous_allow_conversion($input, typecode, &is_new_object); if (!array || !require_dimensions(array,2) || !require_size(array,size,1)) SWIG_fail; $1 = (type*) array->data; Modified: trunk/Lib/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-07 04:20:54 UTC (rev 2501) +++ trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-08 05:25:56 UTC (rev 2502) @@ -1,16 +1,10 @@ -# This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.31 -# +# This file was created automatically by SWIG 1.3.28. # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. import _sparsetools import new new_instancemethod = new.instancemethod -try: - _swig_property = property -except NameError: - pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): @@ -33,11 +27,6 @@ if method: return method(self) raise AttributeError,name -def _swig_repr(self): - try: strthis = "proxy of " + self.this.__repr__() - except: strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) - import types try: _object = types.ObjectType @@ -51,7 +40,7 @@ def csrtocsc(*args): - """ + """ csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, @@ -69,10 +58,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csrtocsc(*args) + return _sparsetools.csrtocsc(*args) def csctocsr(*args): - """ + """ csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, @@ -90,10 +79,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csctocsr(*args) + return _sparsetools.csctocsr(*args) def csrtocoo(*args): - """ + """ csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, @@ -111,10 +100,10 @@ std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csrtocoo(*args) + return _sparsetools.csrtocoo(*args) def cootocsr(*args): - """ + """ cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) @@ -134,10 +123,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.cootocsr(*args) + return _sparsetools.cootocsr(*args) def csctocoo(*args): - """ + """ csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, @@ -155,10 +144,10 @@ std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csctocoo(*args) + return _sparsetools.csctocoo(*args) def cootocsc(*args): - """ + """ cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) @@ -178,10 +167,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.cootocsc(*args) + return _sparsetools.cootocsc(*args) def csrplcsr(*args): - """ + """ csrplcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -201,10 +190,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrplcsr(*args) + return _sparsetools.csrplcsr(*args) def cscplcsc(*args): - """ + """ cscplcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -224,10 +213,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscplcsc(*args) + return _sparsetools.cscplcsc(*args) def csrmucsr(*args): - """ + """ csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -247,10 +236,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrmucsr(*args) + return _sparsetools.csrmucsr(*args) def cscmucsc(*args): - """ + """ cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -270,10 +259,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscmucsc(*args) + return _sparsetools.cscmucsc(*args) def csrmux(*args): - """ + """ csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, std::vector<(float)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, @@ -287,10 +276,10 @@ csrmux(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ - return _sparsetools.csrmux(*args) + return _sparsetools.csrmux(*args) def cscmux(*args): - """ + """ cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, std::vector<(float)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, @@ -304,10 +293,10 @@ cscmux(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ - return _sparsetools.cscmux(*args) + return _sparsetools.cscmux(*args) def csrelmulcsr(*args): - """ + """ csrelmulcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -327,10 +316,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrelmulcsr(*args) + return _sparsetools.csrelmulcsr(*args) def cscelmulcsc(*args): - """ + """ cscelmulcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -350,10 +339,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscelmulcsc(*args) + return _sparsetools.cscelmulcsc(*args) def spdiags(*args): - """ + """ spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(float)> Ax) @@ -373,10 +362,10 @@ std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(npy_clongdouble)> Ax) """ - return _sparsetools.spdiags(*args) + return _sparsetools.spdiags(*args) def csrtodense(*args): - """ + """ csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, long double Ax, @@ -388,10 +377,10 @@ csrtodense(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, npy_clongdouble Mx) """ - return _sparsetools.csrtodense(*args) + return _sparsetools.csrtodense(*args) def densetocsr(*args): - """ + """ densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(float)> Ax) densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, @@ -405,5 +394,5 @@ densetocsr(int n_row, int n_col, npy_clongdouble Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(npy_clongdouble)> Ax) """ - return _sparsetools.densetocsr(*args) + return _sparsetools.densetocsr(*args) Modified: trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-07 04:20:54 UTC (rev 2501) +++ trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-08 05:25:56 UTC (rev 2502) @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.31 + * Version 1.3.28 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -27,10 +27,12 @@ }; #endif -/* ----------------------------------------------------------------------------- +/*********************************************************************** + * * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ + * + ************************************************************************/ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR @@ -87,13 +89,7 @@ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - +/* exporting methods for Windows DLLs */ #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) @@ -102,11 +98,7 @@ # define SWIGEXPORT __declspec(dllexport) # endif # else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif +# define SWIGEXPORT # endif #endif @@ -119,25 +111,21 @@ # endif #endif -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - /* Python.h has to appear first */ #include -/* ----------------------------------------------------------------------------- +/*********************************************************************** * swigrun.swg * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "3" +#define SWIG_RUNTIME_VERSION "2" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -358,7 +346,7 @@ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + if (*f1 != *f2) return (int)(*f1 - *f2); } return (l1 - f1) - (l2 - f2); } @@ -714,11 +702,13 @@ +/* Python.h has to appear first */ +#include /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf +# define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif @@ -728,7 +718,7 @@ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 +#define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * @@ -739,70 +729,36 @@ va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); + return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) +#define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del +#define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif +#define PyExc_StopIteration PyExc_RuntimeError +#define PyObject_GenericGetAttr 0 +#define Py_NotImplemented PyExc_RuntimeError #endif -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif +#define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} #endif -/* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif +#define PySequence_Size PySequence_Length #endif -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -#endif - /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ @@ -977,17 +933,15 @@ #endif -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * +/*********************************************************************** * pyrun.swg * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. * - * ----------------------------------------------------------------------------- */ + * Author : David Beazley (beazley at cs.uchicago.edu) + ************************************************************************/ /* Common SWIG API */ @@ -1195,7 +1149,7 @@ SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { - PyObject *none = Py_BuildValue((char*)""); + PyObject *none = Py_BuildValue(""); Py_DECREF(none); return none; } @@ -1217,6 +1171,7 @@ return none; } + /* PySwigClientData */ typedef struct { @@ -1252,7 +1207,7 @@ PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); /* the klass element */ data->klass = obj; - Py_INCREF(data->klass); + Py_INCREF(obj); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; @@ -1261,17 +1216,15 @@ } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); #else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } + data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, (char *)"__new__"); + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); Py_INCREF(data->newargs); +#endif } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); @@ -1299,6 +1252,7 @@ SWIGRUNTIME void PySwigClientData_Del(PySwigClientData* data) { + Py_XDECREF(data->klass); Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); @@ -1351,22 +1305,14 @@ } SWIGRUNTIME PyObject * -#ifdef METH_NOARGS PySwigObject_repr(PySwigObject *v) -#else -PySwigObject_repr(PySwigObject *v, PyObject *args) -#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); Py_DECREF(hex); if (v->next) { -#ifdef METH_NOARGS PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); -#else - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); -#endif PyString_ConcatAndDel(&repr,nrep); } return repr; @@ -1375,11 +1321,7 @@ SWIGRUNTIME int PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { -#ifdef METH_NOARGS PyObject *repr = PySwigObject_repr(v); -#else - PyObject *repr = PySwigObject_repr(v, NULL); -#endif if (repr) { fputs(PyString_AsString(repr), fp); Py_DECREF(repr); @@ -1528,7 +1470,7 @@ else { PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); + PyObject *obj = sobj->own ? Py_True : Py_False; if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { @@ -1544,6 +1486,7 @@ } #endif } + Py_INCREF(obj); return obj; } } @@ -1556,7 +1499,6 @@ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else @@ -1567,7 +1509,6 @@ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif @@ -1915,13 +1856,14 @@ if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { + } #ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } + else if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } #endif + if (!obj) { obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); @@ -1949,6 +1891,7 @@ } } + /* Acquire a pointer value */ SWIGRUNTIME int @@ -2054,7 +1997,7 @@ void *vptr = 0; /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) { desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; @@ -2128,14 +2071,6 @@ } return inst; #else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; @@ -2147,56 +2082,11 @@ Py_DECREF(inst); return NULL; } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif -#endif } -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - PySwigObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - /* Create a new pointer object */ SWIGRUNTIME PyObject * @@ -2314,35 +2204,7 @@ } } -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = PyString_FromString(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - /* For backward compatibility only */ @@ -2483,7 +2345,7 @@ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires swig to be run with the '-classic' option" +# warning "This python version probably requires to use swig with the '-classic' option" # endif #endif @@ -2494,12 +2356,11 @@ #define SWIG_name "_sparsetools" -#define SWIGVERSION 0x010331 -#define SWIG_VERSION SWIGVERSION +#define SWIGVERSION 0x010328 -#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) +#define SWIG_as_voidptr(a) const_cast(static_cast(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast(a)) #include @@ -2592,6 +2453,7 @@ #define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) #define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) + /* Given a PyObject, return a string describing its type. */ char* pytype_string(PyObject* py_obj) { @@ -2788,7 +2650,7 @@ * array has the specified shape, return 1. Otherwise, set the python * error string and return 0. */ -int require_size(PyArrayObject* ary, int* size, int n) { +int require_size(PyArrayObject* ary, npy_intp * size, int n) { int i; int success = 1; int len; @@ -2807,14 +2669,14 @@ } else { - sprintf(s, "%d,", size[i]); + sprintf(s,"%" NPY_INTP_FMT ",", size[i]); } strcat(desired_dims,s); } len = strlen(desired_dims); desired_dims[len-1] = ']'; for (i = 0; i < n; i++) { - sprintf(s, "%d,", array_size(ary,i)); + sprintf(s,"%" NPY_INTP_FMT ",", array_size(ary,i)); strcat(actual_dims,s); } len = strlen(actual_dims); @@ -3002,7 +2864,7 @@ if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { - if (val) *val = static_cast< int >(v); + if (val) *val = static_cast(v); } } return res; @@ -3057,14 +2919,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -3072,7 +2934,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -3080,7 +2942,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -3088,6 +2950,7 @@ arg5 = (float*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3180,14 +3043,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -3195,7 +3058,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -3203,7 +3066,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -3211,6 +3074,7 @@ arg5 = (double*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3303,14 +3167,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -3318,7 +3182,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -3326,7 +3190,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -3334,6 +3198,7 @@ arg5 = (long double*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3426,14 +3291,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -3441,7 +3306,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -3449,7 +3314,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -3457,6 +3322,7 @@ arg5 = (npy_cfloat*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3549,14 +3415,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -3564,7 +3430,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -3572,7 +3438,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -3580,6 +3446,7 @@ arg5 = (npy_cdouble*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3672,14 +3539,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -3687,7 +3554,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -3695,7 +3562,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -3703,6 +3570,7 @@ arg5 = (npy_clongdouble*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3947,7 +3815,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n csrtocsc<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocsc'"); return NULL; } @@ -3998,14 +3866,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4013,7 +3881,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4021,7 +3889,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -4029,6 +3897,7 @@ arg5 = (float*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4121,14 +3990,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4136,7 +4005,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4144,7 +4013,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -4152,6 +4021,7 @@ arg5 = (double*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4244,14 +4114,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4259,7 +4129,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4267,7 +4137,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -4275,6 +4145,7 @@ arg5 = (long double*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4367,14 +4238,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4382,7 +4253,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4390,7 +4261,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -4398,6 +4269,7 @@ arg5 = (npy_cfloat*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4490,14 +4362,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4505,7 +4377,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4513,7 +4385,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -4521,6 +4393,7 @@ arg5 = (npy_cdouble*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4613,14 +4486,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4628,7 +4501,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4636,7 +4509,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -4644,6 +4517,7 @@ arg5 = (npy_clongdouble*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4888,7 +4762,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n csctocsr<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocsr'"); return NULL; } @@ -4939,14 +4813,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -4954,7 +4828,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -4962,7 +4836,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -4970,6 +4844,7 @@ arg5 = (float*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5062,14 +4937,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -5077,7 +4952,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -5085,7 +4960,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -5093,6 +4968,7 @@ arg5 = (double*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5185,14 +5061,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -5200,7 +5076,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -5208,7 +5084,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -5216,6 +5092,7 @@ arg5 = (long double*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5308,14 +5185,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -5323,7 +5200,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -5331,7 +5208,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -5339,6 +5216,7 @@ arg5 = (npy_cfloat*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5431,14 +5309,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -5446,7 +5324,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -5454,7 +5332,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -5462,6 +5340,7 @@ arg5 = (npy_cdouble*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5554,14 +5433,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -5569,7 +5448,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -5577,7 +5456,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -5585,6 +5464,7 @@ arg5 = (npy_clongdouble*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5829,7 +5709,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n csrtocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocoo'"); return NULL; } @@ -5884,19 +5764,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -5904,7 +5784,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -5912,7 +5792,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); @@ -5920,6 +5800,7 @@ arg6 = (float*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6016,19 +5897,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -6036,7 +5917,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -6044,7 +5925,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); @@ -6052,6 +5933,7 @@ arg6 = (double*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6148,19 +6030,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -6168,7 +6050,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -6176,7 +6058,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); @@ -6184,6 +6066,7 @@ arg6 = (long double*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6280,19 +6163,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -6300,7 +6183,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -6308,7 +6191,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); @@ -6316,6 +6199,7 @@ arg6 = (npy_cfloat*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6412,19 +6296,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -6432,7 +6316,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -6440,7 +6324,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); @@ -6448,6 +6332,7 @@ arg6 = (npy_cdouble*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6544,19 +6429,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -6564,7 +6449,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -6572,7 +6457,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); @@ -6580,6 +6465,7 @@ arg6 = (npy_clongdouble*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6860,7 +6746,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n cootocsr<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsr'"); return NULL; } @@ -6911,14 +6797,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -6926,7 +6812,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -6934,7 +6820,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -6942,6 +6828,7 @@ arg5 = (float*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7034,14 +6921,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -7049,7 +6936,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -7057,7 +6944,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -7065,6 +6952,7 @@ arg5 = (double*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7157,14 +7045,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -7172,7 +7060,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -7180,7 +7068,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -7188,6 +7076,7 @@ arg5 = (long double*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7280,14 +7169,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -7295,7 +7184,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -7303,7 +7192,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -7311,6 +7200,7 @@ arg5 = (npy_cfloat*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7403,14 +7293,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -7418,7 +7308,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -7426,7 +7316,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -7434,6 +7324,7 @@ arg5 = (npy_cdouble*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7526,14 +7417,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -7541,7 +7432,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -7549,7 +7440,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -7557,6 +7448,7 @@ arg5 = (npy_clongdouble*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7801,7 +7693,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n csctocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocoo'"); return NULL; } @@ -7856,19 +7748,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -7876,7 +7768,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -7884,7 +7776,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); @@ -7892,6 +7784,7 @@ arg6 = (float*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -7988,19 +7881,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -8008,7 +7901,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -8016,7 +7909,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); @@ -8024,6 +7917,7 @@ arg6 = (double*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8120,19 +8014,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -8140,7 +8034,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -8148,7 +8042,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); @@ -8156,6 +8050,7 @@ arg6 = (long double*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8252,19 +8147,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -8272,7 +8167,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -8280,7 +8175,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); @@ -8288,6 +8183,7 @@ arg6 = (npy_cfloat*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8384,19 +8280,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -8404,7 +8300,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -8412,7 +8308,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); @@ -8420,6 +8316,7 @@ arg6 = (npy_cdouble*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8516,19 +8413,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -8536,7 +8433,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); @@ -8544,7 +8441,7 @@ arg5 = (int*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); @@ -8552,6 +8449,7 @@ arg6 = (npy_clongdouble*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8832,7 +8730,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n cootocsc<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsc'"); return NULL; } @@ -8895,14 +8793,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -8910,7 +8808,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -8918,7 +8816,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -8926,7 +8824,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -8934,7 +8832,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -8942,7 +8840,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); @@ -8950,6 +8848,7 @@ arg8 = (float*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9072,14 +8971,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -9087,7 +8986,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -9095,7 +8994,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -9103,7 +9002,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -9111,7 +9010,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -9119,7 +9018,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); @@ -9127,6 +9026,7 @@ arg8 = (double*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9249,14 +9149,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -9264,7 +9164,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -9272,7 +9172,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -9280,7 +9180,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -9288,7 +9188,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -9296,7 +9196,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); @@ -9304,6 +9204,7 @@ arg8 = (long double*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9426,14 +9327,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -9441,7 +9342,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -9449,7 +9350,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -9457,7 +9358,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -9465,7 +9366,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -9473,7 +9374,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); @@ -9481,6 +9382,7 @@ arg8 = (npy_cfloat*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9603,14 +9505,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -9618,7 +9520,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -9626,7 +9528,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -9634,7 +9536,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -9642,7 +9544,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -9650,7 +9552,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); @@ -9658,6 +9560,7 @@ arg8 = (npy_cdouble*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9780,14 +9683,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -9795,7 +9698,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -9803,7 +9706,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -9811,7 +9714,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -9819,7 +9722,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -9827,7 +9730,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); @@ -9835,6 +9738,7 @@ arg8 = (npy_clongdouble*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10187,7 +10091,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrplcsr'.\n Possible C/C++ prototypes are:\n csrplcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrplcsr'"); return NULL; } @@ -10250,14 +10154,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -10265,7 +10169,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -10273,7 +10177,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -10281,7 +10185,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -10289,7 +10193,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -10297,7 +10201,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); @@ -10305,6 +10209,7 @@ arg8 = (float*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10427,14 +10332,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -10442,7 +10347,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -10450,7 +10355,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -10458,7 +10363,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -10466,7 +10371,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -10474,7 +10379,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); @@ -10482,6 +10387,7 @@ arg8 = (double*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10604,14 +10510,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -10619,7 +10525,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -10627,7 +10533,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -10635,7 +10541,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -10643,7 +10549,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -10651,7 +10557,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); @@ -10659,6 +10565,7 @@ arg8 = (long double*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10781,14 +10688,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -10796,7 +10703,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -10804,7 +10711,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -10812,7 +10719,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -10820,7 +10727,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -10828,7 +10735,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); @@ -10836,6 +10743,7 @@ arg8 = (npy_cfloat*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10958,14 +10866,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -10973,7 +10881,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -10981,7 +10889,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -10989,7 +10897,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -10997,7 +10905,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -11005,7 +10913,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); @@ -11013,6 +10921,7 @@ arg8 = (npy_cdouble*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11135,14 +11044,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -11150,7 +11059,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -11158,7 +11067,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -11166,7 +11075,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -11174,7 +11083,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -11182,7 +11091,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); @@ -11190,6 +11099,7 @@ arg8 = (npy_clongdouble*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11542,7 +11452,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscplcsc'.\n Possible C/C++ prototypes are:\n cscplcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscplcsc'"); return NULL; } @@ -11605,14 +11515,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -11620,7 +11530,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -11628,7 +11538,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -11636,7 +11546,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -11644,7 +11554,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -11652,7 +11562,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); @@ -11660,6 +11570,7 @@ arg8 = (float*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11782,14 +11693,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -11797,7 +11708,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -11805,7 +11716,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -11813,7 +11724,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -11821,7 +11732,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -11829,7 +11740,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); @@ -11837,6 +11748,7 @@ arg8 = (double*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11959,14 +11871,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -11974,7 +11886,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -11982,7 +11894,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -11990,7 +11902,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -11998,7 +11910,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -12006,7 +11918,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); @@ -12014,6 +11926,7 @@ arg8 = (long double*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12136,14 +12049,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -12151,7 +12064,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -12159,7 +12072,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -12167,7 +12080,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -12175,7 +12088,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -12183,7 +12096,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); @@ -12191,6 +12104,7 @@ arg8 = (npy_cfloat*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12313,14 +12227,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -12328,7 +12242,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -12336,7 +12250,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -12344,7 +12258,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -12352,7 +12266,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -12360,7 +12274,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); @@ -12368,6 +12282,7 @@ arg8 = (npy_cdouble*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12490,14 +12405,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -12505,7 +12420,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -12513,7 +12428,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -12521,7 +12436,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -12529,7 +12444,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -12537,7 +12452,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); @@ -12545,6 +12460,7 @@ arg8 = (npy_clongdouble*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12897,7 +12813,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n csrmucsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmucsr'"); return NULL; } @@ -12960,14 +12876,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -12975,7 +12891,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -12983,7 +12899,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -12991,7 +12907,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -12999,7 +12915,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -13007,7 +12923,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); @@ -13015,6 +12931,7 @@ arg8 = (float*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13137,14 +13054,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -13152,7 +13069,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -13160,7 +13077,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -13168,7 +13085,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -13176,7 +13093,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -13184,7 +13101,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); @@ -13192,6 +13109,7 @@ arg8 = (double*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13314,14 +13232,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -13329,7 +13247,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -13337,7 +13255,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -13345,7 +13263,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -13353,7 +13271,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -13361,7 +13279,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); @@ -13369,6 +13287,7 @@ arg8 = (long double*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13491,14 +13410,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -13506,7 +13425,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -13514,7 +13433,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -13522,7 +13441,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -13530,7 +13449,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -13538,7 +13457,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); @@ -13546,6 +13465,7 @@ arg8 = (npy_cfloat*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13668,14 +13588,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -13683,7 +13603,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -13691,7 +13611,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -13699,7 +13619,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -13707,7 +13627,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -13715,7 +13635,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); @@ -13723,6 +13643,7 @@ arg8 = (npy_cdouble*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13845,14 +13766,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -13860,7 +13781,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -13868,7 +13789,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -13876,7 +13797,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -13884,7 +13805,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -13892,7 +13813,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); @@ -13900,6 +13821,7 @@ arg8 = (npy_clongdouble*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -14252,7 +14174,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n cscmucsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmucsc'"); return NULL; } @@ -14295,14 +14217,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -14310,7 +14232,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -14318,7 +14240,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -14326,7 +14248,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); @@ -14334,6 +14256,7 @@ arg6 = (float*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14410,14 +14333,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -14425,7 +14348,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -14433,7 +14356,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -14441,7 +14364,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); @@ -14449,6 +14372,7 @@ arg6 = (double*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14525,14 +14449,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -14540,7 +14464,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -14548,7 +14472,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -14556,7 +14480,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); @@ -14564,6 +14488,7 @@ arg6 = (long double*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14640,14 +14565,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -14655,7 +14580,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -14663,7 +14588,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -14671,7 +14596,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); @@ -14679,6 +14604,7 @@ arg6 = (npy_cfloat*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14755,14 +14681,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -14770,7 +14696,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -14778,7 +14704,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -14786,7 +14712,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); @@ -14794,6 +14720,7 @@ arg6 = (npy_cdouble*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14870,14 +14797,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -14885,7 +14812,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -14893,7 +14820,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -14901,7 +14828,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); @@ -14909,6 +14836,7 @@ arg6 = (npy_clongdouble*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15175,7 +15103,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n csrmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n csrmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n csrmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n csrmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n csrmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n csrmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmux'"); return NULL; } @@ -15218,14 +15146,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -15233,7 +15161,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -15241,7 +15169,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -15249,7 +15177,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); @@ -15257,6 +15185,7 @@ arg6 = (float*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15333,14 +15262,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -15348,7 +15277,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -15356,7 +15285,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -15364,7 +15293,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); @@ -15372,6 +15301,7 @@ arg6 = (double*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15448,14 +15378,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -15463,7 +15393,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -15471,7 +15401,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -15479,7 +15409,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); @@ -15487,6 +15417,7 @@ arg6 = (long double*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15563,14 +15494,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -15578,7 +15509,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -15586,7 +15517,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -15594,7 +15525,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); @@ -15602,6 +15533,7 @@ arg6 = (npy_cfloat*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15678,14 +15610,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -15693,7 +15625,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -15701,7 +15633,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -15709,7 +15641,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); @@ -15717,6 +15649,7 @@ arg6 = (npy_cdouble*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15793,14 +15726,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -15808,7 +15741,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -15816,7 +15749,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -15824,7 +15757,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); @@ -15832,6 +15765,7 @@ arg6 = (npy_clongdouble*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); + resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -16098,7 +16032,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n cscmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n cscmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n cscmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n cscmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n cscmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n cscmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmux'"); return NULL; } @@ -16161,14 +16095,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -16176,7 +16110,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -16184,7 +16118,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -16192,7 +16126,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -16200,7 +16134,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -16208,7 +16142,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); @@ -16216,6 +16150,7 @@ arg8 = (float*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16338,14 +16273,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -16353,7 +16288,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -16361,7 +16296,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -16369,7 +16304,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -16377,7 +16312,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -16385,7 +16320,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); @@ -16393,6 +16328,7 @@ arg8 = (double*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16515,14 +16451,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -16530,7 +16466,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -16538,7 +16474,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -16546,7 +16482,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -16554,7 +16490,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -16562,7 +16498,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); @@ -16570,6 +16506,7 @@ arg8 = (long double*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16692,14 +16629,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -16707,7 +16644,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -16715,7 +16652,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -16723,7 +16660,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -16731,7 +16668,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -16739,7 +16676,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); @@ -16747,6 +16684,7 @@ arg8 = (npy_cfloat*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16869,14 +16807,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -16884,7 +16822,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -16892,7 +16830,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -16900,7 +16838,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -16908,7 +16846,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -16916,7 +16854,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); @@ -16924,6 +16862,7 @@ arg8 = (npy_cdouble*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17046,14 +16985,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -17061,7 +17000,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -17069,7 +17008,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -17077,7 +17016,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -17085,7 +17024,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -17093,7 +17032,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); @@ -17101,6 +17040,7 @@ arg8 = (npy_clongdouble*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17453,7 +17393,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrelmulcsr'.\n Possible C/C++ prototypes are:\n csrelmulcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrelmulcsr'"); return NULL; } @@ -17516,14 +17456,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -17531,7 +17471,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -17539,7 +17479,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -17547,7 +17487,7 @@ arg5 = (float*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -17555,7 +17495,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -17563,7 +17503,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); @@ -17571,6 +17511,7 @@ arg8 = (float*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17693,14 +17634,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -17708,7 +17649,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -17716,7 +17657,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -17724,7 +17665,7 @@ arg5 = (double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -17732,7 +17673,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -17740,7 +17681,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); @@ -17748,6 +17689,7 @@ arg8 = (double*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17870,14 +17812,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -17885,7 +17827,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -17893,7 +17835,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -17901,7 +17843,7 @@ arg5 = (long double*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -17909,7 +17851,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -17917,7 +17859,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); @@ -17925,6 +17867,7 @@ arg8 = (long double*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18047,14 +17990,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -18062,7 +18005,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -18070,7 +18013,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -18078,7 +18021,7 @@ arg5 = (npy_cfloat*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -18086,7 +18029,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -18094,7 +18037,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); @@ -18102,6 +18045,7 @@ arg8 = (npy_cfloat*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18224,14 +18168,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -18239,7 +18183,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -18247,7 +18191,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -18255,7 +18199,7 @@ arg5 = (npy_cdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -18263,7 +18207,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -18271,7 +18215,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); @@ -18279,6 +18223,7 @@ arg8 = (npy_cdouble*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18401,14 +18346,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -18416,7 +18361,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -18424,7 +18369,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -18432,7 +18377,7 @@ arg5 = (npy_clongdouble*) array5->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); @@ -18440,7 +18385,7 @@ arg6 = (int*) array6->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array7 = obj_to_array_contiguous_allow_conversion(obj6, PyArray_INT, &is_new_object7); @@ -18448,7 +18393,7 @@ arg7 = (int*) array7->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); @@ -18456,6 +18401,7 @@ arg8 = (npy_clongdouble*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18808,7 +18754,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscelmulcsc'.\n Possible C/C++ prototypes are:\n cscelmulcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscelmulcsc'"); return NULL; } @@ -18859,19 +18805,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -18879,7 +18825,7 @@ arg4 = (int*) array4->data; } { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -18887,6 +18833,7 @@ arg5 = (float*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -18973,19 +18920,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -18993,7 +18940,7 @@ arg4 = (int*) array4->data; } { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -19001,6 +18948,7 @@ arg5 = (double*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19087,19 +19035,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19107,7 +19055,7 @@ arg4 = (int*) array4->data; } { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -19115,6 +19063,7 @@ arg5 = (long double*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19201,19 +19150,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19221,7 +19170,7 @@ arg4 = (int*) array4->data; } { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -19229,6 +19178,7 @@ arg5 = (npy_cfloat*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19315,19 +19265,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19335,7 +19285,7 @@ arg4 = (int*) array4->data; } { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -19343,6 +19293,7 @@ arg5 = (npy_cdouble*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19429,19 +19380,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast< int >(val3); + arg3 = static_cast(val3); { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19452,8 +19403,9 @@ if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "spdiags" "', argument " "5"" of type '" "npy_clongdouble const []""'"); } - arg5 = reinterpret_cast< npy_clongdouble * >(argp5); + arg5 = reinterpret_cast(argp5); spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19692,7 +19644,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n spdiags<(float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long double)>(int const,int const,int const,int const [],long double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cfloat)>(int const,int const,int const,int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cdouble)>(int const,int const,int const,int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_clongdouble)>(int const,int const,int const,int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'spdiags'"); return NULL; } @@ -19728,14 +19680,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -19743,7 +19695,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19751,7 +19703,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); @@ -19764,6 +19716,7 @@ arg6 = (float*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); + resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19820,14 +19773,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -19835,7 +19788,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19843,7 +19796,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); @@ -19856,6 +19809,7 @@ arg6 = (double*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); + resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19912,14 +19866,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -19927,7 +19881,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -19935,7 +19889,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); @@ -19948,6 +19902,7 @@ arg6 = (long double*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); + resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20004,14 +19959,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -20019,7 +19974,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -20027,7 +19982,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); @@ -20040,6 +19995,7 @@ arg6 = (npy_cfloat*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6); + resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20096,14 +20052,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -20111,7 +20067,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -20119,7 +20075,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); @@ -20132,6 +20088,7 @@ arg6 = (npy_cdouble*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6); + resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20189,14 +20146,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[1] = { + npy_intp size[1] = { -1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); @@ -20204,7 +20161,7 @@ arg3 = (int*) array3->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); @@ -20212,7 +20169,7 @@ arg4 = (int*) array4->data; } { - int size[1] = { + npy_intp size[1] = { -1 }; array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); @@ -20223,8 +20180,9 @@ if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "csrtodense" "', argument " "6"" of type '" "npy_clongdouble []""'"); } - arg6 = reinterpret_cast< npy_clongdouble * >(argp6); + arg6 = reinterpret_cast(argp6); csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6); + resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20478,7 +20436,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n csrtodense<(float)>(int const,int const,int const [],int const [],float const [],float [])\n csrtodense<(double)>(int const,int const,int const [],int const [],double const [],double [])\n csrtodense<(long double)>(int const,int const,int const [],int const [],long double const [],long double [])\n csrtodense<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat [])\n csrtodense<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble [])\n csrtodense<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtodense'"); return NULL; } @@ -20521,14 +20479,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_FLOAT, &is_new_object3); @@ -20536,6 +20494,7 @@ arg3 = (float*) array3->data; } densetocsr(arg1,arg2,(float const (*))arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20608,14 +20567,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_DOUBLE, &is_new_object3); @@ -20623,6 +20582,7 @@ arg3 = (double*) array3->data; } densetocsr(arg1,arg2,(double const (*))arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20695,14 +20655,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGDOUBLE, &is_new_object3); @@ -20710,6 +20670,7 @@ arg3 = (long double*) array3->data; } densetocsr(arg1,arg2,(long double const (*))arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20782,14 +20743,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CFLOAT, &is_new_object3); @@ -20797,6 +20758,7 @@ arg3 = (npy_cfloat*) array3->data; } densetocsr(arg1,arg2,(npy_cfloat const (*))arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20869,14 +20831,14 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); { - int size[2] = { + npy_intp size[2] = { -1,-1 }; array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CDOUBLE, &is_new_object3); @@ -20884,6 +20846,7 @@ arg3 = (npy_cdouble*) array3->data; } densetocsr(arg1,arg2,(npy_cdouble const (*))arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20956,18 +20919,19 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast< int >(val1); + arg1 = static_cast(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast< int >(val2); + arg2 = static_cast(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "densetocsr" "', argument " "3"" of type '" "npy_clongdouble const []""'"); } - arg3 = reinterpret_cast< npy_clongdouble * >(argp3); + arg3 = reinterpret_cast(argp3); densetocsr(arg1,arg2,(npy_clongdouble const (*))arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -21134,7 +21098,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n densetocsr<(float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long double)>(int const,int const,long double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cfloat)>(int const,int const,npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cdouble)>(int const,int const,npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_clongdouble)>(int const,int const,npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'densetocsr'"); return NULL; } @@ -21216,7 +21180,7 @@ #ifdef __cplusplus } #endif -/* ----------------------------------------------------------------------------- +/************************************************************************* * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to @@ -21228,9 +21192,9 @@ * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. - * + * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop through that array, and handle each type individually. + * array. We just loop though that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a @@ -21242,7 +21206,7 @@ * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. - * + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding @@ -21255,7 +21219,7 @@ * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. - * ----------------------------------------------------------------------------- */ +**/ #ifdef __cplusplus extern "C" { @@ -21268,47 +21232,30 @@ #define SWIGRUNTIME_DEBUG #endif - SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; - swig_module_info *module_head, *iter; - int found; + swig_module_info *module_head; + static int init_run = 0; clientdata = clientdata; - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next==0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - } + if (init_run) return; + init_run = 1; + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; - iter=module_head; - do { - if (iter==&swig_module) { - found=1; - break; - } - iter=iter->next; - } while (iter!= module_head); - - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ + if (module_head) { swig_module.next = module_head->next; module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); } /* Now work on filling in swig_module.types */ @@ -21621,7 +21568,7 @@ } SWIGINTERN PyObject * - SWIG_globals(void) { + SWIG_globals() { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; @@ -21666,11 +21613,11 @@ swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { - const char *c = methods[i].ml_doc; + char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; - const char *name = c + 10; + char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { From scipy-svn at scipy.org Mon Jan 8 02:56:25 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 01:56:25 -0600 (CST) Subject: [Scipy-svn] r2503 - trunk/Lib/sparse Message-ID: <20070108075625.35A2939C04D@new.scipy.org> Author: timl Date: 2007-01-08 01:56:16 -0600 (Mon, 08 Jan 2007) New Revision: 2503 Modified: trunk/Lib/sparse/sparse.py Log: fix typo Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-08 05:25:56 UTC (rev 2502) +++ trunk/Lib/sparse/sparse.py 2007-01-08 07:56:16 UTC (rev 2503) @@ -799,7 +799,7 @@ cd = conj(self.data) else: cd = self.data - y = sparsetool.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) + y = sparsetools.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an From scipy-svn at scipy.org Mon Jan 8 04:24:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 03:24:22 -0600 (CST) Subject: [Scipy-svn] r2504 - trunk/Lib/sparse Message-ID: <20070108092422.E216E39C04D@new.scipy.org> Author: stefan Date: 2007-01-08 03:24:01 -0600 (Mon, 08 Jan 2007) New Revision: 2504 Modified: trunk/Lib/sparse/info.py Log: Fix sparse.info docstring. Modified: trunk/Lib/sparse/info.py =================================================================== --- trunk/Lib/sparse/info.py 2007-01-08 07:56:16 UTC (rev 2503) +++ trunk/Lib/sparse/info.py 2007-01-08 09:24:01 UTC (rev 2504) @@ -25,12 +25,13 @@ Example: Construct a 10x1000 lil_matrix and add some values to it: >>> from scipy import sparse, linsolve - >>> from numpy import rand, linalg + >>> from numpy import linalg + >>> from numpy.random import rand >>> A = sparse.lil_matrix((1000, 1000)) >>> A[0, :100] = rand(100) >>> A[1, 100:200] = A[0, :100] >>> A.setdiag(rand(1000)) - + Now convert it to CSR format and solve (A A^T) x = b for x: >>> A = A.tocsr() >>> b = rand(1000) From scipy-svn at scipy.org Mon Jan 8 04:50:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 03:50:27 -0600 (CST) Subject: [Scipy-svn] r2505 - trunk/Lib/sparse/sparsetools Message-ID: <20070108095027.D5C7F39C015@new.scipy.org> Author: wnbell Date: 2007-01-08 03:50:20 -0600 (Mon, 08 Jan 2007) New Revision: 2505 Modified: trunk/Lib/sparse/sparsetools/sparsetools.py trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx Log: Regenerated sparsetools with SWIG 1.3.32 to fix const errors Modified: trunk/Lib/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-08 09:24:01 UTC (rev 2504) +++ trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-08 09:50:20 UTC (rev 2505) @@ -1,10 +1,16 @@ -# This file was created automatically by SWIG 1.3.28. +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.32 +# # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. import _sparsetools import new new_instancemethod = new.instancemethod +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): @@ -27,6 +33,11 @@ if method: return method(self) raise AttributeError,name +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + import types try: _object = types.ObjectType @@ -40,7 +51,7 @@ def csrtocsc(*args): - """ + """ csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, @@ -58,10 +69,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csrtocsc(*args) + return _sparsetools.csrtocsc(*args) def csctocsr(*args): - """ + """ csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, @@ -79,10 +90,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csctocsr(*args) + return _sparsetools.csctocsr(*args) def csrtocoo(*args): - """ + """ csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, @@ -100,10 +111,10 @@ std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csrtocoo(*args) + return _sparsetools.csrtocoo(*args) def cootocsr(*args): - """ + """ cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) @@ -123,10 +134,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.cootocsr(*args) + return _sparsetools.cootocsr(*args) def csctocoo(*args): - """ + """ csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, @@ -144,10 +155,10 @@ std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.csctocoo(*args) + return _sparsetools.csctocoo(*args) def cootocsc(*args): - """ + """ cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) @@ -167,10 +178,10 @@ std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_clongdouble)> Bx) """ - return _sparsetools.cootocsc(*args) + return _sparsetools.cootocsc(*args) def csrplcsr(*args): - """ + """ csrplcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -190,10 +201,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrplcsr(*args) + return _sparsetools.csrplcsr(*args) def cscplcsc(*args): - """ + """ cscplcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -213,10 +224,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscplcsc(*args) + return _sparsetools.cscplcsc(*args) def csrmucsr(*args): - """ + """ csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -236,10 +247,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrmucsr(*args) + return _sparsetools.csrmucsr(*args) def cscmucsc(*args): - """ + """ cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -259,10 +270,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscmucsc(*args) + return _sparsetools.cscmucsc(*args) def csrmux(*args): - """ + """ csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, std::vector<(float)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, @@ -276,10 +287,10 @@ csrmux(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ - return _sparsetools.csrmux(*args) + return _sparsetools.csrmux(*args) def cscmux(*args): - """ + """ cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, std::vector<(float)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, @@ -293,10 +304,10 @@ cscmux(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ - return _sparsetools.cscmux(*args) + return _sparsetools.cscmux(*args) def csrelmulcsr(*args): - """ + """ csrelmulcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) @@ -316,10 +327,10 @@ int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.csrelmulcsr(*args) + return _sparsetools.csrelmulcsr(*args) def cscelmulcsc(*args): - """ + """ cscelmulcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) @@ -339,10 +350,10 @@ int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ - return _sparsetools.cscelmulcsc(*args) + return _sparsetools.cscelmulcsc(*args) def spdiags(*args): - """ + """ spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(float)> Ax) @@ -362,10 +373,10 @@ std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(npy_clongdouble)> Ax) """ - return _sparsetools.spdiags(*args) + return _sparsetools.spdiags(*args) def csrtodense(*args): - """ + """ csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, long double Ax, @@ -377,10 +388,10 @@ csrtodense(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, npy_clongdouble Mx) """ - return _sparsetools.csrtodense(*args) + return _sparsetools.csrtodense(*args) def densetocsr(*args): - """ + """ densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(float)> Ax) densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, @@ -394,5 +405,5 @@ densetocsr(int n_row, int n_col, npy_clongdouble Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(npy_clongdouble)> Ax) """ - return _sparsetools.densetocsr(*args) + return _sparsetools.densetocsr(*args) Modified: trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-08 09:24:01 UTC (rev 2504) +++ trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-08 09:50:20 UTC (rev 2505) @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.28 + * Version 1.3.32 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -27,12 +27,10 @@ }; #endif -/*********************************************************************** - * +/* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. - * - ************************************************************************/ + * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR @@ -89,7 +87,13 @@ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif -/* exporting methods for Windows DLLs */ +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) @@ -98,7 +102,11 @@ # define SWIGEXPORT __declspec(dllexport) # endif # else -# define SWIGEXPORT +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif # endif #endif @@ -111,21 +119,25 @@ # endif #endif +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + /* Python.h has to appear first */ #include -/*********************************************************************** +/* ----------------------------------------------------------------------------- * swigrun.swg * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * - ************************************************************************/ + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" +#define SWIG_RUNTIME_VERSION "3" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -346,7 +358,7 @@ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (int)(*f1 - *f2); + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (l1 - f1) - (l2 - f2); } @@ -702,13 +714,11 @@ -/* Python.h has to appear first */ -#include /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf +# define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif @@ -718,7 +728,7 @@ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE -#define SWIG_PYBUFFER_SIZE 1024 +# define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * @@ -729,36 +739,70 @@ va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 -#define PyObject_Del(op) PyMem_DEL((op)) +# define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL -#define PyObject_DEL PyObject_Del +# define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 -#define PyExc_StopIteration PyExc_RuntimeError -#define PyObject_GenericGetAttr 0 -#define Py_NotImplemented PyExc_RuntimeError +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif #endif +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 -#define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif #endif +/* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 -#define PySequence_Size PySequence_Length +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif #endif +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +#endif + /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ @@ -933,15 +977,17 @@ #endif -/*********************************************************************** +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * * pyrun.swg * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. * - * Author : David Beazley (beazley at cs.uchicago.edu) - ************************************************************************/ + * ----------------------------------------------------------------------------- */ /* Common SWIG API */ @@ -1149,7 +1195,7 @@ SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { - PyObject *none = Py_BuildValue(""); + PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } @@ -1171,7 +1217,6 @@ return none; } - /* PySwigClientData */ typedef struct { @@ -1207,7 +1252,7 @@ PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); /* the klass element */ data->klass = obj; - Py_INCREF(obj); + Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; @@ -1216,15 +1261,17 @@ } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); #else - data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, (char *)"__new__"); - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } Py_INCREF(data->newargs); -#endif } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); @@ -1252,7 +1299,6 @@ SWIGRUNTIME void PySwigClientData_Del(PySwigClientData* data) { - Py_XDECREF(data->klass); Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); @@ -1305,14 +1351,22 @@ } SWIGRUNTIME PyObject * +#ifdef METH_NOARGS PySwigObject_repr(PySwigObject *v) +#else +PySwigObject_repr(PySwigObject *v, PyObject *args) +#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); Py_DECREF(hex); if (v->next) { +#ifdef METH_NOARGS PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); +#else + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); +#endif PyString_ConcatAndDel(&repr,nrep); } return repr; @@ -1321,7 +1375,11 @@ SWIGRUNTIME int PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { +#ifdef METH_NOARGS PyObject *repr = PySwigObject_repr(v); +#else + PyObject *repr = PySwigObject_repr(v, NULL); +#endif if (repr) { fputs(PyString_AsString(repr), fp); Py_DECREF(repr); @@ -1470,7 +1528,7 @@ else { PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = sobj->own ? Py_True : Py_False; + PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { @@ -1486,7 +1544,6 @@ } #endif } - Py_INCREF(obj); return obj; } } @@ -1499,6 +1556,7 @@ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else @@ -1509,6 +1567,7 @@ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif @@ -1856,14 +1915,13 @@ if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } + } else { #ifdef PyWeakref_CheckProxy - else if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } #endif - if (!obj) { obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); @@ -1891,7 +1949,6 @@ } } - /* Acquire a pointer value */ SWIGRUNTIME int @@ -1997,7 +2054,7 @@ void *vptr = 0; /* here we get the method pointer for callbacks */ - char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) { desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; @@ -2071,6 +2128,14 @@ } return inst; #else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst; + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + return (PyObject *) inst; +#else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; @@ -2082,11 +2147,56 @@ Py_DECREF(inst); return NULL; } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif +#endif } +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + return NULL; + } else { + PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + PySwigObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + /* Create a new pointer object */ SWIGRUNTIME PyObject * @@ -2204,7 +2314,35 @@ } } +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = PyString_FromString(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); + } else { + swig_module_info *swig_module = SWIG_Python_GetModule(); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCObject_FromVoidPtr(descriptor, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + /* For backward compatibility only */ @@ -2345,7 +2483,7 @@ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) -# warning "This python version probably requires to use swig with the '-classic' option" +# error "This python version requires swig to be run with the '-classic' option" # endif #endif @@ -2356,11 +2494,12 @@ #define SWIG_name "_sparsetools" -#define SWIGVERSION 0x010328 +#define SWIGVERSION 0x010332 +#define SWIG_VERSION SWIGVERSION -#define SWIG_as_voidptr(a) const_cast(static_cast(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast(a)) +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) #include @@ -2864,7 +3003,7 @@ if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { - if (val) *val = static_cast(v); + if (val) *val = static_cast< int >(v); } } return res; @@ -2919,12 +3058,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -2950,7 +3089,6 @@ arg5 = (float*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3043,12 +3181,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -3074,7 +3212,6 @@ arg5 = (double*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3167,12 +3304,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -3198,7 +3335,6 @@ arg5 = (long double*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3291,12 +3427,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -3322,7 +3458,6 @@ arg5 = (npy_cfloat*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3415,12 +3550,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -3446,7 +3581,6 @@ arg5 = (npy_cdouble*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3539,12 +3673,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -3570,7 +3704,6 @@ arg5 = (npy_clongdouble*) array5->data; } csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3815,7 +3948,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n csrtocsc<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -3866,12 +3999,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -3897,7 +4030,6 @@ arg5 = (float*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3990,12 +4122,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4021,7 +4153,6 @@ arg5 = (double*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4114,12 +4245,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4145,7 +4276,6 @@ arg5 = (long double*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4238,12 +4368,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4269,7 +4399,6 @@ arg5 = (npy_cfloat*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4362,12 +4491,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4393,7 +4522,6 @@ arg5 = (npy_cdouble*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4486,12 +4614,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4517,7 +4645,6 @@ arg5 = (npy_clongdouble*) array5->data; } csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4762,7 +4889,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n csctocsr<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -4813,12 +4940,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4844,7 +4971,6 @@ arg5 = (float*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4937,12 +5063,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -4968,7 +5094,6 @@ arg5 = (double*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5061,12 +5186,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -5092,7 +5217,6 @@ arg5 = (long double*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5185,12 +5309,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -5216,7 +5340,6 @@ arg5 = (npy_cfloat*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5309,12 +5432,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -5340,7 +5463,6 @@ arg5 = (npy_cdouble*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5433,12 +5555,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -5464,7 +5586,6 @@ arg5 = (npy_clongdouble*) array5->data; } csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5709,7 +5830,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtocoo'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n csrtocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -5764,17 +5885,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -5800,7 +5921,6 @@ arg6 = (float*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -5897,17 +6017,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -5933,7 +6053,6 @@ arg6 = (double*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6030,17 +6149,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -6066,7 +6185,6 @@ arg6 = (long double*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6163,17 +6281,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -6199,7 +6317,6 @@ arg6 = (npy_cfloat*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6296,17 +6413,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -6332,7 +6449,6 @@ arg6 = (npy_cdouble*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6429,17 +6545,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -6465,7 +6581,6 @@ arg6 = (npy_clongdouble*) array6->data; } cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -6746,7 +6861,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n cootocsr<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -6797,12 +6912,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -6828,7 +6943,6 @@ arg5 = (float*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -6921,12 +7035,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -6952,7 +7066,6 @@ arg5 = (double*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7045,12 +7158,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -7076,7 +7189,6 @@ arg5 = (long double*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7169,12 +7281,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -7200,7 +7312,6 @@ arg5 = (npy_cfloat*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7293,12 +7404,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -7324,7 +7435,6 @@ arg5 = (npy_cdouble*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7417,12 +7527,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -7448,7 +7558,6 @@ arg5 = (npy_clongdouble*) array5->data; } csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -7693,7 +7802,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csctocoo'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n csctocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -7748,17 +7857,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -7784,7 +7893,6 @@ arg6 = (float*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -7881,17 +7989,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -7917,7 +8025,6 @@ arg6 = (double*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8014,17 +8121,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -8050,7 +8157,6 @@ arg6 = (long double*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8147,17 +8253,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -8183,7 +8289,6 @@ arg6 = (npy_cfloat*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8280,17 +8385,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -8316,7 +8421,6 @@ arg6 = (npy_cdouble*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8413,17 +8517,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsc" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -8449,7 +8553,6 @@ arg6 = (npy_clongdouble*) array6->data; } cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8730,7 +8833,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cootocsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n cootocsc<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -8793,12 +8896,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -8848,7 +8951,6 @@ arg8 = (float*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -8971,12 +9073,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -9026,7 +9128,6 @@ arg8 = (double*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9149,12 +9250,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -9204,7 +9305,6 @@ arg8 = (long double*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9327,12 +9427,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -9382,7 +9482,6 @@ arg8 = (npy_cfloat*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9505,12 +9604,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -9560,7 +9659,6 @@ arg8 = (npy_cdouble*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9683,12 +9781,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrplcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrplcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -9738,7 +9836,6 @@ arg8 = (npy_clongdouble*) array8->data; } csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10091,7 +10188,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrplcsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrplcsr'.\n Possible C/C++ prototypes are:\n csrplcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -10154,12 +10251,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -10209,7 +10306,6 @@ arg8 = (float*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10332,12 +10428,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -10387,7 +10483,6 @@ arg8 = (double*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10510,12 +10605,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -10565,7 +10660,6 @@ arg8 = (long double*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10688,12 +10782,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -10743,7 +10837,6 @@ arg8 = (npy_cfloat*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10866,12 +10959,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -10921,7 +11014,6 @@ arg8 = (npy_cdouble*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11044,12 +11136,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscplcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscplcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -11099,7 +11191,6 @@ arg8 = (npy_clongdouble*) array8->data; } cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11452,7 +11543,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscplcsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscplcsc'.\n Possible C/C++ prototypes are:\n cscplcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -11515,12 +11606,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -11570,7 +11661,6 @@ arg8 = (float*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11693,12 +11783,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -11748,7 +11838,6 @@ arg8 = (double*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11871,12 +11960,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -11926,7 +12015,6 @@ arg8 = (long double*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12049,12 +12137,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -12104,7 +12192,6 @@ arg8 = (npy_cfloat*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12227,12 +12314,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -12282,7 +12369,6 @@ arg8 = (npy_cdouble*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12405,12 +12491,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmucsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmucsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -12460,7 +12546,6 @@ arg8 = (npy_clongdouble*) array8->data; } csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12813,7 +12898,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmucsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n csrmucsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -12876,12 +12961,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -12931,7 +13016,6 @@ arg8 = (float*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13054,12 +13138,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -13109,7 +13193,6 @@ arg8 = (double*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13232,12 +13315,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -13287,7 +13370,6 @@ arg8 = (long double*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13410,12 +13492,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -13465,7 +13547,6 @@ arg8 = (npy_cfloat*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13588,12 +13669,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -13643,7 +13724,6 @@ arg8 = (npy_cdouble*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13766,12 +13846,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmucsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmucsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -13821,7 +13901,6 @@ arg8 = (npy_clongdouble*) array8->data; } cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -14174,7 +14253,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmucsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n cscmucsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -14217,12 +14296,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -14256,7 +14335,6 @@ arg6 = (float*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14333,12 +14411,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -14372,7 +14450,6 @@ arg6 = (double*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14449,12 +14526,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -14488,7 +14565,6 @@ arg6 = (long double*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14565,12 +14641,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -14604,7 +14680,6 @@ arg6 = (npy_cfloat*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14681,12 +14756,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -14720,7 +14795,6 @@ arg6 = (npy_cdouble*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -14797,12 +14871,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -14836,7 +14910,6 @@ arg6 = (npy_clongdouble*) array6->data; } csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15103,7 +15176,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrmux'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n csrmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n csrmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n csrmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n csrmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n csrmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n csrmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); return NULL; } @@ -15146,12 +15219,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -15185,7 +15258,6 @@ arg6 = (float*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15262,12 +15334,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -15301,7 +15373,6 @@ arg6 = (double*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15378,12 +15449,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -15417,7 +15488,6 @@ arg6 = (long double*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15494,12 +15564,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -15533,7 +15603,6 @@ arg6 = (npy_cfloat*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15610,12 +15679,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -15649,7 +15718,6 @@ arg6 = (npy_cdouble*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -15726,12 +15794,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscmux" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscmux" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -15765,7 +15833,6 @@ arg6 = (npy_clongdouble*) array6->data; } cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -16032,7 +16099,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscmux'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n cscmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n cscmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n cscmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n cscmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n cscmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n cscmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); return NULL; } @@ -16095,12 +16162,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -16150,7 +16217,6 @@ arg8 = (float*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16273,12 +16339,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -16328,7 +16394,6 @@ arg8 = (double*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16451,12 +16516,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -16506,7 +16571,6 @@ arg8 = (long double*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16629,12 +16693,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -16684,7 +16748,6 @@ arg8 = (npy_cfloat*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16807,12 +16870,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -16862,7 +16925,6 @@ arg8 = (npy_cdouble*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16985,12 +17047,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrelmulcsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrelmulcsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -17040,7 +17102,6 @@ arg8 = (npy_clongdouble*) array8->data; } csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17393,7 +17454,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrelmulcsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrelmulcsr'.\n Possible C/C++ prototypes are:\n csrelmulcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -17456,12 +17517,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -17511,7 +17572,6 @@ arg8 = (float*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17634,12 +17694,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -17689,7 +17749,6 @@ arg8 = (double*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17812,12 +17871,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -17867,7 +17926,6 @@ arg8 = (long double*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17990,12 +18048,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -18045,7 +18103,6 @@ arg8 = (npy_cfloat*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18168,12 +18225,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -18223,7 +18280,6 @@ arg8 = (npy_cdouble*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18346,12 +18402,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cscelmulcsc" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cscelmulcsc" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -18401,7 +18457,6 @@ arg8 = (npy_clongdouble*) array8->data; } cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); - resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18754,7 +18809,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'cscelmulcsc'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscelmulcsc'.\n Possible C/C++ prototypes are:\n cscelmulcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -18805,17 +18860,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -18833,7 +18888,6 @@ arg5 = (float*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -18920,17 +18974,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -18948,7 +19002,6 @@ arg5 = (double*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19035,17 +19088,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -19063,7 +19116,6 @@ arg5 = (long double*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19150,17 +19202,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -19178,7 +19230,6 @@ arg5 = (npy_cfloat*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19265,17 +19316,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -19293,7 +19344,6 @@ arg5 = (npy_cdouble*) array5->data; } spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19380,17 +19430,17 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "spdiags" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "spdiags" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "spdiags" "', argument " "3"" of type '" "int""'"); } - arg3 = static_cast(val3); + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 @@ -19403,9 +19453,8 @@ if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "spdiags" "', argument " "5"" of type '" "npy_clongdouble const []""'"); } - arg5 = reinterpret_cast(argp5); + arg5 = reinterpret_cast< npy_clongdouble * >(argp5); spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); - resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19644,7 +19693,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'spdiags'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n spdiags<(float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long double)>(int const,int const,int const,int const [],long double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cfloat)>(int const,int const,int const,int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cdouble)>(int const,int const,int const,int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_clongdouble)>(int const,int const,int const,int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -19680,12 +19729,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -19716,7 +19765,6 @@ arg6 = (float*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19773,12 +19821,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -19809,7 +19857,6 @@ arg6 = (double*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19866,12 +19913,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -19902,7 +19949,6 @@ arg6 = (long double*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19959,12 +20005,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -19995,7 +20041,6 @@ arg6 = (npy_cfloat*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20052,12 +20097,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -20088,7 +20133,6 @@ arg6 = (npy_cdouble*) temp6->data; } csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20146,12 +20190,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csrtodense" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csrtodense" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[1] = { -1 @@ -20180,9 +20224,8 @@ if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "csrtodense" "', argument " "6"" of type '" "npy_clongdouble []""'"); } - arg6 = reinterpret_cast(argp6); + arg6 = reinterpret_cast< npy_clongdouble * >(argp6); csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6); - resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20436,7 +20479,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'csrtodense'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n csrtodense<(float)>(int const,int const,int const [],int const [],float const [],float [])\n csrtodense<(double)>(int const,int const,int const [],int const [],double const [],double [])\n csrtodense<(long double)>(int const,int const,int const [],int const [],long double const [],long double [])\n csrtodense<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat [])\n csrtodense<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble [])\n csrtodense<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble [])\n"); return NULL; } @@ -20479,12 +20522,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[2] = { -1,-1 @@ -20494,7 +20537,6 @@ arg3 = (float*) array3->data; } densetocsr(arg1,arg2,(float const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20567,12 +20609,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[2] = { -1,-1 @@ -20582,7 +20624,6 @@ arg3 = (double*) array3->data; } densetocsr(arg1,arg2,(double const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20655,12 +20696,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[2] = { -1,-1 @@ -20670,7 +20711,6 @@ arg3 = (long double*) array3->data; } densetocsr(arg1,arg2,(long double const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20743,12 +20783,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[2] = { -1,-1 @@ -20758,7 +20798,6 @@ arg3 = (npy_cfloat*) array3->data; } densetocsr(arg1,arg2,(npy_cfloat const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20831,12 +20870,12 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); { npy_intp size[2] = { -1,-1 @@ -20846,7 +20885,6 @@ arg3 = (npy_cdouble*) array3->data; } densetocsr(arg1,arg2,(npy_cdouble const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20919,19 +20957,18 @@ if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "densetocsr" "', argument " "1"" of type '" "int""'"); } - arg1 = static_cast(val1); + arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } - arg2 = static_cast(val2); + arg2 = static_cast< int >(val2); res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); if (!SWIG_IsOK(res3)) { SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "densetocsr" "', argument " "3"" of type '" "npy_clongdouble const []""'"); } - arg3 = reinterpret_cast(argp3); + arg3 = reinterpret_cast< npy_clongdouble * >(argp3); densetocsr(arg1,arg2,(npy_clongdouble const (*))arg3,arg4,arg5,arg6); - resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -21098,7 +21135,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'densetocsr'"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n densetocsr<(float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long double)>(int const,int const,long double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cfloat)>(int const,int const,npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cdouble)>(int const,int const,npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_clongdouble)>(int const,int const,npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -21180,7 +21217,7 @@ #ifdef __cplusplus } #endif -/************************************************************************* +/* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to @@ -21192,9 +21229,9 @@ * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. - + * * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop though that array, and handle each type individually. + * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a @@ -21206,7 +21243,7 @@ * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. - + * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding @@ -21219,7 +21256,7 @@ * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. -**/ + * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { @@ -21232,30 +21269,47 @@ #define SWIGRUNTIME_DEBUG #endif + SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; - swig_module_info *module_head; - static int init_run = 0; + swig_module_info *module_head, *iter; + int found; clientdata = clientdata; - if (init_run) return; - init_run = 1; + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + } - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); - if (module_head) { + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; - } else { - /* This is the first module loaded */ - swig_module.next = &swig_module; - SWIG_SetModule(clientdata, &swig_module); } /* Now work on filling in swig_module.types */ @@ -21568,7 +21622,7 @@ } SWIGINTERN PyObject * - SWIG_globals() { + SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; @@ -21613,11 +21667,11 @@ swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { - char *c = methods[i].ml_doc; + const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; - char *name = c + 10; + const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { From scipy-svn at scipy.org Mon Jan 8 05:42:31 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 04:42:31 -0600 (CST) Subject: [Scipy-svn] r2506 - trunk/Lib/sparse Message-ID: <20070108104231.CE69A39C015@new.scipy.org> Author: wnbell Date: 2007-01-08 04:42:30 -0600 (Mon, 08 Jan 2007) New Revision: 2506 Modified: trunk/Lib/sparse/sparse.py Log: Removed default value for argument m in speye() The previous statement "m=None" wasn't handled correctly anyway. Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-08 09:50:20 UTC (rev 2505) +++ trunk/Lib/sparse/sparse.py 2007-01-08 10:42:30 UTC (rev 2506) @@ -2718,7 +2718,7 @@ return spdiags( diags, 0, n, n ) -def speye(n, m = None, k = 0, dtype = 'd'): +def speye(n, m, k = 0, dtype = 'd'): """ speye(n, m) returns a (n x m) matrix stored in CSC sparse matrix format, where the k-th diagonal is all ones, From scipy-svn at scipy.org Mon Jan 8 06:06:49 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 05:06:49 -0600 (CST) Subject: [Scipy-svn] r2507 - trunk/Lib/sparse Message-ID: <20070108110649.8D70839C08A@new.scipy.org> Author: wnbell Date: 2007-01-08 05:06:48 -0600 (Mon, 08 Jan 2007) New Revision: 2507 Modified: trunk/Lib/sparse/sparse.py Log: setdiag() now works for subdiagonals (k < 0) Resolves ticket #324 Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-08 10:42:30 UTC (rev 2506) +++ trunk/Lib/sparse/sparse.py 2007-01-08 11:06:48 UTC (rev 2507) @@ -424,13 +424,23 @@ """Fills the diagonal elements {a_ii} with the values from the given sequence. If k != 0, fills the off-diagonal elements {a_{i,i+k}} instead. + + values may have any length. If the diagonal is longer than values, + then the remaining diagonal entries will not be set. If values if + longer than the diagonal, then the remaining values are ignored. """ M, N = self.shape - if len(values) > min(M, N+k): - raise ValueError, "sequence of target values is too long" - for i, v in enumerate(values): - self[i, i+k] = v - return + if (k > 0 and k >= N) or (k < 0 and -k >= M): + raise ValueError, "k exceedes matrix dimensions" + if k < 0: + max_index = min(M+k,N,len(values)) + for i,v in enumerate(values[:max_index]): + self[i - k, i] = v + else: + max_index = min(M,N-k,len(values)) + for i,v in enumerate(values[:max_index]): + self[i, i + k] = v + def save(self, file_name, format = '%d %d %f\n'): try: From scipy-svn at scipy.org Mon Jan 8 21:36:37 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 20:36:37 -0600 (CST) Subject: [Scipy-svn] r2508 - trunk/Lib/sparse Message-ID: <20070109023637.3D2D739C086@new.scipy.org> Author: timl Date: 2007-01-08 20:36:32 -0600 (Mon, 08 Jan 2007) New Revision: 2508 Modified: trunk/Lib/sparse/sparse.py Log: ensure that the correct dtype is used for lil_matrix.__setitem__ Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-08 11:06:48 UTC (rev 2507) +++ trunk/Lib/sparse/sparse.py 2007-01-09 02:36:32 UTC (rev 2508) @@ -2391,6 +2391,10 @@ def __setitem__(self, index, x): + if isscalar(x): + x = self.dtype.type(x) + elif not isinstance(x, spmatrix): + x = numpy.asarray(x, dtype=self.dtype) try: assert len(index) == 2 except (AssertionError, TypeError): From scipy-svn at scipy.org Tue Jan 9 00:49:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 8 Jan 2007 23:49:11 -0600 (CST) Subject: [Scipy-svn] r2509 - trunk/Lib/sparse Message-ID: <20070109054911.3D96139C075@new.scipy.org> Author: timl Date: 2007-01-08 23:49:05 -0600 (Mon, 08 Jan 2007) New Revision: 2509 Modified: trunk/Lib/sparse/sparse.py Log: code cleanups Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-09 02:36:32 UTC (rev 2508) +++ trunk/Lib/sparse/sparse.py 2007-01-09 05:49:05 UTC (rev 2509) @@ -20,8 +20,8 @@ new[:old] = arr return new -MAXPRINT=50 -ALLOCSIZE=1000 +MAXPRINT = 50 +ALLOCSIZE = 1000 NZMAX = 100 @@ -83,9 +83,9 @@ self.maxprint = maxprint self.allocsize = allocsize - def astype( self, t ): + def astype(self, t): csc = self.tocsc() - return csc.astype( t ) + return csc.astype(t) def getmaxprint(self): try: @@ -158,7 +158,7 @@ return val[:-1] def __cmp__(self, other): - raise TypeError, "comparison of sparse matrices not implemented" + raise NotImplementedError, "comparison of sparse matrices not implemented" def __nonzero__(self): # Simple -- other ideas? return self.getnnz() > 0 @@ -383,18 +383,18 @@ # For some sparse matrix formats more efficient methods are # possible -- these should override this function. m, n = self.shape - if axis==0: + if axis == 0: # sum over columns # Does the following multiplication work in NumPy now? o = asmatrix(ones((1, m), dtype=self.dtype)) return o * self # o = ones(m, dtype=self.dtype) # return asmatrix(self.rmatvec(o)) - elif axis==1: + elif axis == 1: # sum over rows o = asmatrix(ones((n, 1), dtype=self.dtype)) return self * o - elif axis==None: + elif axis == None: # sum over rows and columns m, n = self.shape o0 = asmatrix(ones((1, m), dtype=self.dtype)) @@ -407,11 +407,11 @@ """Average the matrix over the given axis. If the axis is None, average over both rows and columns, returning a scalar. """ - if axis==0: + if axis == 0: mean = self.sum(0) mean *= 1.0 / self.shape[0] return mean - elif axis==1: + elif axis == 1: mean = self.sum(1) mean *= 1.0 / self.shape[1] return mean @@ -433,11 +433,11 @@ if (k > 0 and k >= N) or (k < 0 and -k >= M): raise ValueError, "k exceedes matrix dimensions" if k < 0: - max_index = min(M+k,N,len(values)) + max_index = min(M+k, N, len(values)) for i,v in enumerate(values[:max_index]): self[i - k, i] = v else: - max_index = min(M,N-k,len(values)) + max_index = min(M, N-k, len(values)) for i,v in enumerate(values[:max_index]): self[i, i + k] = v @@ -618,6 +618,7 @@ if self.dtype.char not in 'fdFD': self.data = 1.0 * self.data self.dtype = self.data.dtype + self.ftype = _transtabl[self.dtype.char] def astype(self, t): @@ -647,7 +648,7 @@ indptr,rowind,data = sparsetools.cscplcsc(self.shape[0],self.shape[1], \ self.indptr,self.rowind,self.data,\ ocs.indptr,ocs.rowind,ocs.data) - return csc_matrix((data,rowind,indptr),self.shape) + return csc_matrix((data,rowind,indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. return self.todense() + other @@ -762,7 +763,7 @@ # indptr[j+1] for j in xrange(n): out[j] = data[indptr[j] : indptr[j+1]].sum() - if axis==0: + if axis == 0: # Output is a (1 x n) dense matrix return asmatrix(out) else: @@ -784,8 +785,8 @@ #if len(other) != self.shape[1]: # raise ValueError, "dimension mismatch" oth = numpy.ravel(other) - y = sparsetools.cscmux(self.shape[0],self.shape[1],\ - self.indptr,self.rowind,self.data,oth) + y = sparsetools.cscmux(self.shape[0], self.shape[1],\ + self.indptr, self.rowind, self.data, oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -831,7 +832,7 @@ other = other.tocsc() indptr,rowind,data = sparsetools.cscmucsc(M,N,self.indptr,self.rowind,self.data,\ other.indptr,other.rowind,other.data) - return csc_matrix((data,rowind,indptr),(M,N)) + return csc_matrix((data, rowind, indptr), (M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! @@ -926,7 +927,6 @@ raise ValueError, "slicing with step != 1 not supported" if stop <= start: raise ValueError, "slice width must be >= 1" - startind = -1 indices = [] @@ -958,11 +958,11 @@ def tocoo(self): rows,cols,data = sparsetools.csctocoo(self.shape[0],self.shape[1],\ self.indptr,self.rowind,self.data) - return coo_matrix((data,(rows,cols)),self.shape) + return coo_matrix((data,(rows,cols)), self.shape) def tocsr(self): indptr,colind,data = sparsetools.csctocsr(self.shape[0],self.shape[1],self.indptr,self.rowind,self.data) - return csr_matrix((data,colind,indptr),self.shape) + return csr_matrix((data,colind,indptr), self.shape) def toarray(self): return self.tocsr().toarray() @@ -981,7 +981,7 @@ self.nzmax = nnz self._check() - def ensure_sorted_indices(self,inplace=False): + def ensure_sorted_indices(self, inplace=False): """Return a copy of this matrix where the row indices are sorted """ if inplace: @@ -992,6 +992,7 @@ else: return self.tocsr().tocsc() + def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() @@ -1380,7 +1381,6 @@ raise ValueError, "slicing with step != 1 not supported" if stop <= start: raise ValueError, "slice width must be >= 1" - startind = -1 indices = [] From scipy-svn at scipy.org Tue Jan 9 06:36:51 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 05:36:51 -0600 (CST) Subject: [Scipy-svn] r2510 - trunk/Lib/sparse/sparsetools Message-ID: <20070109113651.1DA9539C061@new.scipy.org> Author: wnbell Date: 2007-01-09 05:36:44 -0600 (Tue, 09 Jan 2007) New Revision: 2510 Modified: trunk/Lib/sparse/sparsetools/numpy.i trunk/Lib/sparse/sparsetools/sparsetools.h trunk/Lib/sparse/sparsetools/sparsetools.i trunk/Lib/sparse/sparsetools/sparsetools.py trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx Log: Templated index types in sparsetools.h Consolidated redundant code in sparsetools.i regenerated SWIG wrappers Modified: trunk/Lib/sparse/sparsetools/numpy.i =================================================================== --- trunk/Lib/sparse/sparsetools/numpy.i 2007-01-09 05:49:05 UTC (rev 2509) +++ trunk/Lib/sparse/sparsetools/numpy.i 2007-01-09 11:36:44 UTC (rev 2510) @@ -41,11 +41,14 @@ /* Given a Numeric typecode, return a string describing the type. */ -char* typecode_string(int typecode) { - char* type_names[20] = {"char","unsigned byte","byte","short", - "unsigned short","int","unsigned int","long", - "float","double","complex float","complex double", - "object","ntype","unkown"}; +char* type_names[20] = {"char","unsigned byte","byte","short", + "unsigned short","int","unsigned int","long", + "float","double","complex float","complex double", + "object","ntype","unkown"}; + char* typecode_string(int typecode) { + if(typecode < 0 || typecode > 19) + typecode = 19; + return type_names[typecode]; } @@ -298,7 +301,7 @@ /* Define concrete examples of the TYPEMAP_IN1 macros */ TYPEMAP_IN1(char, PyArray_CHAR ) TYPEMAP_IN1(unsigned char, PyArray_UBYTE ) -TYPEMAP_IN1(signed char, PyArray_SBYTE ) +TYPEMAP_IN1(signed char, PyArray_BYTE ) TYPEMAP_IN1(short, PyArray_SHORT ) TYPEMAP_IN1(int, PyArray_INT ) TYPEMAP_IN1(long, PyArray_LONG ) @@ -310,7 +313,7 @@ TYPEMAP_IN1(npy_clongdouble, PyArray_CLONGDOUBLE) TYPEMAP_IN1(const char, PyArray_CHAR ) TYPEMAP_IN1(const unsigned char, PyArray_UBYTE ) -TYPEMAP_IN1(const signed char, PyArray_SBYTE ) +TYPEMAP_IN1(const signed char, PyArray_BYTE ) TYPEMAP_IN1(const short, PyArray_SHORT ) TYPEMAP_IN1(const int, PyArray_INT ) TYPEMAP_IN1(const long, PyArray_LONG ) @@ -344,7 +347,7 @@ /* Define concrete examples of the TYPEMAP_IN2 macros */ TYPEMAP_IN2(char, PyArray_CHAR ) TYPEMAP_IN2(unsigned char, PyArray_UBYTE ) -TYPEMAP_IN2(signed char, PyArray_SBYTE ) +TYPEMAP_IN2(signed char, PyArray_BYTE ) TYPEMAP_IN2(short, PyArray_SHORT ) TYPEMAP_IN2(int, PyArray_INT ) TYPEMAP_IN2(long, PyArray_LONG ) @@ -356,7 +359,7 @@ TYPEMAP_IN2(npy_clongdouble, PyArray_CLONGDOUBLE) TYPEMAP_IN2(const char, PyArray_CHAR ) TYPEMAP_IN2(const unsigned char, PyArray_UBYTE ) -TYPEMAP_IN2(const signed char, PyArray_SBYTE ) +TYPEMAP_IN2(const signed char, PyArray_BYTE ) TYPEMAP_IN2(const short, PyArray_SHORT ) TYPEMAP_IN2(const int, PyArray_INT ) TYPEMAP_IN2(const long, PyArray_LONG ) @@ -408,7 +411,7 @@ /* Define concrete examples of the TYPEMAP_INPLACE1 macro */ TYPEMAP_INPLACE1(char, PyArray_CHAR ) TYPEMAP_INPLACE1(unsigned char, PyArray_UBYTE ) -TYPEMAP_INPLACE1(signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE1(signed char, PyArray_BYTE ) TYPEMAP_INPLACE1(short, PyArray_SHORT ) TYPEMAP_INPLACE1(int, PyArray_INT ) TYPEMAP_INPLACE1(long, PyArray_LONG ) @@ -420,7 +423,7 @@ TYPEMAP_INPLACE1(npy_clongdouble, PyArray_CLONGDOUBLE) TYPEMAP_INPLACE1(const char, PyArray_CHAR ) TYPEMAP_INPLACE1(const unsigned char, PyArray_UBYTE ) -TYPEMAP_INPLACE1(const signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE1(const signed char, PyArray_BYTE ) TYPEMAP_INPLACE1(const short, PyArray_SHORT ) TYPEMAP_INPLACE1(const int, PyArray_INT ) TYPEMAP_INPLACE1(const long, PyArray_LONG ) @@ -450,7 +453,7 @@ /* Define concrete examples of the TYPEMAP_INPLACE2 macro */ TYPEMAP_INPLACE2(char, PyArray_CHAR ) TYPEMAP_INPLACE2(unsigned char, PyArray_UBYTE ) -TYPEMAP_INPLACE2(signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE2(signed char, PyArray_BYTE ) TYPEMAP_INPLACE2(short, PyArray_SHORT ) TYPEMAP_INPLACE2(int, PyArray_INT ) TYPEMAP_INPLACE2(long, PyArray_LONG ) @@ -462,7 +465,7 @@ TYPEMAP_INPLACE2(npy_clongdouble, PyArray_CLONGDOUBLE) TYPEMAP_INPLACE2(const char, PyArray_CHAR ) TYPEMAP_INPLACE2(const unsigned char, PyArray_UBYTE ) -TYPEMAP_INPLACE2(const signed char, PyArray_SBYTE ) +TYPEMAP_INPLACE2(const signed char, PyArray_BYTE ) TYPEMAP_INPLACE2(const short, PyArray_SHORT ) TYPEMAP_INPLACE2(const int, PyArray_INT ) TYPEMAP_INPLACE2(const long, PyArray_LONG ) @@ -521,7 +524,7 @@ /* Define concrete examples of the TYPEMAP_ARGOUT1 macro */ TYPEMAP_ARGOUT1(char, PyArray_CHAR ) TYPEMAP_ARGOUT1(unsigned char, PyArray_UBYTE ) -TYPEMAP_ARGOUT1(signed char, PyArray_SBYTE ) +TYPEMAP_ARGOUT1(signed char, PyArray_BYTE ) TYPEMAP_ARGOUT1(short, PyArray_SHORT ) TYPEMAP_ARGOUT1(int, PyArray_INT ) TYPEMAP_ARGOUT1(long, PyArray_LONG ) @@ -549,7 +552,7 @@ /* Define concrete examples of the TYPEMAP_ARGOUT2 macro */ TYPEMAP_ARGOUT2(char, PyArray_CHAR ) TYPEMAP_ARGOUT2(unsigned char, PyArray_UBYTE ) -TYPEMAP_ARGOUT2(signed char, PyArray_SBYTE ) +TYPEMAP_ARGOUT2(signed char, PyArray_BYTE ) TYPEMAP_ARGOUT2(short, PyArray_SHORT ) TYPEMAP_ARGOUT2(int, PyArray_INT ) TYPEMAP_ARGOUT2(long, PyArray_LONG ) Modified: trunk/Lib/sparse/sparsetools/sparsetools.h =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.h 2007-01-09 05:49:05 UTC (rev 2509) +++ trunk/Lib/sparse/sparsetools/sparsetools.h 2007-01-09 11:36:44 UTC (rev 2510) @@ -10,6 +10,7 @@ * Nathan Bell * * Revisions: + * 01/09/2007 - index type is now templated * 01/06/2007 - initial inclusion into SciPy * */ @@ -25,6 +26,10 @@ /* * Return zero of the appropriate type + * + * this is a workaround for NumPy complex types + * where T x = 0; doesn't make sense. + * */ template T ZERO(){ @@ -43,16 +48,16 @@ * - convert CSC->CSR * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros + * I n_row - number of rows in A + * I n_col - number of columns in A + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros * * Output Arguments: - * vec Bp - row pointer - * vec Bj - column indices - * vec Bx - nonzeros + * vec Bp - row pointer + * vec Bj - column indices + * vec Bx - nonzeros * * Note: * Output arrays Bp,Bj,Bx will be allocated within in the method @@ -64,43 +69,43 @@ * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) * */ -template -void csrtocsc(const int n_row, - const int n_col, - const int Ap[], - const int Aj[], - const T Ax[], - std::vector* Bp, - std::vector* Bi, - std::vector* Bx) +template +void csrtocsc(const I n_row, + const I n_col, + const I Ap[], + const I Aj[], + const T Ax[], + std::vector* Bp, + std::vector* Bi, + std::vector* Bx) { - int NNZ = Ap[n_row]; + I NNZ = Ap[n_row]; - *Bp = std::vector(n_col+1); - *Bi = std::vector(NNZ); + *Bp = std::vector(n_col+1); + *Bi = std::vector(NNZ); *Bx = std::vector(NNZ); - std::vector nnz_per_col(n_col,0); //temp array + std::vector nnz_per_col(n_col,0); //temp array //compute number of non-zero entries per column of A - for (int i = 0; i < NNZ; i++){ + for (I i = 0; i < NNZ; i++){ nnz_per_col[Aj[i]]++; } //cumsum the nnz_per_col to get Bp[] - for(int i = 0, cumsum = 0; i < n_col; i++){ + for(I i = 0, cumsum = 0; i < n_col; i++){ (*Bp)[i] = cumsum; cumsum += nnz_per_col[i]; nnz_per_col[i] = 0; //reset count } (*Bp)[n_col] = NNZ; - for(int i = 0; i < n_row; i++){ - int row_start = Ap[i]; - int row_end = Ap[i+1]; - for(int j = row_start; j < row_end; j++){ - int col = Aj[j]; - int k = (*Bp)[col] + nnz_per_col[col]; + for(I i = 0; i < n_row; i++){ + I row_start = Ap[i]; + I row_end = Ap[i+1]; + for(I j = row_start; j < row_end; j++){ + I col = Aj[j]; + I k = (*Bp)[col] + nnz_per_col[col]; (*Bi)[k] = i; (*Bx)[k] = Ax[j]; @@ -120,16 +125,16 @@ * - convert CSC->COO * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros + * I n_row - number of rows in A + * I n_col - number of columns in A + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros * * Output Arguments: - * vec Bi - row indices - * vec Bj - column indices - * vec Bx - nonzeros + * vec Bi - row indices + * vec Bj - column indices + * vec Bx - nonzeros * * Note: * Output arrays Bi,Bj,Bx will be allocated within in the method @@ -138,20 +143,20 @@ * Complexity: Linear. * */ -template -void csrtocoo(const int n_row, - const int n_col, - const int Ap [], - const int Aj[], - const T Ax[], - std::vector* Bi, - std::vector* Bj, +template +void csrtocoo(const I n_row, + const I n_col, + const I Ap [], + const I Aj[], + const T Ax[], + std::vector* Bi, + std::vector* Bj, std::vector* Bx) { - for(int i = 0; i < n_row; i++){ - int row_start = Ap[i]; - int row_end = Ap[i+1]; - for(int jj = row_start; jj < row_end; jj++){ + for(I i = 0; i < n_row; i++){ + I row_start = Ap[i]; + I row_end = Ap[i+1]; + for(I jj = row_start; jj < row_end; jj++){ Bi->push_back(i); Bj->push_back(Aj[jj]); Bx->push_back(Ax[jj]); @@ -166,18 +171,18 @@ * * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in B (hence C is n_row by n_col) - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros - * int Bp[?] - row pointer - * int Bj[nnz(B)] - column indices - * T Bx[nnz(B)] - nonzeros + * I n_row - number of rows in A + * I n_col - number of columns in B (hence C is n_row by n_col) + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * I Bp[?] - row pointer + * I Bj[nnz(B)] - column indices + * T Bx[nnz(B)] - nonzeros * Output Arguments: - * vec Cp - row pointer - * vec Cj - column indices - * vec Cx - nonzeros + * vec Cp - row pointer + * vec Cj - column indices + * vec Cx - nonzeros * * Note: * Output arrays Cp,Cj, and Cx will be allocated within in the method @@ -201,36 +206,34 @@ * http://www.mgnet.org/~douglas/ccd-codes.html * */ -template -void csrmucsr(const int n_row, - const int n_col, - const int Ap [], - const int Aj[], +template +void csrmucsr(const I n_row, + const I n_col, + const I Ap[], + const I Aj[], const T Ax[], - const int Bp[], - const int Bj[], + const I Bp[], + const I Bj[], const T Bx[], - std::vector* Cp, - std::vector* Cj, + std::vector* Cp, + std::vector* Cj, std::vector* Cx) { - *Cp = std::vector(n_row+1,0); - Cj->clear(); - Cx->clear(); + *Cp = std::vector(n_row+1,0); const T zero = ZERO(); - std::vector index(n_col,-1); + std::vector index(n_col,-1); std::vector sums(n_col,zero); - for(int i = 0; i < n_row; i++){ - int istart = -1; - int length = 0; + for(I i = 0; i < n_row; i++){ + I istart = -1; + I length = 0; - for(int jj = Ap[i]; jj < Ap[i+1]; jj++){ - int j = Aj[jj]; - for(int kk = Bp[j]; kk < Bp[j+1]; kk++){ - int k = Bj[kk]; + for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ + I j = Aj[jj]; + for(I kk = Bp[j]; kk < Bp[j+1]; kk++){ + I k = Bj[kk]; sums[k] += Ax[jj]*Bx[kk]; @@ -242,13 +245,13 @@ } } - for(int jj = 0; jj < length; jj++){ + for(I jj = 0; jj < length; jj++){ if(sums[istart] != zero){ Cj->push_back(istart); Cx->push_back(sums[istart]); } - int temp = istart; + I temp = istart; istart = index[istart]; index[temp] = -1; //clear arrays @@ -267,18 +270,18 @@ * * * Input Arguments: - * int n_row - number of rows in A (and B) - * int n_col - number of columns in A (and B) - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros - * int Bp[?] - row pointer - * int Bj[nnz(B)] - column indices - * T Bx[nnz(B)] - nonzeros + * I n_row - number of rows in A (and B) + * I n_col - number of columns in A (and B) + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * I Bp[?] - row pointer + * I Bj[nnz(B)] - column indices + * T Bx[nnz(B)] - nonzeros * Output Arguments: - * vec Cp - row pointer - * vec Cj - column indices - * vec Cx - nonzeros + * vec Cp - row pointer + * vec Cj - column indices + * vec Cx - nonzeros * * Note: * Output arrays Cp,Cj, and Cx will be allocated within in the method @@ -289,36 +292,34 @@ * Cx will not contain any zero entries * */ -template -void csrplcsr(const int n_row, - const int n_col, - const int Ap[], - const int Aj[], - const T Ax[], - const int Bp[], - const int Bj[], - const T Bx[], - std::vector* Cp, - std::vector* Cj, - std::vector * Cx) +template +void csrplcsr(const I n_row, + const I n_col, + const I Ap[], + const I Aj[], + const T Ax[], + const I Bp[], + const I Bj[], + const T Bx[], + std::vector* Cp, + std::vector* Cj, + std::vector* Cx) { - *Cp = std::vector(n_row+1,0); - Cj->clear(); - Cx->clear(); + *Cp = std::vector(n_row+1,0); const T zero = ZERO(); - std::vector index(n_col,-1); - std::vector sums(n_col,zero); + std::vector index(n_col,-1); + std::vector sums(n_col,zero); - for(int i = 0; i < n_row; i++){ - int istart = -1; - int length = 0; + for(I i = 0; i < n_row; i++){ + I istart = -1; + I length = 0; //add a row of A to sums - for(int jj = Ap[i]; jj < Ap[i+1]; jj++){ - int j = Aj[jj]; + for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ + I j = Aj[jj]; sums[j] += Ax[jj]; if(index[j] == -1){ @@ -329,8 +330,8 @@ } //add a row of B to sums - for(int jj = Bp[i]; jj < Bp[i+1]; jj++){ - int j = Bj[jj]; + for(I jj = Bp[i]; jj < Bp[i+1]; jj++){ + I j = Bj[jj]; sums[j] += Bx[jj]; if(index[j] == -1){ @@ -341,13 +342,13 @@ } - for(int jj = 0; jj < length; jj++){ + for(I jj = 0; jj < length; jj++){ if(sums[istart] != zero){ Cj->push_back(istart); Cx->push_back(sums[istart]); } - int temp = istart; + I temp = istart; istart = index[istart]; index[temp] = -1; @@ -364,18 +365,18 @@ * (elmul) - elementwise multiplication * * Input Arguments: - * int n_row - number of rows in A (and B) - * int n_col - number of columns in A (and B) - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros - * int Bp[?] - row pointer - * int Bj[nnz(B)] - column indices - * T Bx[nnz(B)] - nonzeros + * I n_row - number of rows in A (and B) + * I n_col - number of columns in A (and B) + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros + * I Bp[?] - row pointer + * I Bj[nnz(B)] - column indices + * T Bx[nnz(B)] - nonzeros * Output Arguments: - * vec Cp - row pointer - * vec Cj - column indices - * vec Cx - nonzeros + * vec Cp - row pointer + * vec Cj - column indices + * vec Cx - nonzeros * * Note: * Output arrays Cp,Cj, and Cx will be allocated within in the method @@ -386,36 +387,34 @@ * Cx will not contain any zero entries * */ -template -void csrelmulcsr(const int n_row, - const int n_col, - const int Ap [], - const int Aj[], - const T Ax[], - const int Bp[], - const int Bj[], - const T Bx[], - std::vector* Cp, - std::vector* Cj, - std::vector* Cx) +template +void csrelmulcsr(const I n_row, + const I n_col, + const I Ap [], + const I Aj[], + const T Ax[], + const I Bp[], + const I Bj[], + const T Bx[], + std::vector* Cp, + std::vector* Cj, + std::vector* Cx) { - *Cp = std::vector(n_row+1,0); - Cj->clear(); - Cx->clear(); + *Cp = std::vector(n_row+1,0); const T zero = ZERO(); - std::vector index(n_col,-1); + std::vector index(n_col,-1); std::vector A_row(n_col,zero); std::vector B_row(n_col,zero); - for(int i = 0; i < n_row; i++){ - int istart = -1; - int length = 0; + for(I i = 0; i < n_row; i++){ + I istart = -1; + I length = 0; //add a row of A to A_row - for(int jj = Ap[i]; jj < Ap[i+1]; jj++){ - int j = Aj[jj]; + for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ + I j = Aj[jj]; A_row[j] += Ax[jj]; @@ -427,8 +426,8 @@ } //add a row of B to B_row - for(int jj = Bp[i]; jj < Bp[i+1]; jj++){ - int j = Bj[jj]; + for(I jj = Bp[i]; jj < Bp[i+1]; jj++){ + I j = Bj[jj]; B_row[j] += Bx[jj]; @@ -440,7 +439,7 @@ } - for(int jj = 0; jj < length; jj++){ + for(I jj = 0; jj < length; jj++){ T prod = A_row[istart] * B_row[istart]; if(prod != zero){ @@ -448,7 +447,7 @@ Cx->push_back(prod); } - int temp = istart; + I temp = istart; istart = index[istart]; index[temp] = -1; @@ -466,15 +465,15 @@ * * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int Ai[nnz(A)] - row indices - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros + * I n_row - number of rows in A + * I n_col - number of columns in A + * I Ai[nnz(A)] - row indices + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros * Output Arguments: - * vec Bp - row pointer - * vec Bj - column indices - * vec Bx - nonzeros + * vec Bp - row pointer + * vec Bj - column indices + * vec Bx - nonzeros * * Note: * Output arrays Bp,Bj,Bx will be allocated within in the method @@ -488,28 +487,28 @@ * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) * */ -template -void cootocsr(const int n_row, - const int n_col, - const int NNZ, - const int Ai[], - const int Aj[], - const T Ax[], - std::vector* Bp, - std::vector* Bj, +template +void cootocsr(const I n_row, + const I n_col, + const I NNZ, + const I Ai[], + const I Aj[], + const T Ax[], + std::vector* Bp, + std::vector* Bj, std::vector* Bx) { - std::vector tempBp(n_row+1,0); - std::vector tempBj(NNZ); - std::vector tempBx(NNZ); + std::vector tempBp(n_row+1,0); + std::vector tempBj(NNZ); + std::vector tempBx(NNZ); - std::vector nnz_per_row(n_row,0); //temp array + std::vector nnz_per_row(n_row,0); //temp array //compute nnz per row, then compute Bp - for(int i = 0; i < NNZ; i++){ + for(I i = 0; i < NNZ; i++){ nnz_per_row[Ai[i]]++; } - for(int i = 0, cumsum = 0; i < n_row; i++){ + for(I i = 0, cumsum = 0; i < n_row; i++){ tempBp[i] = cumsum; cumsum += nnz_per_row[i]; nnz_per_row[i] = 0; //reset count @@ -517,10 +516,10 @@ tempBp[n_row] = NNZ; - //write Aj,Ax into tempBj,tempBx - for(int i = 0; i < NNZ; i++){ - int row = Ai[i]; - int n = tempBp[row] + nnz_per_row[row]; + //write Aj,Ax Io tempBj,tempBx + for(I i = 0; i < NNZ; i++){ + I row = Ai[i]; + I n = tempBp[row] + nnz_per_row[row]; tempBj[n] = Aj[i]; tempBx[n] = Ax[i]; @@ -531,12 +530,12 @@ //use (tempB + 0) to sum duplicates - std::vector Xp(n_row+1,0); //row pointer for an empty matrix + std::vector Xp(n_row+1,0); //row pointer for an empty matrix - csrplcsr(n_row,n_col, - &tempBp[0],&tempBj[0],&tempBx[0], - &Xp[0],NULL,NULL, - Bp,Bj,Bx); + csrplcsr(n_row,n_col, + &tempBp[0],&tempBj[0],&tempBx[0], + &Xp[0],NULL,NULL, + Bp,Bj,Bx); } @@ -548,12 +547,12 @@ * * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[n_col] - nonzeros - * T Xx[n_col] - nonzeros + * I n_row - number of rows in A + * I n_col - number of columns in A + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[n_col] - nonzeros + * T Xx[n_col] - nonzeros * * Output Arguments: * vec Yx - nonzeros (real part) @@ -564,25 +563,25 @@ * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) * */ -template -void csrmux(const int n_row, - const int n_col, - const int Ap [], - const int Aj[], - const T Ax[], - const T Xx[], +template +void csrmux(const I n_row, + const I n_col, + const I Ap [], + const I Aj[], + const T Ax[], + const T Xx[], std::vector* Yx) { const T zero = ZERO(); *Yx = std::vector(n_row,zero); - for(int i = 0; i < n_row; i++){ - int row_start = Ap[i]; - int row_end = Ap[i+1]; + for(I i = 0; i < n_row; i++){ + I row_start = Ap[i]; + I row_end = Ap[i+1]; T& Yx_i = (*Yx)[i]; - for(int jj = row_start; jj < row_end; jj++){ + for(I jj = row_start; jj < row_end; jj++){ Yx_i += Ax[jj] * Xx[Aj[jj]]; } } @@ -595,10 +594,10 @@ * * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int Ap[n_row+1] - column pointer - * int Ai[nnz(A)] - row indices + * I n_row - number of rows in A + * I n_col - number of columns in A + * I Ap[n_row+1] - column pointer + * I Ai[nnz(A)] - row indices * T Ax[n_col] - nonzeros (real part) * T Xx[n_col] - nonzeros (real part) * bool do_complex - switch scalar/complex modes @@ -612,25 +611,25 @@ * Complexity: Linear. Specifically O(nnz(A) + max(n_row,n_col)) * */ -template -void cscmux(const int n_row, - const int n_col, - const int Ap[], - const int Ai[], - const T Ax[], - const T Xx[], +template +void cscmux(const I n_row, + const I n_col, + const I Ap[], + const I Ai[], + const T Ax[], + const T Xx[], std::vector* Yx) { const T zero = ZERO(); *Yx = std::vector(n_row,zero); - for(int j = 0; j < n_col; j++){ - int col_start = Ap[j]; - int col_end = Ap[j+1]; + for(I j = 0; j < n_col; j++){ + I col_start = Ap[j]; + I col_end = Ap[j+1]; - for(int ii = col_start; ii < col_end; ii++){ - int row = Ai[ii]; + for(I ii = col_start; ii < col_end; ii++){ + I row = Ai[ii]; (*Yx)[row] += Ax[ii] * Xx[j]; } } @@ -643,16 +642,16 @@ * Construct CSC matrix A from diagonals * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int n_diags - number of diagonals - * int diags_indx[n_diags] - where to place each diagonal - * T diags[n_diags][min(n_row,n_col)] - diagonals + * I n_row - number of rows in A + * I n_col - number of columns in A + * I n_diags - number of diagonals + * I diags_indx[n_diags] - where to place each diagonal + * T diags[n_diags][min(n_row,n_col)] - diagonals * * Output Arguments: - * vec Ap - row pointer - * vec Aj - column indices - * vec Ax - nonzeros + * vec Ap - row pointer + * vec Aj - column indices + * vec Ax - nonzeros * * Note: * Output arrays Ap,Aj,Ax will be allocated within in the method @@ -663,30 +662,30 @@ * Complexity: Linear * */ -template -void spdiags(const int n_row, - const int n_col, - const int n_diag, - const int offsets[], - const T diags[], - std::vector * Ap, - std::vector * Ai, - std::vector * Ax) +template +void spdiags(const I n_row, + const I n_col, + const I n_diag, + const I offsets[], + const T diags[], + std::vector * Ap, + std::vector * Ai, + std::vector * Ax) { - const int diags_length = std::min(n_row,n_col); + const I diags_length = std::min(n_row,n_col); Ap->push_back(0); - for(int i = 0; i < n_col; i++){ - for(int j = 0; j < n_diag; j++){ + for(I i = 0; i < n_col; i++){ + for(I j = 0; j < n_diag; j++){ if(offsets[j] <= 0){ //sub-diagonal - int row = i - offsets[j]; + I row = i - offsets[j]; if (row >= n_row){ continue; } Ai->push_back(row); Ax->push_back(diags[j*diags_length + i]); } else { //super-diagonal - int row = i - offsets[j]; + I row = i - offsets[j]; if (row < 0 || row >= n_row){ continue; } Ai->push_back(row); @@ -703,36 +702,36 @@ * Compute M = A for CSR matrix A, dense matrix M * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices + * I n_row - number of rows in A + * I n_col - number of columns in A + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices * T Ax[nnz(A)] - nonzeros * T Mx[n_row*n_col] - dense matrix * * Note: - * Output arrays Mx are assumed to be allocated and + * Output array Mx is assumed to be allocated and * initialized to 0 by the caller. * */ -template -void csrtodense(const int n_row, - const int n_col, - const int Ap[], - const int Aj[], - const T Ax[], - T Mx[]) +template +void csrtodense(const I n_row, + const I n_col, + const I Ap[], + const I Aj[], + const T Ax[], + T Mx[]) { - int row_base = 0; - for(int i = 0; i < n_row; i++){ - int row_start = Ap[i]; - int row_end = Ap[i+1]; - for(int jj = row_start; jj < row_end; jj++){ - int j = Aj[jj]; + I row_base = 0; + for(I i = 0; i < n_row; i++){ + I row_start = Ap[i]; + I row_end = Ap[i+1]; + for(I jj = row_start; jj < row_end; jj++){ + I j = Aj[jj]; Mx[row_base + j] = Ax[jj]; } - row_base += n_col; + row_base += n_col; } } @@ -742,31 +741,31 @@ * Compute A = M for CSR matrix A, dense matrix M * * Input Arguments: - * int n_row - number of rows in A - * int n_col - number of columns in A - * T Mx[n_row*n_col] - dense matrix - * int Ap[n_row+1] - row pointer - * int Aj[nnz(A)] - column indices - * T Ax[nnz(A)] - nonzeros + * I n_row - number of rows in A + * I n_col - number of columns in A + * T Mx[n_row*n_col] - dense matrix + * I Ap[n_row+1] - row pointer + * I Aj[nnz(A)] - column indices + * T Ax[nnz(A)] - nonzeros * * Note: * Output arrays Ap,Aj,Ax will be allocated within the method * */ -template -void densetocsr(const int n_row, - const int n_col, - const T Mx[], - std::vector* Ap, - std::vector* Aj, - std::vector* Ax) +template +void densetocsr(const I n_row, + const I n_col, + const T Mx[], + std::vector* Ap, + std::vector* Aj, + std::vector* Ax) { - const T zero = ZERO(); + const T zero = ZERO(); const T* x_ptr = Mx; Ap->push_back(0); - for(int i = 0; i < n_row; i++){ - for(int j = 0; j < n_col; j++){ + for(I i = 0; i < n_row; i++){ + for(I j = 0; j < n_col; j++){ if(*x_ptr != zero){ Aj->push_back(j); Ax->push_back(*x_ptr); @@ -782,81 +781,81 @@ /* * Derived methods */ -template -void csctocsr(const int n_row, - const int n_col, - const int Ap[], - const int Ai[], - const T Ax[], - std::vector* Bp, - std::vector* Bj, - std::vector* Bx) -{ csrtocsc(n_col,n_row,Ap,Ai,Ax,Bp,Bj,Bx); } +template +void csctocsr(const I n_row, + const I n_col, + const I Ap[], + const I Ai[], + const T Ax[], + std::vector* Bp, + std::vector* Bj, + std::vector* Bx) +{ csrtocsc(n_col,n_row,Ap,Ai,Ax,Bp,Bj,Bx); } -template -void csctocoo(const int n_row, - const int n_col, - const int Ap[], - const int Ai[], - const T Ax[], - std::vector* Bi, - std::vector* Bj, - std::vector* Bx) -{ csrtocoo(n_col,n_row,Ap,Ai,Ax,Bj,Bi,Bx); } +template +void csctocoo(const I n_row, + const I n_col, + const I Ap[], + const I Ai[], + const T Ax[], + std::vector* Bi, + std::vector* Bj, + std::vector* Bx) +{ csrtocoo(n_col,n_row,Ap,Ai,Ax,Bj,Bi,Bx); } -template -void cscmucsc(const int n_row, - const int n_col, - const int Ap [], - const int Ai[], - const T Ax[], - const int Bp[], - const int Bi[], - const T Bx[], - std::vector* Cp, - std::vector* Ci, - std::vector * Cx) -{ csrmucsr(n_col,n_row,Bp,Bi,Bx,Ap,Ai,Ax,Cp,Ci,Cx); } +template +void cscmucsc(const I n_row, + const I n_col, + const I Ap[], + const I Ai[], + const T Ax[], + const I Bp[], + const I Bi[], + const T Bx[], + std::vector* Cp, + std::vector* Ci, + std::vector* Cx) +{ csrmucsr(n_col,n_row,Bp,Bi,Bx,Ap,Ai,Ax,Cp,Ci,Cx); } -template -void cscplcsc(const int n_row, - const int n_col, - const int Ap [], - const int Ai[], - const T Ax[], - const int Bp[], - const int Bi[], - const T Bx[], - std::vector* Cp, - std::vector* Ci, - std::vector* Cx) -{ csrplcsr(n_col,n_row,Ap,Ai,Ax,Bp,Bi,Bx,Cp,Ci,Cx); } +template +void cscplcsc(const I n_row, + const I n_col, + const I Ap[], + const I Ai[], + const T Ax[], + const I Bp[], + const I Bi[], + const T Bx[], + std::vector* Cp, + std::vector* Ci, + std::vector* Cx) +{ csrplcsr(n_col,n_row,Ap,Ai,Ax,Bp,Bi,Bx,Cp,Ci,Cx); } -template -void cscelmulcsc(const int n_row, - const int n_col, - const int Ap [], - const int Ai[], - const T Ax[], - const int Bp[], - const int Bi[], - const T Bx[], - std::vector* Cp, - std::vector* Ci, - std::vector* Cx) -{ csrelmulcsr(n_col,n_row,Ap,Ai,Ax,Bp,Bi,Bx,Cp,Ci,Cx); } +template +void cscelmulcsc(const I n_row, + const I n_col, + const I Ap[], + const I Ai[], + const T Ax[], + const I Bp[], + const I Bi[], + const T Bx[], + std::vector* Cp, + std::vector* Ci, + std::vector* Cx) +{ csrelmulcsr(n_col,n_row,Ap,Ai,Ax,Bp,Bi,Bx,Cp,Ci,Cx); } -template -void cootocsc(const int n_row, - const int n_col, - const int NNZ, - const int Ai[], - const int Aj[], - const T Ax[], - std::vector* Bp, - std::vector* Bi, - std::vector* Bx) -{ cootocsr(n_col,n_row,NNZ,Aj,Ai,Ax,Bp,Bi,Bx); } +template +void cootocsc(const I n_row, + const I n_col, + const I NNZ, + const I Ai[], + const I Aj[], + const T Ax[], + std::vector* Bp, + std::vector* Bi, + std::vector* Bx) +{ cootocsr(n_col,n_row,NNZ,Aj,Ai,Ax,Bp,Bi,Bx); } Modified: trunk/Lib/sparse/sparsetools/sparsetools.i =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.i 2007-01-09 05:49:05 UTC (rev 2509) +++ trunk/Lib/sparse/sparsetools/sparsetools.i 2007-01-09 11:36:44 UTC (rev 2510) @@ -49,14 +49,10 @@ } return where; } +%} //end inline code - -%} - - - /* * Use STL vectors for ARGOUTs */ @@ -76,366 +72,205 @@ - + /* + * make typechecks - used for overloading + */ %include "typemaps.i" -%typemap(typecheck) int *, const int *, int [], const int [] +%define NPY_TYPECHECK( ctype, atype ) +%typemap(typecheck) ctype *, const ctype *, ctype [], const ctype [] { - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_INT)) ? 1 : 0; + $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_##atype)) ? 1 : 0; }; +%enddef -%typemap(typecheck) float *, const float *, float [], const float [] -{ - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_FLOAT)) ? 1 : 0; -}; +NPY_TYPECHECK( int, INT ) +NPY_TYPECHECK( long, LONG ) +NPY_TYPECHECK( float, FLOAT ) +NPY_TYPECHECK( double, DOUBLE ) +NPY_TYPECHECK( npy_cfloat, CFLOAT ) +NPY_TYPECHECK( npy_cdouble, CDOUBLE ) -%typemap(typecheck) double *, const double *, double [], const double [] -{ - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_DOUBLE)) ? 1 : 0; -}; -%typemap(typecheck) long double *, const long double *, long double [], const long double [] -{ - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_LONGDOUBLE)) ? 1 : 0; -}; -%typemap(typecheck) npy_cfloat *, const npy_cfloat *, npy_cfloat [], const npy_cfloat [] -{ - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_CFLOAT)) ? 1 : 0; + /* + * IN types + */ +%define I_IN_ARRAY1( ctype ) +%apply ctype * IN_ARRAY1 { + const ctype Ap [ ], + const ctype Ai [ ], + const ctype Aj [ ], + const ctype Bp [ ], + const ctype Bi [ ], + const ctype Bj [ ], + const ctype offsets [ ] }; +%enddef -%typemap(typecheck) npy_cdouble *, const npy_cdouble *, npy_cdouble [], const npy_cdouble [] -{ - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_CDOUBLE)) ? 1 : 0; +%define T_IN_ARRAY1( ctype ) +%apply ctype * IN_ARRAY1 { + const ctype Ax [ ], + const ctype Bx [ ], + const ctype Xx [ ], + const ctype Yx [ ] }; +%enddef -%typemap(typecheck) npy_clongdouble *, const npy_clongdouble *, npy_clongdouble [], const npy_clongdouble [] -{ - $1 = (is_array($input) && PyArray_CanCastSafely(PyArray_TYPE($input),PyArray_CLONGDOUBLE)) ? 1 : 0; +%define T_IN_ARRAY2( ctype ) +%apply ctype * IN_ARRAY2 { + const ctype Mx [ ], + const ctype diags [ ] }; +%enddef +I_IN_ARRAY1( int ) +I_IN_ARRAY1( long ) +T_IN_ARRAY1( int ) +T_IN_ARRAY1( long ) +T_IN_ARRAY1( float ) +T_IN_ARRAY1( double ) +T_IN_ARRAY1( npy_cfloat ) +T_IN_ARRAY1( npy_cdouble ) +T_IN_ARRAY2( int ) +T_IN_ARRAY2( long ) +T_IN_ARRAY2( float ) +T_IN_ARRAY2( double ) +T_IN_ARRAY2( npy_cfloat ) +T_IN_ARRAY2( npy_cdouble ) -/* - * IN types - */ -%apply int * IN_ARRAY1 { - const int Ap [ ], - const int Ai [ ], - const int Aj [ ], - const int Bp [ ], - const int Bi [ ], - const int Bj [ ], - const int offsets [ ] -}; -%apply float * IN_ARRAY1 { - const float Ax [ ], - const float Bx [ ], - const float Xx [ ], - const float Yx [ ] + /* + * OUT types + */ +%define I_ARRAY_ARGOUT( ctype, atype ) +VEC_ARRAY_ARGOUT( ctype, atype ) +%apply std::vector* array_argout { + std::vector* Ap, + std::vector* Ai, + std::vector* Aj, + std::vector* Bp, + std::vector* Bi, + std::vector* Bj, + std::vector* Cp, + std::vector* Ci, + std::vector* Cj }; +%enddef -%apply double * IN_ARRAY1 { - const double Ax [ ], - const double Bx [ ], - const double Xx [ ], - const double Yx [ ] +%define T_ARRAY_ARGOUT( ctype, atype ) +VEC_ARRAY_ARGOUT( ctype, atype ) +%apply std::vector* array_argout { + std::vector* Ax, + std::vector* Bx, + std::vector* Cx, + std::vector* Xx, + std::vector* Yx }; +%enddef -%apply long double * IN_ARRAY1 { - const long double Ax [ ], - const long double Bx [ ], - const long double Xx [ ], - const long double Yx [ ] -}; -%apply npy_cfloat * IN_ARRAY1 { - const npy_cfloat Ax [ ], - const npy_cfloat Bx [ ], - const npy_cfloat Xx [ ], - const npy_cfloat Yx [ ] -}; -%apply npy_cdouble * IN_ARRAY1 { - const npy_cdouble Ax [ ], - const npy_cdouble Bx [ ], - const npy_cdouble Xx [ ], - const npy_cdouble Yx [ ] -}; +I_ARRAY_ARGOUT( int, INT) +I_ARRAY_ARGOUT( long, LONG) -%apply npy_clongdouble * IN_ARRAY1 { - const npy_clongdouble Ax [ ], - const npy_clongdouble Bx [ ], - const npy_clongdouble Xx [ ], - const npy_clongdouble Yx [ ] -}; +T_ARRAY_ARGOUT( int, INT ) +T_ARRAY_ARGOUT( long, LONG ) +T_ARRAY_ARGOUT( float, FLOAT ) +T_ARRAY_ARGOUT( double, DOUBLE ) +T_ARRAY_ARGOUT( npy_cfloat, CFLOAT ) +T_ARRAY_ARGOUT( npy_cdouble, CDOUBLE ) -%apply float * IN_ARRAY2 { const float Mx[] } -%apply double * IN_ARRAY2 { const double Mx[] } -%apply long double * IN_ARRAY2 { const long double Mx[] } -%apply npy_cfloat * IN_ARRAY2 { const npy_cfloat Mx[] } -%apply npy_cdouble * IN_ARRAY2 { const npy_cdouble Mx[] } -%apply npy_clongdouble * IN_ARRAY2 { const npy_longdouble Mx[] } - -%apply float * IN_ARRAY2 { const float diags[] } -%apply double * IN_ARRAY2 { const double diags[] } -%apply long double * IN_ARRAY2 { const long double diags[] } -%apply npy_cfloat * IN_ARRAY2 { const npy_cfloat diags[] } -%apply npy_cdouble * IN_ARRAY2 { const npy_cdouble diags[] } -%apply npy_clongdouble * IN_ARRAY2 { const npy_longdouble diags[] } - - - -/* - * OUT types - */ -VEC_ARRAY_ARGOUT( int, INT ) -%apply std::vector* array_argout { - std::vector* Ap, - std::vector* Ai, - std::vector* Aj, - std::vector* Bp, - std::vector* Bi, - std::vector* Bj, - std::vector* Cp, - std::vector* Ci, - std::vector* Cj + /* + * INOUT types + */ +%define T_INPLACE_ARRAY2( ctype ) +%apply ctype * INPLACE_ARRAY2 { + ctype Mx [ ] }; +%enddef -VEC_ARRAY_ARGOUT( float, FLOAT ) -%apply std::vector* array_argout { - std::vector* Ax, - std::vector* Bx, - std::vector* Cx, - std::vector* Xx, - std::vector* Yx -}; +T_INPLACE_ARRAY2( int ) +T_INPLACE_ARRAY2( long ) +T_INPLACE_ARRAY2( float ) +T_INPLACE_ARRAY2( double ) +T_INPLACE_ARRAY2( npy_cfloat ) +T_INPLACE_ARRAY2( npy_cdouble ) -VEC_ARRAY_ARGOUT( double, DOUBLE ) -%apply std::vector* array_argout { - std::vector* Ax, - std::vector* Bx, - std::vector* Cx, - std::vector* Xx, - std::vector* Yx -}; -VEC_ARRAY_ARGOUT( long double, LONGDOUBLE ) -%apply std::vector* array_argout { - std::vector* Ax, - std::vector* Bx, - std::vector* Cx, - std::vector* Xx, - std::vector* Yx -}; -VEC_ARRAY_ARGOUT( npy_cfloat, CFLOAT ) -%apply std::vector* array_argout { - std::vector* Ax, - std::vector* Bx, - std::vector* Cx, - std::vector* Xx, - std::vector* Yx -}; -VEC_ARRAY_ARGOUT( npy_cdouble, CDOUBLE ) -%apply std::vector* array_argout { - std::vector* Ax, - std::vector* Bx, - std::vector* Cx, - std::vector* Xx, - std::vector* Yx -}; - - -VEC_ARRAY_ARGOUT( npy_clongdouble, CLONGDOUBLE ) -%apply std::vector* array_argout { - std::vector* Ax, - std::vector* Bx, - std::vector* Cx, - std::vector* Xx, - std::vector* Yx -}; - - - -/* - * INOUT types - */ -%apply float * INPLACE_ARRAY2 { float Mx [] } -%apply double * INPLACE_ARRAY2 { double Mx [] } -%apply long double * INPLACE_ARRAY2 { long double Mx[] } -%apply npy_cfloat * INPLACE_ARRAY2 { npy_cfloat Mx[] } -%apply npy_cdouble * INPLACE_ARRAY2 { npy_cdouble Mx[] } -%apply npy_clongdouble * INPLACE_ARRAY2 { npy_longdouble Mx[] } - - - - - - %include "sparsetools.h" + /* + * Order may be important here, list float before npy_float64, scalar before complex + */ +%define INSTANTIATE_ALL( f_name ) +%template(f_name) f_name; +%template(f_name) f_name; +%template(f_name) f_name; +%template(f_name) f_name; +%template(f_name) f_name; +%template(f_name) f_name; +/* 64-bit indices would go here */ +%enddef - /* - * Order may be important here, list float before double - */ /* * CSR->CSC or CSC->CSR or CSR = CSR^T or CSC = CSC^T */ -%template(csrtocsc) csrtocsc; -%template(csrtocsc) csrtocsc; -%template(csrtocsc) csrtocsc; -%template(csrtocsc) csrtocsc; -%template(csrtocsc) csrtocsc; -%template(csrtocsc) csrtocsc; +INSTANTIATE_ALL(csrtocsc) +INSTANTIATE_ALL(csctocsr) -%template(csctocsr) csctocsr; -%template(csctocsr) csctocsr; -%template(csctocsr) csctocsr; -%template(csctocsr) csctocsr; -%template(csctocsr) csctocsr; -%template(csctocsr) csctocsr; - - /* * CSR<->COO and CSC<->COO */ -%template(csrtocoo) csrtocoo; -%template(csrtocoo) csrtocoo; -%template(csrtocoo) csrtocoo; -%template(csrtocoo) csrtocoo; -%template(csrtocoo) csrtocoo; -%template(csrtocoo) csrtocoo; +INSTANTIATE_ALL(csrtocoo) +INSTANTIATE_ALL(csctocoo) +INSTANTIATE_ALL(cootocsr) +INSTANTIATE_ALL(cootocsc) -%template(cootocsr) cootocsr; -%template(cootocsr) cootocsr; -%template(cootocsr) cootocsr; -%template(cootocsr) cootocsr; -%template(cootocsr) cootocsr; -%template(cootocsr) cootocsr; - -%template(csctocoo) csctocoo; -%template(csctocoo) csctocoo; -%template(csctocoo) csctocoo; -%template(csctocoo) csctocoo; -%template(csctocoo) csctocoo; -%template(csctocoo) csctocoo; - -%template(cootocsc) cootocsc; -%template(cootocsc) cootocsc; -%template(cootocsc) cootocsc; -%template(cootocsc) cootocsc; -%template(cootocsc) cootocsc; -%template(cootocsc) cootocsc; - - /* * CSR+CSR and CSC+CSC */ -%template(csrplcsr) csrplcsr; -%template(csrplcsr) csrplcsr; -%template(csrplcsr) csrplcsr; -%template(csrplcsr) csrplcsr; -%template(csrplcsr) csrplcsr; -%template(csrplcsr) csrplcsr; +INSTANTIATE_ALL(csrplcsr) +INSTANTIATE_ALL(cscplcsc) -%template(cscplcsc) cscplcsc; -%template(cscplcsc) cscplcsc; -%template(cscplcsc) cscplcsc; -%template(cscplcsc) cscplcsc; -%template(cscplcsc) cscplcsc; -%template(cscplcsc) cscplcsc; - - - /* * CSR*CSR and CSC*CSC */ -%template(csrmucsr) csrmucsr; -%template(csrmucsr) csrmucsr; -%template(csrmucsr) csrmucsr; -%template(csrmucsr) csrmucsr; -%template(csrmucsr) csrmucsr; -%template(csrmucsr) csrmucsr; +INSTANTIATE_ALL(csrmucsr) +INSTANTIATE_ALL(cscmucsc) -%template(cscmucsc) cscmucsc; -%template(cscmucsc) cscmucsc; -%template(cscmucsc) cscmucsc; -%template(cscmucsc) cscmucsc; -%template(cscmucsc) cscmucsc; -%template(cscmucsc) cscmucsc; - /* * CSR*x and CSC*x */ -%template(csrmux) csrmux; -%template(csrmux) csrmux; -%template(csrmux) csrmux; -%template(csrmux) csrmux; -%template(csrmux) csrmux; -%template(csrmux) csrmux; +INSTANTIATE_ALL(csrmux) +INSTANTIATE_ALL(cscmux) -%template(cscmux) cscmux; -%template(cscmux) cscmux; -%template(cscmux) cscmux; -%template(cscmux) cscmux; -%template(cscmux) cscmux; -%template(cscmux) cscmux; - - /* * CSR(elmul)CSR and CSC(elmul)CSC */ -%template(csrelmulcsr) csrelmulcsr; -%template(csrelmulcsr) csrelmulcsr; -%template(csrelmulcsr) csrelmulcsr; -%template(csrelmulcsr) csrelmulcsr; -%template(csrelmulcsr) csrelmulcsr; -%template(csrelmulcsr) csrelmulcsr; +INSTANTIATE_ALL(csrelmulcsr) +INSTANTIATE_ALL(cscelmulcsc) -%template(cscelmulcsc) cscelmulcsc; -%template(cscelmulcsc) cscelmulcsc; -%template(cscelmulcsc) cscelmulcsc; -%template(cscelmulcsc) cscelmulcsc; -%template(cscelmulcsc) cscelmulcsc; -%template(cscelmulcsc) cscelmulcsc; - /* * spdiags->CSC */ -%template(spdiags) spdiags; -%template(spdiags) spdiags; -%template(spdiags) spdiags; -%template(spdiags) spdiags; -%template(spdiags) spdiags; -%template(spdiags) spdiags; +INSTANTIATE_ALL(spdiags) - /* * CSR<->Dense */ -%template(csrtodense) csrtodense; -%template(csrtodense) csrtodense; -%template(csrtodense) csrtodense; -%template(csrtodense) csrtodense; -%template(csrtodense) csrtodense; -%template(csrtodense) csrtodense; - -%template(densetocsr) densetocsr; -%template(densetocsr) densetocsr; -%template(densetocsr) densetocsr; -%template(densetocsr) densetocsr; -%template(densetocsr) densetocsr; -%template(densetocsr) densetocsr; +INSTANTIATE_ALL(csrtodense) +INSTANTIATE_ALL(densetocsr) Modified: trunk/Lib/sparse/sparsetools/sparsetools.py =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-09 05:49:05 UTC (rev 2509) +++ trunk/Lib/sparse/sparsetools/sparsetools.py 2007-01-09 11:36:44 UTC (rev 2510) @@ -52,358 +52,348 @@ def csrtocsc(*args): """ + csrtocsc(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(int)> Bx) + csrtocsc(int n_row, int n_col, int Ap, int Aj, long Ax, std::vector<(int)> Bp, + std::vector<(int)> Bi, std::vector<(long)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(double)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, long double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long double)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_cfloat)> Bx) csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_cdouble)> Bx) - csrtocsc(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_clongdouble)> Bx) """ return _sparsetools.csrtocsc(*args) def csctocsr(*args): """ + csctocsr(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocsr(int n_row, int n_col, int Ap, int Ai, long Ax, std::vector<(int)> Bp, + std::vector<(int)> Bj, std::vector<(long)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, long double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long double)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_cfloat)> Bx) csctocsr(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_cdouble)> Bx) - csctocsr(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_clongdouble)> Bx) """ return _sparsetools.csctocsr(*args) def csrtocoo(*args): """ + csrtocoo(int n_row, int n_col, int Ap, int Aj, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csrtocoo(int n_row, int n_col, int Ap, int Aj, long Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(long)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, float Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(float)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, double Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(double)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, long double Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long double)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_cfloat)> Bx) csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, std::vector<(int)> Bi, std::vector<(int)> Bj, std::vector<(npy_cdouble)> Bx) - csrtocoo(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_clongdouble)> Bx) """ return _sparsetools.csrtocoo(*args) +def csctocoo(*args): + """ + csctocoo(int n_row, int n_col, int Ap, int Ai, int Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(int)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, long Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(long)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(float)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, + std::vector<(int)> Bj, std::vector<(double)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cfloat)> Bx) + csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, + std::vector<(int)> Bi, std::vector<(int)> Bj, + std::vector<(npy_cdouble)> Bx) + """ + return _sparsetools.csctocoo(*args) + def cootocsr(*args): """ + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(int)> Bx) + cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bj, + std::vector<(long)> Bx) cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(float)> Bx) cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(double)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, long double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(long double)> Bx) cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_cfloat)> Bx) cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble Ax, std::vector<(int)> Bp, std::vector<(int)> Bj, std::vector<(npy_cdouble)> Bx) - cootocsr(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_clongdouble Ax, - std::vector<(int)> Bp, std::vector<(int)> Bj, - std::vector<(npy_clongdouble)> Bx) """ return _sparsetools.cootocsr(*args) -def csctocoo(*args): - """ - csctocoo(int n_row, int n_col, int Ap, int Ai, float Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(float)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, double Ax, std::vector<(int)> Bi, - std::vector<(int)> Bj, std::vector<(double)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, long double Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(long double)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cfloat)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_cdouble)> Bx) - csctocoo(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, - std::vector<(int)> Bi, std::vector<(int)> Bj, - std::vector<(npy_clongdouble)> Bx) - """ - return _sparsetools.csctocoo(*args) - def cootocsc(*args): """ + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, int Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(int)> Bx) + cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long Ax, + std::vector<(int)> Bp, std::vector<(int)> Bi, + std::vector<(long)> Bx) cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, float Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(float)> Bx) cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, double Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(double)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, long double Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(long double)> Bx) cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cfloat Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_cfloat)> Bx) cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_cdouble Ax, std::vector<(int)> Bp, std::vector<(int)> Bi, std::vector<(npy_cdouble)> Bx) - cootocsc(int n_row, int n_col, int NNZ, int Ai, int Aj, npy_clongdouble Ax, - std::vector<(int)> Bp, std::vector<(int)> Bi, - std::vector<(npy_clongdouble)> Bx) """ return _sparsetools.cootocsc(*args) def csrplcsr(*args): """ + csrplcsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(int)> Cx) + csrplcsr(int n_row, int n_col, int Ap, int Aj, long Ax, int Bp, + int Bj, long Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(long)> Cx) csrplcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) csrplcsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, int Bj, double Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(double)> Cx) - csrplcsr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long double)> Cx) csrplcsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, int Bp, int Bj, npy_cfloat Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_cfloat)> Cx) csrplcsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, int Bp, int Bj, npy_cdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_cdouble)> Cx) - csrplcsr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ return _sparsetools.csrplcsr(*args) def cscplcsc(*args): """ + cscplcsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(int)> Cx) + cscplcsc(int n_row, int n_col, int Ap, int Ai, long Ax, int Bp, + int Bi, long Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(long)> Cx) cscplcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) cscplcsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, int Bi, double Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(double)> Cx) - cscplcsc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long double)> Cx) cscplcsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, int Bp, int Bi, npy_cfloat Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_cfloat)> Cx) cscplcsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, int Bp, int Bi, npy_cdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_cdouble)> Cx) - cscplcsc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, - int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ return _sparsetools.cscplcsc(*args) def csrmucsr(*args): """ + csrmucsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(int)> Cx) + csrmucsr(int n_row, int n_col, int Ap, int Aj, long Ax, int Bp, + int Bj, long Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(long)> Cx) csrmucsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) csrmucsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, int Bj, double Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(double)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long double)> Cx) csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, int Bp, int Bj, npy_cfloat Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_cfloat)> Cx) csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, int Bp, int Bj, npy_cdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_cdouble)> Cx) - csrmucsr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ return _sparsetools.csrmucsr(*args) def cscmucsc(*args): """ + cscmucsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(int)> Cx) + cscmucsc(int n_row, int n_col, int Ap, int Ai, long Ax, int Bp, + int Bi, long Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(long)> Cx) cscmucsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) cscmucsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, int Bi, double Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(double)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long double)> Cx) cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, int Bp, int Bi, npy_cfloat Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_cfloat)> Cx) cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, int Bp, int Bi, npy_cdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_cdouble)> Cx) - cscmucsc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, - int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ return _sparsetools.cscmucsc(*args) def csrmux(*args): """ + csrmux(int n_row, int n_col, int Ap, int Aj, int Ax, int Xx, + std::vector<(int)> Yx) + csrmux(int n_row, int n_col, int Ap, int Aj, long Ax, long Xx, + std::vector<(long)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, float Ax, float Xx, std::vector<(float)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, double Ax, double Xx, std::vector<(double)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Xx, std::vector<(long double)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, npy_cfloat Xx, std::vector<(npy_cfloat)> Yx) csrmux(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, npy_cdouble Xx, std::vector<(npy_cdouble)> Yx) - csrmux(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ return _sparsetools.csrmux(*args) def cscmux(*args): """ + cscmux(int n_row, int n_col, int Ap, int Ai, int Ax, int Xx, + std::vector<(int)> Yx) + cscmux(int n_row, int n_col, int Ap, int Ai, long Ax, long Xx, + std::vector<(long)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, float Ax, float Xx, std::vector<(float)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, double Ax, double Xx, std::vector<(double)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, long double Ax, - long double Xx, std::vector<(long double)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, npy_cfloat Xx, std::vector<(npy_cfloat)> Yx) cscmux(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, npy_cdouble Xx, std::vector<(npy_cdouble)> Yx) - cscmux(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, - npy_clongdouble Xx, std::vector<(npy_clongdouble)> Yx) """ return _sparsetools.cscmux(*args) def csrelmulcsr(*args): """ + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, int Ax, int Bp, + int Bj, int Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(int)> Cx) + csrelmulcsr(int n_row, int n_col, int Ap, int Aj, long Ax, int Bp, + int Bj, long Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, + std::vector<(long)> Cx) csrelmulcsr(int n_row, int n_col, int Ap, int Aj, float Ax, int Bp, int Bj, float Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(float)> Cx) csrelmulcsr(int n_row, int n_col, int Ap, int Aj, double Ax, int Bp, int Bj, double Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(double)> Cx) - csrelmulcsr(int n_row, int n_col, int Ap, int Aj, long double Ax, - int Bp, int Bj, long double Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(long double)> Cx) csrelmulcsr(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, int Bp, int Bj, npy_cfloat Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_cfloat)> Cx) csrelmulcsr(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, int Bp, int Bj, npy_cdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Cj, std::vector<(npy_cdouble)> Cx) - csrelmulcsr(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - int Bp, int Bj, npy_clongdouble Bx, std::vector<(int)> Cp, - std::vector<(int)> Cj, std::vector<(npy_clongdouble)> Cx) """ return _sparsetools.csrelmulcsr(*args) def cscelmulcsc(*args): """ + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, int Ax, int Bp, + int Bi, int Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(int)> Cx) + cscelmulcsc(int n_row, int n_col, int Ap, int Ai, long Ax, int Bp, + int Bi, long Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, + std::vector<(long)> Cx) cscelmulcsc(int n_row, int n_col, int Ap, int Ai, float Ax, int Bp, int Bi, float Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(float)> Cx) cscelmulcsc(int n_row, int n_col, int Ap, int Ai, double Ax, int Bp, int Bi, double Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(double)> Cx) - cscelmulcsc(int n_row, int n_col, int Ap, int Ai, long double Ax, - int Bp, int Bi, long double Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(long double)> Cx) cscelmulcsc(int n_row, int n_col, int Ap, int Ai, npy_cfloat Ax, int Bp, int Bi, npy_cfloat Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_cfloat)> Cx) cscelmulcsc(int n_row, int n_col, int Ap, int Ai, npy_cdouble Ax, int Bp, int Bi, npy_cdouble Bx, std::vector<(int)> Cp, std::vector<(int)> Ci, std::vector<(npy_cdouble)> Cx) - cscelmulcsc(int n_row, int n_col, int Ap, int Ai, npy_clongdouble Ax, - int Bp, int Bi, npy_clongdouble Bx, std::vector<(int)> Cp, - std::vector<(int)> Ci, std::vector<(npy_clongdouble)> Cx) """ return _sparsetools.cscelmulcsc(*args) def spdiags(*args): """ + spdiags(int n_row, int n_col, int n_diag, int offsets, int diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(int)> Ax) + spdiags(int n_row, int n_col, int n_diag, int offsets, long diags, + std::vector<(int)> Ap, std::vector<(int)> Ai, + std::vector<(long)> Ax) spdiags(int n_row, int n_col, int n_diag, int offsets, float diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(float)> Ax) spdiags(int n_row, int n_col, int n_diag, int offsets, double diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(double)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, long double diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(long double)> Ax) spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cfloat diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(npy_cfloat)> Ax) spdiags(int n_row, int n_col, int n_diag, int offsets, npy_cdouble diags, std::vector<(int)> Ap, std::vector<(int)> Ai, std::vector<(npy_cdouble)> Ax) - spdiags(int n_row, int n_col, int n_diag, int offsets, npy_clongdouble diags, - std::vector<(int)> Ap, std::vector<(int)> Ai, - std::vector<(npy_clongdouble)> Ax) """ return _sparsetools.spdiags(*args) def csrtodense(*args): """ + csrtodense(int n_row, int n_col, int Ap, int Aj, int Ax, int Mx) + csrtodense(int n_row, int n_col, int Ap, int Aj, long Ax, long Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, float Ax, float Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, double Ax, double Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, long double Ax, - long double Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cfloat Ax, npy_cfloat Mx) csrtodense(int n_row, int n_col, int Ap, int Aj, npy_cdouble Ax, npy_cdouble Mx) - csrtodense(int n_row, int n_col, int Ap, int Aj, npy_clongdouble Ax, - npy_clongdouble Mx) """ return _sparsetools.csrtodense(*args) def densetocsr(*args): """ + densetocsr(int n_row, int n_col, int Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(int)> Ax) + densetocsr(int n_row, int n_col, long Mx, std::vector<(int)> Ap, + std::vector<(int)> Aj, std::vector<(long)> Ax) densetocsr(int n_row, int n_col, float Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(float)> Ax) densetocsr(int n_row, int n_col, double Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(double)> Ax) - densetocsr(int n_row, int n_col, long double Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(long double)> Ax) densetocsr(int n_row, int n_col, npy_cfloat Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(npy_cfloat)> Ax) densetocsr(int n_row, int n_col, npy_cdouble Mx, std::vector<(int)> Ap, std::vector<(int)> Aj, std::vector<(npy_cdouble)> Ax) - densetocsr(int n_row, int n_col, npy_clongdouble Mx, std::vector<(int)> Ap, - std::vector<(int)> Aj, std::vector<(npy_clongdouble)> Ax) """ return _sparsetools.densetocsr(*args) Modified: trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-09 05:49:05 UTC (rev 2509) +++ trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-09 11:36:44 UTC (rev 2510) @@ -2466,16 +2466,14 @@ /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_char swig_types[0] -#define SWIGTYPE_p_npy_clongdouble swig_types[1] -#define SWIGTYPE_p_std__vectorTdouble_t swig_types[2] -#define SWIGTYPE_p_std__vectorTfloat_t swig_types[3] -#define SWIGTYPE_p_std__vectorTint_t swig_types[4] -#define SWIGTYPE_p_std__vectorTlong_double_t swig_types[5] -#define SWIGTYPE_p_std__vectorTnpy_cdouble_t swig_types[6] -#define SWIGTYPE_p_std__vectorTnpy_cfloat_t swig_types[7] -#define SWIGTYPE_p_std__vectorTnpy_clongdouble_t swig_types[8] -static swig_type_info *swig_types[10]; -static swig_module_info swig_module = {swig_types, 9, 0, 0, 0, 0}; +#define SWIGTYPE_p_std__vectorTdouble_t swig_types[1] +#define SWIGTYPE_p_std__vectorTfloat_t swig_types[2] +#define SWIGTYPE_p_std__vectorTint_t swig_types[3] +#define SWIGTYPE_p_std__vectorTlong_t swig_types[4] +#define SWIGTYPE_p_std__vectorTnpy_cdouble_t swig_types[5] +#define SWIGTYPE_p_std__vectorTnpy_cfloat_t swig_types[6] +static swig_type_info *swig_types[8]; +static swig_module_info swig_module = {swig_types, 7, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2613,11 +2611,14 @@ /* Given a Numeric typecode, return a string describing the type. */ -char* typecode_string(int typecode) { - char* type_names[20] = {"char","unsigned byte","byte","short", - "unsigned short","int","unsigned int","long", - "float","double","complex float","complex double", - "object","ntype","unkown"}; +char* type_names[20] = {"char","unsigned byte","byte","short", + "unsigned short","int","unsigned int","long", + "float","double","complex float","complex double", + "object","ntype","unkown"}; + char* typecode_string(int typecode) { + if(typecode < 0 || typecode > 19) + typecode = 19; + return type_names[typecode]; } @@ -2859,10 +2860,6 @@ } - - - - #include #ifndef LLONG_MIN # define LLONG_MIN LONG_LONG_MIN @@ -3018,10 +3015,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3034,7 +3031,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3050,7 +3047,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -3084,11 +3081,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } - csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3106,8 +3103,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -3141,10 +3138,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3157,7 +3154,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3173,7 +3170,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -3207,11 +3204,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } - csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3229,8 +3226,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -3264,10 +3261,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3280,7 +3277,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3296,7 +3293,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -3330,11 +3327,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } - csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3352,8 +3349,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -3387,10 +3384,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3403,7 +3400,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3419,7 +3416,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -3453,11 +3450,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } - csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3475,8 +3472,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -3510,10 +3507,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3526,7 +3523,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3542,7 +3539,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -3576,11 +3573,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } - csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3598,8 +3595,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -3633,10 +3630,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3649,7 +3646,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3665,7 +3662,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocsc",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -3699,11 +3696,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } - csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + csrtocsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -3721,8 +3718,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -3781,7 +3778,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrtocsc__SWIG_1(self, args); @@ -3812,7 +3809,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrtocsc__SWIG_2(self, args); @@ -3843,7 +3840,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrtocsc__SWIG_3(self, args); @@ -3874,7 +3871,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrtocsc__SWIG_4(self, args); @@ -3905,7 +3902,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrtocsc__SWIG_5(self, args); @@ -3936,7 +3933,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrtocsc__SWIG_6(self, args); @@ -3948,7 +3945,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n csrtocsc<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocsc'.\n Possible C/C++ prototypes are:\n csrtocsc<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,long)>(int const,int const,int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocsc<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -3959,10 +3956,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -3975,7 +3972,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -3991,7 +3988,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4025,11 +4022,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } - csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4047,8 +4044,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -4082,10 +4079,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -4098,7 +4095,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4114,7 +4111,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4148,11 +4145,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } - csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4170,8 +4167,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -4205,10 +4202,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -4221,7 +4218,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4237,7 +4234,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4271,11 +4268,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } - csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4293,8 +4290,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -4328,10 +4325,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -4344,7 +4341,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4360,7 +4357,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4394,11 +4391,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } - csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4416,8 +4413,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -4451,10 +4448,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -4467,7 +4464,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4483,7 +4480,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4517,11 +4514,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } - csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4539,8 +4536,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -4574,10 +4571,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -4590,7 +4587,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4606,7 +4603,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocsr",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4640,11 +4637,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } - csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + csctocsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4662,8 +4659,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -4722,7 +4719,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csctocsr__SWIG_1(self, args); @@ -4753,7 +4750,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csctocsr__SWIG_2(self, args); @@ -4784,7 +4781,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csctocsr__SWIG_3(self, args); @@ -4815,7 +4812,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csctocsr__SWIG_4(self, args); @@ -4846,7 +4843,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csctocsr__SWIG_5(self, args); @@ -4877,7 +4874,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csctocsr__SWIG_6(self, args); @@ -4889,7 +4886,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n csctocsr<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocsr'.\n Possible C/C++ prototypes are:\n csctocsr<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,long)>(int const,int const,int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocsr<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -4900,10 +4897,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -4916,7 +4913,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4932,7 +4929,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -4966,11 +4963,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } - csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -4988,8 +4985,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -5023,10 +5020,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -5039,7 +5036,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -5055,7 +5052,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -5089,11 +5086,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } - csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5111,8 +5108,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -5146,10 +5143,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -5162,7 +5159,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -5178,7 +5175,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -5212,11 +5209,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } - csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5234,8 +5231,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -5269,10 +5266,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -5285,7 +5282,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -5301,7 +5298,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -5335,11 +5332,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } - csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5357,8 +5354,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -5392,10 +5389,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -5408,7 +5405,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -5424,7 +5421,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -5458,11 +5455,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } - csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5480,8 +5477,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -5515,10 +5512,10 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -5531,7 +5528,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -5547,7 +5544,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:csrtocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -5581,11 +5578,11 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } - csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + csrtocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -5603,8 +5600,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -5663,7 +5660,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrtocoo__SWIG_1(self, args); @@ -5694,7 +5691,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrtocoo__SWIG_2(self, args); @@ -5725,7 +5722,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrtocoo__SWIG_3(self, args); @@ -5756,7 +5753,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrtocoo__SWIG_4(self, args); @@ -5787,7 +5784,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrtocoo__SWIG_5(self, args); @@ -5818,7 +5815,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrtocoo__SWIG_6(self, args); @@ -5830,45 +5827,45 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n csrtocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtocoo'.\n Possible C/C++ prototypes are:\n csrtocoo<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,long)>(int const,int const,int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrtocoo<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int arg3 ; + int *arg3 ; int *arg4 ; int *arg5 ; - float *arg6 ; + std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - PyArrayObject *array6 = NULL ; - int is_new_object6 ; + std::vector *tmp6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { tmp7 = new std::vector(); arg7 = tmp7; } @@ -5876,30 +5873,29 @@ tmp8 = new std::vector(); arg8 = tmp8; } - { - tmp9 = new std::vector(); - arg9 = tmp9; - } - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; + } + { + npy_intp size[1] = { + -1 + }; array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; arg4 = (int*) array4->data; @@ -5912,16 +5908,15 @@ if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; arg5 = (int*) array5->data; } + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); { - npy_intp size[1] = { - -1 - }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (float*) array6->data; + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } - cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); - resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); @@ -5937,11 +5932,7 @@ resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(float)*length); - delete arg9; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + if (is_new_object3 && array3) Py_DECREF(array3); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -5949,112 +5940,107 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return resultobj; fail: { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int arg3 ; + int *arg3 ; int *arg4 ; - int *arg5 ; - double *arg6 ; + long *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - PyArrayObject *array6 = NULL ; - int is_new_object6 ; + std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - { - tmp9 = new std::vector(); - arg9 = tmp9; - } - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (int*) array5->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (double*) array6->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (long*) array5->data; } - cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -6063,17 +6049,13 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(double)*length); - delete arg9; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + if (is_new_object3 && array3) Py_DECREF(array3); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -6081,112 +6063,107 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return resultobj; fail: { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int arg3 ; + int *arg3 ; int *arg4 ; - int *arg5 ; - long double *arg6 ; + float *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - PyArrayObject *array6 = NULL ; - int is_new_object6 ; + std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - { - tmp9 = new std::vector(); - arg9 = tmp9; - } - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (int*) array5->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (long double*) array6->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (float*) array5->data; } - cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -6195,17 +6172,13 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(long double)*length); - delete arg9; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + if (is_new_object3 && array3) Py_DECREF(array3); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -6213,112 +6186,107 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return resultobj; fail: { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int arg3 ; + int *arg3 ; int *arg4 ; - int *arg5 ; - npy_cfloat *arg6 ; + double *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - PyArrayObject *array6 = NULL ; - int is_new_object6 ; + std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - { - tmp9 = new std::vector(); - arg9 = tmp9; - } - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (int*) array5->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cfloat*) array6->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (double*) array5->data; } - cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -6327,17 +6295,13 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cfloat)*length); - delete arg9; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + if (is_new_object3 && array3) Py_DECREF(array3); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -6345,112 +6309,107 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return resultobj; fail: { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int arg3 ; + int *arg3 ; int *arg4 ; - int *arg5 ; - npy_cdouble *arg6 ; + npy_cfloat *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - PyArrayObject *array6 = NULL ; - int is_new_object6 ; + std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - { - tmp9 = new std::vector(); - arg9 = tmp9; - } - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (int*) array5->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cdouble*) array6->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cfloat*) array5->data; } - cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -6459,17 +6418,13 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cdouble)*length); - delete arg9; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + if (is_new_object3 && array3) Py_DECREF(array3); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -6477,112 +6432,107 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return resultobj; fail: { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int arg3 ; + int *arg3 ; int *arg4 ; - int *arg5 ; - npy_clongdouble *arg6 ; + npy_cdouble *arg5 ; + std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - PyArrayObject *array6 = NULL ; - int is_new_object6 ; + std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; { + tmp6 = new std::vector(); + arg6 = tmp6; + } + { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - { - tmp9 = new std::vector(); - arg9 = tmp9; - } - if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); - } - arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); + if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (int*) array3->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (int*) array5->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); - if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_clongdouble*) array6->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; } - cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); + csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { + int length = (arg6)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); + delete arg6; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + } + { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -6591,17 +6541,13 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_clongdouble)*length); - delete arg9; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); + if (is_new_object3 && array3) Py_DECREF(array3); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -6609,35 +6555,32 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return resultobj; fail: { + if (is_new_object3 && array3) Py_DECREF(array3); + } + { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } - { - if (is_new_object6 && array6) Py_DECREF(array6); - } return NULL; } -SWIGINTERN PyObject *_wrap_cootocsr(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_csctocoo(PyObject *self, PyObject *args) { int argc; - PyObject *argv[7]; + PyObject *argv[6]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = PyObject_Length(args); - for (ii = 0; (ii < argc) && (ii < 6); ii++) { + for (ii = 0; (ii < argc) && (ii < 5); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } - if (argc == 6) { + if (argc == 5) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -6650,8 +6593,7 @@ } if (_v) { { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -6662,19 +6604,14 @@ _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; - } - if (_v) { - return _wrap_cootocsr__SWIG_1(self, args); - } + return _wrap_csctocoo__SWIG_1(self, args); } } } } } } - if (argc == 6) { + if (argc == 5) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -6687,8 +6624,7 @@ } if (_v) { { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -6696,22 +6632,17 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { - { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; - } - if (_v) { - return _wrap_cootocsr__SWIG_2(self, args); - } + return _wrap_csctocoo__SWIG_2(self, args); } } } } } } - if (argc == 6) { + if (argc == 5) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -6724,8 +6655,7 @@ } if (_v) { { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -6733,22 +6663,17 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { - { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; - } - if (_v) { - return _wrap_cootocsr__SWIG_3(self, args); - } + return _wrap_csctocoo__SWIG_3(self, args); } } } } } } - if (argc == 6) { + if (argc == 5) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -6761,8 +6686,7 @@ } if (_v) { { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -6770,22 +6694,17 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { - { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; - } - if (_v) { - return _wrap_cootocsr__SWIG_4(self, args); - } + return _wrap_csctocoo__SWIG_4(self, args); } } } } } } - if (argc == 6) { + if (argc == 5) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -6798,8 +6717,7 @@ } if (_v) { { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -6807,22 +6725,17 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { - { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; - } - if (_v) { - return _wrap_cootocsr__SWIG_5(self, args); - } + return _wrap_csctocoo__SWIG_5(self, args); } } } } } } - if (argc == 6) { + if (argc == 5) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -6835,8 +6748,7 @@ } if (_v) { { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -6844,15 +6756,10 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { - { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; - } - if (_v) { - return _wrap_cootocsr__SWIG_6(self, args); - } + return _wrap_csctocoo__SWIG_6(self, args); } } } @@ -6861,97 +6768,99 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n cootocsr<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n csctocoo<(int,int)>(int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,long)>(int const,int const,int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int *arg3 ; + int arg3 ; int *arg4 ; - float *arg5 ; - std::vector *arg6 = (std::vector *) 0 ; + int *arg5 ; + int *arg6 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - PyArrayObject *array3 = NULL ; - int is_new_object3 ; + int val3 ; + int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - std::vector *tmp6 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; { - tmp6 = new std::vector(); - arg6 = tmp6; - } - { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (int*) array3->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (int*) array6->data; } - csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); - delete arg6; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); - } - { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -6960,13 +6869,17 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -6974,107 +6887,112 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); - } - { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int *arg3 ; + int arg3 ; int *arg4 ; - double *arg5 ; - std::vector *arg6 = (std::vector *) 0 ; + int *arg5 ; + long *arg6 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - PyArrayObject *array3 = NULL ; - int is_new_object3 ; + int val3 ; + int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - std::vector *tmp6 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; { - tmp6 = new std::vector(); - arg6 = tmp6; - } - { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (int*) array3->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONG, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (long*) array6->data; } - csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); - delete arg6; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); - } - { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -7083,13 +7001,17 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(long)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -7097,107 +7019,112 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); - } - { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int *arg3 ; + int arg3 ; int *arg4 ; - long double *arg5 ; - std::vector *arg6 = (std::vector *) 0 ; + int *arg5 ; + float *arg6 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - PyArrayObject *array3 = NULL ; - int is_new_object3 ; + int val3 ; + int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - std::vector *tmp6 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; { - tmp6 = new std::vector(); - arg6 = tmp6; - } - { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (int*) array3->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (float*) array6->data; } - csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); - delete arg6; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); - } - { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -7206,13 +7133,17 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(float)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -7220,107 +7151,112 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); - } - { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_4(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int *arg3 ; + int arg3 ; int *arg4 ; - npy_cfloat *arg5 ; - std::vector *arg6 = (std::vector *) 0 ; + int *arg5 ; + double *arg6 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - PyArrayObject *array3 = NULL ; - int is_new_object3 ; + int val3 ; + int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - std::vector *tmp6 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; { - tmp6 = new std::vector(); - arg6 = tmp6; - } - { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (int*) array3->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (double*) array6->data; } - csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); - delete arg6; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); - } - { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -7329,13 +7265,17 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(double)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -7343,107 +7283,112 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); - } - { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_5(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int *arg3 ; + int arg3 ; int *arg4 ; - npy_cdouble *arg5 ; - std::vector *arg6 = (std::vector *) 0 ; + int *arg5 ; + npy_cfloat *arg6 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - PyArrayObject *array3 = NULL ; - int is_new_object3 ; + int val3 ; + int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - std::vector *tmp6 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; { - tmp6 = new std::vector(); - arg6 = tmp6; - } - { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (int*) array3->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cfloat*) array6->data; } - csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); - delete arg6; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); - } - { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -7452,13 +7397,17 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cfloat)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -7466,107 +7415,112 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); - } - { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr__SWIG_6(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; - int *arg3 ; + int arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; - std::vector *arg6 = (std::vector *) 0 ; + int *arg5 ; + npy_cdouble *arg6 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - PyArrayObject *array3 = NULL ; - int is_new_object3 ; + int val3 ; + int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - std::vector *tmp6 ; + PyArrayObject *array6 = NULL ; + int is_new_object6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; { - tmp6 = new std::vector(); - arg6 = tmp6; - } - { tmp7 = new std::vector(); arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } - if (!PyArg_ParseTuple(args,(char *)"OOOOO:csctocoo",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + { + tmp9 = new std::vector(); + arg9 = tmp9; + } + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "csctocoo" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cootocsr" "', argument " "1"" of type '" "int""'"); } arg1 = static_cast< int >(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "csctocoo" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cootocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "cootocsr" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); { npy_intp size[1] = { -1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); - if (!array3 || !require_dimensions(array3,1) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (int*) array3->data; + array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); + if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; + arg4 = (int*) array4->data; } { npy_intp size[1] = { -1 }; - array4 = obj_to_array_contiguous_allow_conversion(obj3, PyArray_INT, &is_new_object4); - if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; - arg4 = (int*) array4->data; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); + if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); - if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; + arg6 = (npy_cdouble*) array6->data; } - csctocoo(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + cootocsr(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { - int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); - delete arg6; - resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); - } - { int length = (arg7)->size(); PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); @@ -7575,13 +7529,17 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { - if (is_new_object3 && array3) Py_DECREF(array3); + int length = (arg9)->size(); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cdouble)*length); + delete arg9; + resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); @@ -7589,32 +7547,35 @@ { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return resultobj; fail: { - if (is_new_object3 && array3) Py_DECREF(array3); - } - { if (is_new_object4 && array4) Py_DECREF(array4); } { if (is_new_object5 && array5) Py_DECREF(array5); } + { + if (is_new_object6 && array6) Py_DECREF(array6); + } return NULL; } -SWIGINTERN PyObject *_wrap_csctocoo(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_cootocsr(PyObject *self, PyObject *args) { int argc; - PyObject *argv[6]; + PyObject *argv[7]; int ii; if (!PyTuple_Check(args)) SWIG_fail; argc = PyObject_Length(args); - for (ii = 0; (ii < argc) && (ii < 5); ii++) { + for (ii = 0; (ii < argc) && (ii < 6); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } - if (argc == 5) { + if (argc == 6) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -7627,7 +7588,8 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); } if (_v) { { @@ -7635,17 +7597,22 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - return _wrap_csctocoo__SWIG_1(self, args); + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_1(self, args); + } } } } } } } - if (argc == 5) { + if (argc == 6) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -7658,7 +7625,8 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); } if (_v) { { @@ -7666,17 +7634,22 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - return _wrap_csctocoo__SWIG_2(self, args); + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONG)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_2(self, args); + } } } } } } } - if (argc == 5) { + if (argc == 6) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -7689,7 +7662,8 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); } if (_v) { { @@ -7697,17 +7671,22 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - return _wrap_csctocoo__SWIG_3(self, args); + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_3(self, args); + } } } } } } } - if (argc == 5) { + if (argc == 6) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -7720,7 +7699,8 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); } if (_v) { { @@ -7728,17 +7708,22 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - return _wrap_csctocoo__SWIG_4(self, args); + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_4(self, args); + } } } } } } } - if (argc == 5) { + if (argc == 6) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -7751,7 +7736,8 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); } if (_v) { { @@ -7759,17 +7745,22 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - return _wrap_csctocoo__SWIG_5(self, args); + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_5(self, args); + } } } } } } } - if (argc == 5) { + if (argc == 6) { int _v; { int res = SWIG_AsVal_int(argv[0], NULL); @@ -7782,7 +7773,8 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); } if (_v) { { @@ -7790,10 +7782,15 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { - return _wrap_csctocoo__SWIG_6(self, args); + { + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + } + if (_v) { + return _wrap_cootocsr__SWIG_6(self, args); + } } } } @@ -7802,7 +7799,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csctocoo'.\n Possible C/C++ prototypes are:\n csctocoo<(float)>(int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(double)>(int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(long double)>(int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csctocoo<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsr'.\n Possible C/C++ prototypes are:\n cootocsr<(int,int)>(int const,int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,long)>(int const,int const,int const,int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsr<(int,npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -7814,10 +7811,10 @@ int arg3 ; int *arg4 ; int *arg5 ; - float *arg6 ; + int *arg6 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -7832,7 +7829,7 @@ int is_new_object6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -7849,7 +7846,7 @@ arg8 = tmp8; } { - tmp9 = new std::vector(); + tmp9 = new std::vector(); arg9 = tmp9; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -7888,11 +7885,11 @@ npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (float*) array6->data; + arg6 = (int*) array6->data; } - cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -7910,8 +7907,8 @@ } { int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(int)*length); delete arg9; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -7946,10 +7943,10 @@ int arg3 ; int *arg4 ; int *arg5 ; - double *arg6 ; + long *arg6 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -7964,7 +7961,7 @@ int is_new_object6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -7981,7 +7978,7 @@ arg8 = tmp8; } { - tmp9 = new std::vector(); + tmp9 = new std::vector(); arg9 = tmp9; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -8020,11 +8017,11 @@ npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONG, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (double*) array6->data; + arg6 = (long*) array6->data; } - cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8042,8 +8039,8 @@ } { int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(long)*length); delete arg9; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -8078,10 +8075,10 @@ int arg3 ; int *arg4 ; int *arg5 ; - long double *arg6 ; + float *arg6 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -8096,7 +8093,7 @@ int is_new_object6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -8113,7 +8110,7 @@ arg8 = tmp8; } { - tmp9 = new std::vector(); + tmp9 = new std::vector(); arg9 = tmp9; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -8152,11 +8149,11 @@ npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (long double*) array6->data; + arg6 = (float*) array6->data; } - cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(long double const (*))arg6,arg7,arg8,arg9); + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(float const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8174,8 +8171,8 @@ } { int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(float)*length); delete arg9; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -8210,10 +8207,10 @@ int arg3 ; int *arg4 ; int *arg5 ; - npy_cfloat *arg6 ; + double *arg6 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -8228,7 +8225,7 @@ int is_new_object6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -8245,7 +8242,7 @@ arg8 = tmp8; } { - tmp9 = new std::vector(); + tmp9 = new std::vector(); arg9 = tmp9; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -8284,11 +8281,11 @@ npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cfloat*) array6->data; + arg6 = (double*) array6->data; } - cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(double const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8306,8 +8303,8 @@ } { int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(double)*length); delete arg9; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -8342,10 +8339,10 @@ int arg3 ; int *arg4 ; int *arg5 ; - npy_cdouble *arg6 ; + npy_cfloat *arg6 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -8360,7 +8357,7 @@ int is_new_object6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -8377,7 +8374,7 @@ arg8 = tmp8; } { - tmp9 = new std::vector(); + tmp9 = new std::vector(); arg9 = tmp9; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -8416,11 +8413,11 @@ npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cdouble*) array6->data; + arg6 = (npy_cfloat*) array6->data; } - cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cfloat const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8438,8 +8435,8 @@ } { int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cfloat)*length); delete arg9; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -8474,10 +8471,10 @@ int arg3 ; int *arg4 ; int *arg5 ; - npy_clongdouble *arg6 ; + npy_cdouble *arg6 ; std::vector *arg7 = (std::vector *) 0 ; std::vector *arg8 = (std::vector *) 0 ; - std::vector *arg9 = (std::vector *) 0 ; + std::vector *arg9 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -8492,7 +8489,7 @@ int is_new_object6 ; std::vector *tmp7 ; std::vector *tmp8 ; - std::vector *tmp9 ; + std::vector *tmp9 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -8509,7 +8506,7 @@ arg8 = tmp8; } { - tmp9 = new std::vector(); + tmp9 = new std::vector(); arg9 = tmp9; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cootocsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -8548,11 +8545,11 @@ npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_clongdouble*) array6->data; + arg6 = (npy_cdouble*) array6->data; } - cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_clongdouble const (*))arg6,arg7,arg8,arg9); + cootocsc(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,(npy_cdouble const (*))arg6,arg7,arg8,arg9); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); @@ -8570,8 +8567,8 @@ } { int length = (arg9)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg9))[0]),sizeof(npy_cdouble)*length); delete arg9; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -8635,7 +8632,7 @@ } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_cootocsc__SWIG_1(self, args); @@ -8672,7 +8669,7 @@ } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_cootocsc__SWIG_2(self, args); @@ -8709,7 +8706,7 @@ } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_cootocsc__SWIG_3(self, args); @@ -8746,7 +8743,7 @@ } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cootocsc__SWIG_4(self, args); @@ -8783,7 +8780,7 @@ } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_cootocsc__SWIG_5(self, args); @@ -8820,7 +8817,7 @@ } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cootocsc__SWIG_6(self, args); @@ -8833,7 +8830,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n cootocsc<(float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(long double)>(int const,int const,int const,int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(npy_clongdouble)>(int const,int const,int const,int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cootocsc'.\n Possible C/C++ prototypes are:\n cootocsc<(int,int)>(int const,int const,int const,int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,long)>(int const,int const,int const,int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,float)>(int const,int const,int const,int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,double)>(int const,int const,int const,int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,npy_cfloat)>(int const,int const,int const,int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cootocsc<(int,npy_cdouble)>(int const,int const,int const,int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -8844,13 +8841,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; int *arg6 ; int *arg7 ; - float *arg8 ; + int *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -8869,7 +8866,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -8888,7 +8885,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -8922,9 +8919,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { @@ -8946,11 +8943,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (float*) array8->data; + arg8 = (int*) array8->data; } - csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -8968,8 +8965,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(int)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -9021,13 +9018,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; int *arg6 ; int *arg7 ; - double *arg8 ; + long *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -9046,7 +9043,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -9065,7 +9062,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -9099,9 +9096,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { @@ -9123,11 +9120,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONG, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (double*) array8->data; + arg8 = (long*) array8->data; } - csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9145,8 +9142,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -9198,13 +9195,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; int *arg6 ; int *arg7 ; - long double *arg8 ; + float *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -9223,7 +9220,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -9242,7 +9239,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -9276,9 +9273,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { @@ -9300,11 +9297,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (long double*) array8->data; + arg8 = (float*) array8->data; } - csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9322,8 +9319,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -9375,13 +9372,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; int *arg6 ; int *arg7 ; - npy_cfloat *arg8 ; + double *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -9400,7 +9397,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -9419,7 +9416,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -9453,9 +9450,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { @@ -9477,11 +9474,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cfloat*) array8->data; + arg8 = (double*) array8->data; } - csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9499,8 +9496,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -9552,13 +9549,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; int *arg6 ; int *arg7 ; - npy_cdouble *arg8 ; + npy_cfloat *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -9577,7 +9574,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -9596,7 +9593,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -9630,9 +9627,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { @@ -9654,11 +9651,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cdouble*) array8->data; + arg8 = (npy_cfloat*) array8->data; } - csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9676,8 +9673,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -9729,13 +9726,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; int *arg6 ; int *arg7 ; - npy_clongdouble *arg8 ; + npy_cdouble *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -9754,7 +9751,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -9773,7 +9770,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrplcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -9807,9 +9804,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { @@ -9831,11 +9828,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_clongdouble*) array8->data; + arg8 = (npy_cdouble*) array8->data; } - csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + csrplcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -9853,8 +9850,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -9931,7 +9928,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -9943,7 +9940,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrplcsr__SWIG_1(self, args); @@ -9977,7 +9974,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { @@ -9989,7 +9986,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrplcsr__SWIG_2(self, args); @@ -10023,7 +10020,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { @@ -10035,7 +10032,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrplcsr__SWIG_3(self, args); @@ -10069,7 +10066,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { @@ -10081,7 +10078,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrplcsr__SWIG_4(self, args); @@ -10115,7 +10112,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { @@ -10127,7 +10124,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrplcsr__SWIG_5(self, args); @@ -10161,7 +10158,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { @@ -10173,7 +10170,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrplcsr__SWIG_6(self, args); @@ -10188,7 +10185,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrplcsr'.\n Possible C/C++ prototypes are:\n csrplcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrplcsr'.\n Possible C/C++ prototypes are:\n csrplcsr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(int,long)>(int const,int const,int const [],int const [],long const [],int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrplcsr<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -10199,13 +10196,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; int *arg6 ; int *arg7 ; - float *arg8 ; + int *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -10224,7 +10221,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -10243,7 +10240,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -10277,9 +10274,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { @@ -10301,11 +10298,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (float*) array8->data; + arg8 = (int*) array8->data; } - cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10323,8 +10320,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(int)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -10376,13 +10373,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; int *arg6 ; int *arg7 ; - double *arg8 ; + long *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -10401,7 +10398,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -10420,7 +10417,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -10454,9 +10451,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { @@ -10478,11 +10475,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONG, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (double*) array8->data; + arg8 = (long*) array8->data; } - cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10500,8 +10497,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -10553,13 +10550,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; int *arg6 ; int *arg7 ; - long double *arg8 ; + float *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -10578,7 +10575,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -10597,7 +10594,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -10631,9 +10628,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { @@ -10655,11 +10652,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (long double*) array8->data; + arg8 = (float*) array8->data; } - cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10677,8 +10674,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -10730,13 +10727,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; int *arg6 ; int *arg7 ; - npy_cfloat *arg8 ; + double *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -10755,7 +10752,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -10774,7 +10771,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -10808,9 +10805,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { @@ -10832,11 +10829,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cfloat*) array8->data; + arg8 = (double*) array8->data; } - cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -10854,8 +10851,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -10907,13 +10904,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; int *arg6 ; int *arg7 ; - npy_cdouble *arg8 ; + npy_cfloat *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -10932,7 +10929,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -10951,7 +10948,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -10985,9 +10982,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { @@ -11009,11 +11006,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cdouble*) array8->data; + arg8 = (npy_cfloat*) array8->data; } - cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11031,8 +11028,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -11084,13 +11081,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; int *arg6 ; int *arg7 ; - npy_clongdouble *arg8 ; + npy_cdouble *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -11109,7 +11106,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -11128,7 +11125,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscplcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -11162,9 +11159,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { @@ -11186,11 +11183,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_clongdouble*) array8->data; + arg8 = (npy_cdouble*) array8->data; } - cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + cscplcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11208,8 +11205,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -11286,7 +11283,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -11298,7 +11295,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_cscplcsc__SWIG_1(self, args); @@ -11332,7 +11329,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { @@ -11344,7 +11341,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_cscplcsc__SWIG_2(self, args); @@ -11378,7 +11375,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { @@ -11390,7 +11387,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscplcsc__SWIG_3(self, args); @@ -11424,7 +11421,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { @@ -11436,7 +11433,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscplcsc__SWIG_4(self, args); @@ -11470,7 +11467,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { @@ -11482,7 +11479,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscplcsc__SWIG_5(self, args); @@ -11516,7 +11513,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { @@ -11528,7 +11525,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscplcsc__SWIG_6(self, args); @@ -11543,7 +11540,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscplcsc'.\n Possible C/C++ prototypes are:\n cscplcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscplcsc'.\n Possible C/C++ prototypes are:\n cscplcsc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(int,long)>(int const,int const,int const [],int const [],long const [],int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscplcsc<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -11554,13 +11551,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; int *arg6 ; int *arg7 ; - float *arg8 ; + int *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -11579,7 +11576,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -11598,7 +11595,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -11632,9 +11629,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { @@ -11656,11 +11653,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (float*) array8->data; + arg8 = (int*) array8->data; } - csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11678,8 +11675,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(int)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -11731,13 +11728,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; int *arg6 ; int *arg7 ; - double *arg8 ; + long *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -11756,7 +11753,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -11775,7 +11772,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -11809,9 +11806,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { @@ -11833,11 +11830,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONG, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (double*) array8->data; + arg8 = (long*) array8->data; } - csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -11855,8 +11852,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -11908,13 +11905,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; int *arg6 ; int *arg7 ; - long double *arg8 ; + float *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -11933,7 +11930,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -11952,7 +11949,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -11986,9 +11983,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { @@ -12010,11 +12007,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (long double*) array8->data; + arg8 = (float*) array8->data; } - csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12032,8 +12029,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -12085,13 +12082,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; int *arg6 ; int *arg7 ; - npy_cfloat *arg8 ; + double *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -12110,7 +12107,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -12129,7 +12126,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -12163,9 +12160,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { @@ -12187,11 +12184,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cfloat*) array8->data; + arg8 = (double*) array8->data; } - csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12209,8 +12206,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -12262,13 +12259,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; int *arg6 ; int *arg7 ; - npy_cdouble *arg8 ; + npy_cfloat *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -12287,7 +12284,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -12306,7 +12303,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -12340,9 +12337,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { @@ -12364,11 +12361,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cdouble*) array8->data; + arg8 = (npy_cfloat*) array8->data; } - csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12386,8 +12383,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -12439,13 +12436,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; int *arg6 ; int *arg7 ; - npy_clongdouble *arg8 ; + npy_cdouble *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -12464,7 +12461,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -12483,7 +12480,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrmucsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -12517,9 +12514,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { @@ -12541,11 +12538,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_clongdouble*) array8->data; + arg8 = (npy_cdouble*) array8->data; } - csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + csrmucsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -12563,8 +12560,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -12641,7 +12638,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -12653,7 +12650,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrmucsr__SWIG_1(self, args); @@ -12687,7 +12684,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { @@ -12699,7 +12696,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrmucsr__SWIG_2(self, args); @@ -12733,7 +12730,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { @@ -12745,7 +12742,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrmucsr__SWIG_3(self, args); @@ -12779,7 +12776,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { @@ -12791,7 +12788,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrmucsr__SWIG_4(self, args); @@ -12825,7 +12822,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { @@ -12837,7 +12834,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrmucsr__SWIG_5(self, args); @@ -12871,7 +12868,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { @@ -12883,7 +12880,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrmucsr__SWIG_6(self, args); @@ -12898,7 +12895,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n csrmucsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmucsr'.\n Possible C/C++ prototypes are:\n csrmucsr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,long)>(int const,int const,int const [],int const [],long const [],int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrmucsr<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -12909,13 +12906,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; int *arg6 ; int *arg7 ; - float *arg8 ; + int *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -12934,7 +12931,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -12953,7 +12950,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -12987,9 +12984,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { @@ -13011,11 +13008,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (float*) array8->data; + arg8 = (int*) array8->data; } - cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13033,8 +13030,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(int)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -13086,13 +13083,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; int *arg6 ; int *arg7 ; - double *arg8 ; + long *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -13111,7 +13108,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -13130,7 +13127,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -13164,9 +13161,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { @@ -13188,11 +13185,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONG, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (double*) array8->data; + arg8 = (long*) array8->data; } - cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13210,8 +13207,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -13263,13 +13260,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; int *arg6 ; int *arg7 ; - long double *arg8 ; + float *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -13288,7 +13285,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -13307,7 +13304,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -13341,9 +13338,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { @@ -13365,11 +13362,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (long double*) array8->data; + arg8 = (float*) array8->data; } - cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13387,8 +13384,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -13440,13 +13437,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; int *arg6 ; int *arg7 ; - npy_cfloat *arg8 ; + double *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -13465,7 +13462,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -13484,7 +13481,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -13518,9 +13515,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { @@ -13542,11 +13539,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cfloat*) array8->data; + arg8 = (double*) array8->data; } - cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13564,8 +13561,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -13617,13 +13614,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; int *arg6 ; int *arg7 ; - npy_cdouble *arg8 ; + npy_cfloat *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -13642,7 +13639,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -13661,7 +13658,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -13695,9 +13692,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { @@ -13719,11 +13716,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cdouble*) array8->data; + arg8 = (npy_cfloat*) array8->data; } - cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13741,8 +13738,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -13794,13 +13791,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; int *arg6 ; int *arg7 ; - npy_clongdouble *arg8 ; + npy_cdouble *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -13819,7 +13816,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -13838,7 +13835,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscmucsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -13872,9 +13869,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { @@ -13896,11 +13893,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_clongdouble*) array8->data; + arg8 = (npy_cdouble*) array8->data; } - cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + cscmucsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -13918,8 +13915,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -13996,7 +13993,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -14008,7 +14005,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_cscmucsc__SWIG_1(self, args); @@ -14042,7 +14039,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { @@ -14054,7 +14051,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_cscmucsc__SWIG_2(self, args); @@ -14088,7 +14085,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { @@ -14100,7 +14097,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscmucsc__SWIG_3(self, args); @@ -14134,7 +14131,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { @@ -14146,7 +14143,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscmucsc__SWIG_4(self, args); @@ -14180,7 +14177,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { @@ -14192,7 +14189,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscmucsc__SWIG_5(self, args); @@ -14226,7 +14223,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { @@ -14238,7 +14235,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscmucsc__SWIG_6(self, args); @@ -14253,7 +14250,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n cscmucsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmucsc'.\n Possible C/C++ prototypes are:\n cscmucsc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,long)>(int const,int const,int const [],int const [],long const [],int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscmucsc<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -14264,9 +14261,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; - float *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + int *arg5 ; + int *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -14279,7 +14276,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -14288,7 +14285,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -14322,24 +14319,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (float*) array6->data; + arg6 = (int*) array6->data; } - csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -14379,9 +14376,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; - double *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + long *arg5 ; + long *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -14394,7 +14391,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -14403,7 +14400,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -14437,24 +14434,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONG, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (double*) array6->data; + arg6 = (long*) array6->data; } - csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(long)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -14494,9 +14491,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; - long double *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + float *arg5 ; + float *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -14509,7 +14506,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -14518,7 +14515,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -14552,24 +14549,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (long double*) array6->data; + arg6 = (float*) array6->data; } - csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(float)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -14609,9 +14606,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; - npy_cfloat *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + double *arg5 ; + double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -14624,7 +14621,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -14633,7 +14630,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -14667,24 +14664,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cfloat*) array6->data; + arg6 = (double*) array6->data; } - csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(double)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -14724,9 +14721,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; - npy_cdouble *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + npy_cfloat *arg5 ; + npy_cfloat *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -14739,7 +14736,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -14748,7 +14745,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -14782,24 +14779,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cdouble*) array6->data; + arg6 = (npy_cfloat*) array6->data; } - csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cfloat)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -14839,9 +14836,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; - npy_clongdouble *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + npy_cdouble *arg5 ; + npy_cdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -14854,7 +14851,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -14863,7 +14860,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:csrmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -14897,24 +14894,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_clongdouble*) array6->data; + arg6 = (npy_cdouble*) array6->data; } - csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); + csrmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cdouble)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -14979,11 +14976,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrmux__SWIG_1(self, args); @@ -15015,11 +15012,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrmux__SWIG_2(self, args); @@ -15051,11 +15048,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrmux__SWIG_3(self, args); @@ -15087,11 +15084,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrmux__SWIG_4(self, args); @@ -15123,11 +15120,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrmux__SWIG_5(self, args); @@ -15159,11 +15156,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrmux__SWIG_6(self, args); @@ -15176,7 +15173,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n csrmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n csrmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n csrmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n csrmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n csrmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n csrmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrmux'.\n Possible C/C++ prototypes are:\n csrmux<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],std::vector *)\n csrmux<(int,long)>(int const,int const,int const [],int const [],long const [],long const [],std::vector *)\n csrmux<(int,float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n csrmux<(int,double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n csrmux<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n csrmux<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n"); return NULL; } @@ -15187,9 +15184,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; - float *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + int *arg5 ; + int *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -15202,7 +15199,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -15211,7 +15208,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -15245,24 +15242,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_INT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (float*) array6->data; + arg6 = (int*) array6->data; } - cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(int)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -15302,9 +15299,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; - double *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + long *arg5 ; + long *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -15317,7 +15314,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -15326,7 +15323,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -15360,24 +15357,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONG, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (double*) array6->data; + arg6 = (long*) array6->data; } - cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(long const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(long)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -15417,9 +15414,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; - long double *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + float *arg5 ; + float *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -15432,7 +15429,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -15441,7 +15438,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -15475,24 +15472,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_LONGDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_FLOAT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (long double*) array6->data; + arg6 = (float*) array6->data; } - cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(long double const (*))arg6,arg7); + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(float const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(float)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -15532,9 +15529,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; - npy_cfloat *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + double *arg5 ; + double *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -15547,7 +15544,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -15556,7 +15553,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -15590,24 +15587,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_DOUBLE, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cfloat*) array6->data; + arg6 = (double*) array6->data; } - cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(double const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(double)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -15647,9 +15644,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; - npy_cdouble *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + npy_cfloat *arg5 ; + npy_cfloat *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -15662,7 +15659,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -15671,7 +15668,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -15705,24 +15702,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CFLOAT, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_cdouble*) array6->data; + arg6 = (npy_cfloat*) array6->data; } - cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(npy_cfloat const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cfloat)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -15762,9 +15759,9 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; - npy_clongdouble *arg6 ; - std::vector *arg7 = (std::vector *) 0 ; + npy_cdouble *arg5 ; + npy_cdouble *arg6 ; + std::vector *arg7 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -15777,7 +15774,7 @@ int is_new_object5 ; PyArrayObject *array6 = NULL ; int is_new_object6 ; - std::vector *tmp7 ; + std::vector *tmp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -15786,7 +15783,7 @@ PyObject * obj5 = 0 ; { - tmp7 = new std::vector(); + tmp7 = new std::vector(); arg7 = tmp7; } if (!PyArg_ParseTuple(args,(char *)"OOOOOO:cscmux",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; @@ -15820,24 +15817,24 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { -1 }; - array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CLONGDOUBLE, &is_new_object6); + array6 = obj_to_array_contiguous_allow_conversion(obj5, PyArray_CDOUBLE, &is_new_object6); if (!array6 || !require_dimensions(array6,1) || !require_size(array6,size,1)) SWIG_fail; - arg6 = (npy_clongdouble*) array6->data; + arg6 = (npy_cdouble*) array6->data; } - cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(npy_clongdouble const (*))arg6,arg7); + cscmux(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(npy_cdouble const (*))arg6,arg7); resultobj = SWIG_Py_Void(); { int length = (arg7)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg7))[0]),sizeof(npy_cdouble)*length); delete arg7; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -15902,11 +15899,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_cscmux__SWIG_1(self, args); @@ -15938,11 +15935,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_cscmux__SWIG_2(self, args); @@ -15974,11 +15971,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscmux__SWIG_3(self, args); @@ -16010,11 +16007,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscmux__SWIG_4(self, args); @@ -16046,11 +16043,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscmux__SWIG_5(self, args); @@ -16082,11 +16079,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscmux__SWIG_6(self, args); @@ -16099,7 +16096,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n cscmux<(float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n cscmux<(double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n cscmux<(long double)>(int const,int const,int const [],int const [],long double const [],long double const [],std::vector *)\n cscmux<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n cscmux<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n cscmux<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble const [],std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscmux'.\n Possible C/C++ prototypes are:\n cscmux<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],std::vector *)\n cscmux<(int,long)>(int const,int const,int const [],int const [],long const [],long const [],std::vector *)\n cscmux<(int,float)>(int const,int const,int const [],int const [],float const [],float const [],std::vector *)\n cscmux<(int,double)>(int const,int const,int const [],int const [],double const [],double const [],std::vector *)\n cscmux<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat const [],std::vector *)\n cscmux<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble const [],std::vector *)\n"); return NULL; } @@ -16110,13 +16107,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; int *arg6 ; int *arg7 ; - float *arg8 ; + int *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -16135,7 +16132,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -16154,7 +16151,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -16188,9 +16185,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { @@ -16212,11 +16209,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (float*) array8->data; + arg8 = (int*) array8->data; } - csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16234,8 +16231,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(int)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -16287,13 +16284,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; int *arg6 ; int *arg7 ; - double *arg8 ; + long *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -16312,7 +16309,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -16331,7 +16328,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -16365,9 +16362,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { @@ -16389,11 +16386,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONG, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (double*) array8->data; + arg8 = (long*) array8->data; } - csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16411,8 +16408,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -16464,13 +16461,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; int *arg6 ; int *arg7 ; - long double *arg8 ; + float *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -16489,7 +16486,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -16508,7 +16505,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -16542,9 +16539,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { @@ -16566,11 +16563,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (long double*) array8->data; + arg8 = (float*) array8->data; } - csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16588,8 +16585,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -16641,13 +16638,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; int *arg6 ; int *arg7 ; - npy_cfloat *arg8 ; + double *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -16666,7 +16663,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -16685,7 +16682,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -16719,9 +16716,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { @@ -16743,11 +16740,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cfloat*) array8->data; + arg8 = (double*) array8->data; } - csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16765,8 +16762,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -16818,13 +16815,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; int *arg6 ; int *arg7 ; - npy_cdouble *arg8 ; + npy_cfloat *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -16843,7 +16840,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -16862,7 +16859,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -16896,9 +16893,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { @@ -16920,11 +16917,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cdouble*) array8->data; + arg8 = (npy_cfloat*) array8->data; } - csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -16942,8 +16939,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -16995,13 +16992,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; int *arg6 ; int *arg7 ; - npy_clongdouble *arg8 ; + npy_cdouble *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -17020,7 +17017,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -17039,7 +17036,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:csrelmulcsr",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -17073,9 +17070,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { @@ -17097,11 +17094,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_clongdouble*) array8->data; + arg8 = (npy_cdouble*) array8->data; } - csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + csrelmulcsr(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17119,8 +17116,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -17197,7 +17194,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -17209,7 +17206,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrelmulcsr__SWIG_1(self, args); @@ -17243,7 +17240,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { @@ -17255,7 +17252,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrelmulcsr__SWIG_2(self, args); @@ -17289,7 +17286,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { @@ -17301,7 +17298,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrelmulcsr__SWIG_3(self, args); @@ -17335,7 +17332,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { @@ -17347,7 +17344,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrelmulcsr__SWIG_4(self, args); @@ -17381,7 +17378,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { @@ -17393,7 +17390,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrelmulcsr__SWIG_5(self, args); @@ -17427,7 +17424,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { @@ -17439,7 +17436,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrelmulcsr__SWIG_6(self, args); @@ -17454,7 +17451,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrelmulcsr'.\n Possible C/C++ prototypes are:\n csrelmulcsr<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrelmulcsr'.\n Possible C/C++ prototypes are:\n csrelmulcsr<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(int,long)>(int const,int const,int const [],int const [],long const [],int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n csrelmulcsr<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -17465,13 +17462,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; int *arg6 ; int *arg7 ; - float *arg8 ; + int *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -17490,7 +17487,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -17509,7 +17506,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -17543,9 +17540,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { npy_intp size[1] = { @@ -17567,11 +17564,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_INT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (float*) array8->data; + arg8 = (int*) array8->data; } - cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,(int const (*))arg6,(int const (*))arg7,(int const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17589,8 +17586,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(int)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -17642,13 +17639,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; int *arg6 ; int *arg7 ; - double *arg8 ; + long *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -17667,7 +17664,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -17686,7 +17683,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -17720,9 +17717,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { npy_intp size[1] = { @@ -17744,11 +17741,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONG, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (double*) array8->data; + arg8 = (long*) array8->data; } - cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17766,8 +17763,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -17819,13 +17816,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; int *arg6 ; int *arg7 ; - long double *arg8 ; + float *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -17844,7 +17841,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -17863,7 +17860,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -17897,9 +17894,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { npy_intp size[1] = { @@ -17921,11 +17918,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_LONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_FLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (long double*) array8->data; + arg8 = (float*) array8->data; } - cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(long double const (*))arg8,arg9,arg10,arg11); + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,(int const (*))arg6,(int const (*))arg7,(float const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -17943,8 +17940,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(float)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -17996,13 +17993,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; int *arg6 ; int *arg7 ; - npy_cfloat *arg8 ; + double *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -18021,7 +18018,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -18040,7 +18037,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -18074,9 +18071,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { npy_intp size[1] = { @@ -18098,11 +18095,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_DOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cfloat*) array8->data; + arg8 = (double*) array8->data; } - cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,(int const (*))arg6,(int const (*))arg7,(double const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18120,8 +18117,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(double)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -18173,13 +18170,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; int *arg6 ; int *arg7 ; - npy_cdouble *arg8 ; + npy_cfloat *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -18198,7 +18195,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -18217,7 +18214,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -18251,9 +18248,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { npy_intp size[1] = { @@ -18275,11 +18272,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CFLOAT, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_cdouble*) array8->data; + arg8 = (npy_cfloat*) array8->data; } - cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cfloat const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18297,8 +18294,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cfloat)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -18350,13 +18347,13 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; int *arg6 ; int *arg7 ; - npy_clongdouble *arg8 ; + npy_cdouble *arg8 ; std::vector *arg9 = (std::vector *) 0 ; std::vector *arg10 = (std::vector *) 0 ; - std::vector *arg11 = (std::vector *) 0 ; + std::vector *arg11 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -18375,7 +18372,7 @@ int is_new_object8 ; std::vector *tmp9 ; std::vector *tmp10 ; - std::vector *tmp11 ; + std::vector *tmp11 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -18394,7 +18391,7 @@ arg10 = tmp10; } { - tmp11 = new std::vector(); + tmp11 = new std::vector(); arg11 = tmp11; } if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:cscelmulcsc",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; @@ -18428,9 +18425,9 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } { npy_intp size[1] = { @@ -18452,11 +18449,11 @@ npy_intp size[1] = { -1 }; - array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CLONGDOUBLE, &is_new_object8); + array8 = obj_to_array_contiguous_allow_conversion(obj7, PyArray_CDOUBLE, &is_new_object8); if (!array8 || !require_dimensions(array8,1) || !require_size(array8,size,1)) SWIG_fail; - arg8 = (npy_clongdouble*) array8->data; + arg8 = (npy_cdouble*) array8->data; } - cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_clongdouble const (*))arg8,arg9,arg10,arg11); + cscelmulcsc(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,(int const (*))arg6,(int const (*))arg7,(npy_cdouble const (*))arg8,arg9,arg10,arg11); resultobj = SWIG_Py_Void(); { int length = (arg9)->size(); @@ -18474,8 +18471,8 @@ } { int length = (arg11)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg11))[0]),sizeof(npy_cdouble)*length); delete arg11; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -18552,7 +18549,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { @@ -18564,7 +18561,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_cscelmulcsc__SWIG_1(self, args); @@ -18598,7 +18595,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { @@ -18610,7 +18607,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_cscelmulcsc__SWIG_2(self, args); @@ -18644,7 +18641,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { @@ -18656,7 +18653,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscelmulcsc__SWIG_3(self, args); @@ -18690,7 +18687,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { @@ -18702,7 +18699,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscelmulcsc__SWIG_4(self, args); @@ -18736,7 +18733,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { @@ -18748,7 +18745,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_cscelmulcsc__SWIG_5(self, args); @@ -18782,7 +18779,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { @@ -18794,7 +18791,7 @@ } if (_v) { { - _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[7]) && PyArray_CanCastSafely(PyArray_TYPE(argv[7]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_cscelmulcsc__SWIG_6(self, args); @@ -18809,7 +18806,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscelmulcsc'.\n Possible C/C++ prototypes are:\n cscelmulcsc<(float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(long double)>(int const,int const,int const [],int const [],long double const [],int const [],int const [],long double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],int const [],int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'cscelmulcsc'.\n Possible C/C++ prototypes are:\n cscelmulcsc<(int,int)>(int const,int const,int const [],int const [],int const [],int const [],int const [],int const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(int,long)>(int const,int const,int const [],int const [],long const [],int const [],int const [],long const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(int,float)>(int const,int const,int const [],int const [],float const [],int const [],int const [],float const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(int,double)>(int const,int const,int const [],int const [],double const [],int const [],int const [],double const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],int const [],int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n cscelmulcsc<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],int const [],int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -18820,10 +18817,10 @@ int arg2 ; int arg3 ; int *arg4 ; - float *arg5 ; + int *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -18836,7 +18833,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -18852,7 +18849,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -18883,11 +18880,11 @@ npy_intp size[2] = { -1,-1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } - spdiags(arg1,arg2,arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); + spdiags(arg1,arg2,arg3,(int const (*))arg4,(int const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -18905,8 +18902,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(int)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -18934,10 +18931,10 @@ int arg2 ; int arg3 ; int *arg4 ; - double *arg5 ; + long *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -18950,7 +18947,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -18966,7 +18963,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -18997,11 +18994,11 @@ npy_intp size[2] = { -1,-1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } - spdiags(arg1,arg2,arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); + spdiags(arg1,arg2,arg3,(int const (*))arg4,(long const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19019,8 +19016,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -19048,10 +19045,10 @@ int arg2 ; int arg3 ; int *arg4 ; - long double *arg5 ; + float *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19064,7 +19061,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -19080,7 +19077,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -19111,11 +19108,11 @@ npy_intp size[2] = { -1,-1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } - spdiags(arg1,arg2,arg3,(int const (*))arg4,(long double const (*))arg5,arg6,arg7,arg8); + spdiags(arg1,arg2,arg3,(int const (*))arg4,(float const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19133,8 +19130,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(float)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -19162,10 +19159,10 @@ int arg2 ; int arg3 ; int *arg4 ; - npy_cfloat *arg5 ; + double *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19178,7 +19175,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -19194,7 +19191,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -19225,11 +19222,11 @@ npy_intp size[2] = { -1,-1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } - spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); + spdiags(arg1,arg2,arg3,(int const (*))arg4,(double const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19247,8 +19244,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(double)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -19276,10 +19273,10 @@ int arg2 ; int arg3 ; int *arg4 ; - npy_cdouble *arg5 ; + npy_cfloat *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19292,7 +19289,7 @@ int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -19308,7 +19305,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -19339,11 +19336,11 @@ npy_intp size[2] = { -1,-1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } - spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); + spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19361,8 +19358,8 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cfloat)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -19390,10 +19387,10 @@ int arg2 ; int arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; + npy_cdouble *arg5 ; std::vector *arg6 = (std::vector *) 0 ; std::vector *arg7 = (std::vector *) 0 ; - std::vector *arg8 = (std::vector *) 0 ; + std::vector *arg8 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19402,11 +19399,11 @@ int ecode3 = 0 ; PyArrayObject *array4 = NULL ; int is_new_object4 ; - void *argp5 = 0 ; - int res5 = 0 ; + PyArrayObject *array5 = NULL ; + int is_new_object5 ; std::vector *tmp6 ; std::vector *tmp7 ; - std::vector *tmp8 ; + std::vector *tmp8 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -19422,7 +19419,7 @@ arg7 = tmp7; } { - tmp8 = new std::vector(); + tmp8 = new std::vector(); arg8 = tmp8; } if (!PyArg_ParseTuple(args,(char *)"OOOOO:spdiags",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; @@ -19449,12 +19446,15 @@ if (!array4 || !require_dimensions(array4,1) || !require_size(array4,size,1)) SWIG_fail; arg4 = (int*) array4->data; } - res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "spdiags" "', argument " "5"" of type '" "npy_clongdouble const []""'"); - } - arg5 = reinterpret_cast< npy_clongdouble * >(argp5); - spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6,arg7,arg8); + { + npy_intp size[2] = { + -1,-1 + }; + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + if (!array5 || !require_dimensions(array5,2) || !require_size(array5,size,1)) SWIG_fail; + arg5 = (npy_cdouble*) array5->data; + } + spdiags(arg1,arg2,arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6,arg7,arg8); resultobj = SWIG_Py_Void(); { int length = (arg6)->size(); @@ -19472,19 +19472,25 @@ } { int length = (arg8)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg8))[0]),sizeof(npy_cdouble)*length); delete arg8; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } { if (is_new_object4 && array4) Py_DECREF(array4); } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } return resultobj; fail: { if (is_new_object4 && array4) Py_DECREF(array4); } + { + if (is_new_object5 && array5) Py_DECREF(array5); + } return NULL; } @@ -19521,7 +19527,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_spdiags__SWIG_1(self, args); @@ -19553,7 +19559,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_spdiags__SWIG_2(self, args); @@ -19585,7 +19591,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_spdiags__SWIG_3(self, args); @@ -19617,7 +19623,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_spdiags__SWIG_4(self, args); @@ -19649,7 +19655,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_spdiags__SWIG_5(self, args); @@ -19681,7 +19687,7 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_spdiags__SWIG_6(self, args); @@ -19693,7 +19699,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n spdiags<(float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(long double)>(int const,int const,int const,int const [],long double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cfloat)>(int const,int const,int const,int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_cdouble)>(int const,int const,int const,int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n spdiags<(npy_clongdouble)>(int const,int const,int const,int const [],npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'spdiags'.\n Possible C/C++ prototypes are:\n spdiags<(int,int)>(int const,int const,int const,int const [],int const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,long)>(int const,int const,int const,int const [],long const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,float)>(int const,int const,int const,int const [],float const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,double)>(int const,int const,int const,int const [],double const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,npy_cfloat)>(int const,int const,int const,int const [],npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n spdiags<(int,npy_cdouble)>(int const,int const,int const,int const [],npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -19704,8 +19710,8 @@ int arg2 ; int *arg3 ; int *arg4 ; - float *arg5 ; - float *arg6 ; + int *arg5 ; + int *arg6 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19755,16 +19761,16 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_INT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (float*) array5->data; + arg5 = (int*) array5->data; } { - temp6 = obj_to_array_no_conversion(obj5,PyArray_FLOAT); + temp6 = obj_to_array_no_conversion(obj5,PyArray_INT); if (!temp6 || !require_contiguous(temp6)) SWIG_fail; - arg6 = (float*) temp6->data; + arg6 = (int*) temp6->data; } - csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(int const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19796,8 +19802,8 @@ int arg2 ; int *arg3 ; int *arg4 ; - double *arg5 ; - double *arg6 ; + long *arg5 ; + long *arg6 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19847,16 +19853,16 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONG, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (double*) array5->data; + arg5 = (long*) array5->data; } { - temp6 = obj_to_array_no_conversion(obj5,PyArray_DOUBLE); + temp6 = obj_to_array_no_conversion(obj5,PyArray_LONG); if (!temp6 || !require_contiguous(temp6)) SWIG_fail; - arg6 = (double*) temp6->data; + arg6 = (long*) temp6->data; } - csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19888,8 +19894,8 @@ int arg2 ; int *arg3 ; int *arg4 ; - long double *arg5 ; - long double *arg6 ; + float *arg5 ; + float *arg6 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -19939,16 +19945,16 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_LONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_FLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (long double*) array5->data; + arg5 = (float*) array5->data; } { - temp6 = obj_to_array_no_conversion(obj5,PyArray_LONGDOUBLE); + temp6 = obj_to_array_no_conversion(obj5,PyArray_FLOAT); if (!temp6 || !require_contiguous(temp6)) SWIG_fail; - arg6 = (long double*) temp6->data; + arg6 = (float*) temp6->data; } - csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(long double const (*))arg5,arg6); + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(float const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -19980,8 +19986,8 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cfloat *arg5 ; - npy_cfloat *arg6 ; + double *arg5 ; + double *arg6 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20031,16 +20037,16 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_DOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cfloat*) array5->data; + arg5 = (double*) array5->data; } { - temp6 = obj_to_array_no_conversion(obj5,PyArray_CFLOAT); + temp6 = obj_to_array_no_conversion(obj5,PyArray_DOUBLE); if (!temp6 || !require_contiguous(temp6)) SWIG_fail; - arg6 = (npy_cfloat*) temp6->data; + arg6 = (double*) temp6->data; } - csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6); + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(double const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20072,8 +20078,8 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_cdouble *arg5 ; - npy_cdouble *arg6 ; + npy_cfloat *arg5 ; + npy_cfloat *arg6 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20123,16 +20129,16 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CFLOAT, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_cdouble*) array5->data; + arg5 = (npy_cfloat*) array5->data; } { - temp6 = obj_to_array_no_conversion(obj5,PyArray_CDOUBLE); + temp6 = obj_to_array_no_conversion(obj5,PyArray_CFLOAT); if (!temp6 || !require_contiguous(temp6)) SWIG_fail; - arg6 = (npy_cdouble*) temp6->data; + arg6 = (npy_cfloat*) temp6->data; } - csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6); + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cfloat const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20164,8 +20170,8 @@ int arg2 ; int *arg3 ; int *arg4 ; - npy_clongdouble *arg5 ; - npy_clongdouble *arg6 ; + npy_cdouble *arg5 ; + npy_cdouble *arg6 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20176,8 +20182,7 @@ int is_new_object4 ; PyArrayObject *array5 = NULL ; int is_new_object5 ; - void *argp6 = 0 ; - int res6 = 0 ; + PyArrayObject *temp6 = NULL ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20216,16 +20221,16 @@ npy_intp size[1] = { -1 }; - array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CLONGDOUBLE, &is_new_object5); + array5 = obj_to_array_contiguous_allow_conversion(obj4, PyArray_CDOUBLE, &is_new_object5); if (!array5 || !require_dimensions(array5,1) || !require_size(array5,size,1)) SWIG_fail; - arg5 = (npy_clongdouble*) array5->data; + arg5 = (npy_cdouble*) array5->data; } - res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); - if (!SWIG_IsOK(res6)) { - SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "csrtodense" "', argument " "6"" of type '" "npy_clongdouble []""'"); - } - arg6 = reinterpret_cast< npy_clongdouble * >(argp6); - csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_clongdouble const (*))arg5,arg6); + { + temp6 = obj_to_array_no_conversion(obj5,PyArray_CDOUBLE); + if (!temp6 || !require_contiguous(temp6)) SWIG_fail; + arg6 = (npy_cdouble*) temp6->data; + } + csrtodense(arg1,arg2,(int const (*))arg3,(int const (*))arg4,(npy_cdouble const (*))arg5,arg6); resultobj = SWIG_Py_Void(); { if (is_new_object3 && array3) Py_DECREF(array3); @@ -20282,11 +20287,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_INT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_csrtodense__SWIG_1(self, args); @@ -20318,11 +20323,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONG)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_csrtodense__SWIG_2(self, args); @@ -20354,11 +20359,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrtodense__SWIG_3(self, args); @@ -20390,11 +20395,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrtodense__SWIG_4(self, args); @@ -20426,11 +20431,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_csrtodense__SWIG_5(self, args); @@ -20462,11 +20467,11 @@ } if (_v) { { - _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[4]) && PyArray_CanCastSafely(PyArray_TYPE(argv[4]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { { - _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[5]) && PyArray_CanCastSafely(PyArray_TYPE(argv[5]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_csrtodense__SWIG_6(self, args); @@ -20479,7 +20484,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n csrtodense<(float)>(int const,int const,int const [],int const [],float const [],float [])\n csrtodense<(double)>(int const,int const,int const [],int const [],double const [],double [])\n csrtodense<(long double)>(int const,int const,int const [],int const [],long double const [],long double [])\n csrtodense<(npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat [])\n csrtodense<(npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble [])\n csrtodense<(npy_clongdouble)>(int const,int const,int const [],int const [],npy_clongdouble const [],npy_clongdouble [])\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csrtodense'.\n Possible C/C++ prototypes are:\n csrtodense<(int,int)>(int const,int const,int const [],int const [],int const [],int [])\n csrtodense<(int,long)>(int const,int const,int const [],int const [],long const [],long [])\n csrtodense<(int,float)>(int const,int const,int const [],int const [],float const [],float [])\n csrtodense<(int,double)>(int const,int const,int const [],int const [],double const [],double [])\n csrtodense<(int,npy_cfloat)>(int const,int const,int const [],int const [],npy_cfloat const [],npy_cfloat [])\n csrtodense<(int,npy_cdouble)>(int const,int const,int const [],int const [],npy_cdouble const [],npy_cdouble [])\n"); return NULL; } @@ -20488,10 +20493,10 @@ PyObject *resultobj = 0; int arg1 ; int arg2 ; - float *arg3 ; + int *arg3 ; std::vector *arg4 = (std::vector *) 0 ; std::vector *arg5 = (std::vector *) 0 ; - std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20500,7 +20505,7 @@ int is_new_object3 ; std::vector *tmp4 ; std::vector *tmp5 ; - std::vector *tmp6 ; + std::vector *tmp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20514,7 +20519,7 @@ arg5 = tmp5; } { - tmp6 = new std::vector(); + tmp6 = new std::vector(); arg6 = tmp6; } if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; @@ -20532,11 +20537,11 @@ npy_intp size[2] = { -1,-1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_FLOAT, &is_new_object3); + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_INT, &is_new_object3); if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (float*) array3->data; + arg3 = (int*) array3->data; } - densetocsr(arg1,arg2,(float const (*))arg3,arg4,arg5,arg6); + densetocsr(arg1,arg2,(int const (*))arg3,arg4,arg5,arg6); resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20554,8 +20559,8 @@ } { int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(float)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_INT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(int)*length); delete arg6; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -20575,10 +20580,10 @@ PyObject *resultobj = 0; int arg1 ; int arg2 ; - double *arg3 ; + long *arg3 ; std::vector *arg4 = (std::vector *) 0 ; std::vector *arg5 = (std::vector *) 0 ; - std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20587,7 +20592,7 @@ int is_new_object3 ; std::vector *tmp4 ; std::vector *tmp5 ; - std::vector *tmp6 ; + std::vector *tmp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20601,7 +20606,7 @@ arg5 = tmp5; } { - tmp6 = new std::vector(); + tmp6 = new std::vector(); arg6 = tmp6; } if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; @@ -20619,11 +20624,11 @@ npy_intp size[2] = { -1,-1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_DOUBLE, &is_new_object3); + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONG, &is_new_object3); if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (double*) array3->data; + arg3 = (long*) array3->data; } - densetocsr(arg1,arg2,(double const (*))arg3,arg4,arg5,arg6); + densetocsr(arg1,arg2,(long const (*))arg3,arg4,arg5,arg6); resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20641,8 +20646,8 @@ } { int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONG); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(long)*length); delete arg6; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -20662,10 +20667,10 @@ PyObject *resultobj = 0; int arg1 ; int arg2 ; - long double *arg3 ; + float *arg3 ; std::vector *arg4 = (std::vector *) 0 ; std::vector *arg5 = (std::vector *) 0 ; - std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20674,7 +20679,7 @@ int is_new_object3 ; std::vector *tmp4 ; std::vector *tmp5 ; - std::vector *tmp6 ; + std::vector *tmp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20688,7 +20693,7 @@ arg5 = tmp5; } { - tmp6 = new std::vector(); + tmp6 = new std::vector(); arg6 = tmp6; } if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; @@ -20706,11 +20711,11 @@ npy_intp size[2] = { -1,-1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_LONGDOUBLE, &is_new_object3); + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_FLOAT, &is_new_object3); if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (long double*) array3->data; + arg3 = (float*) array3->data; } - densetocsr(arg1,arg2,(long double const (*))arg3,arg4,arg5,arg6); + densetocsr(arg1,arg2,(float const (*))arg3,arg4,arg5,arg6); resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20728,8 +20733,8 @@ } { int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_LONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(long double)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_FLOAT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(float)*length); delete arg6; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -20749,10 +20754,10 @@ PyObject *resultobj = 0; int arg1 ; int arg2 ; - npy_cfloat *arg3 ; + double *arg3 ; std::vector *arg4 = (std::vector *) 0 ; std::vector *arg5 = (std::vector *) 0 ; - std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20761,7 +20766,7 @@ int is_new_object3 ; std::vector *tmp4 ; std::vector *tmp5 ; - std::vector *tmp6 ; + std::vector *tmp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20775,7 +20780,7 @@ arg5 = tmp5; } { - tmp6 = new std::vector(); + tmp6 = new std::vector(); arg6 = tmp6; } if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; @@ -20793,11 +20798,11 @@ npy_intp size[2] = { -1,-1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CFLOAT, &is_new_object3); + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_DOUBLE, &is_new_object3); if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (npy_cfloat*) array3->data; + arg3 = (double*) array3->data; } - densetocsr(arg1,arg2,(npy_cfloat const (*))arg3,arg4,arg5,arg6); + densetocsr(arg1,arg2,(double const (*))arg3,arg4,arg5,arg6); resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20815,8 +20820,8 @@ } { int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_cfloat)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_DOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(double)*length); delete arg6; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -20836,10 +20841,10 @@ PyObject *resultobj = 0; int arg1 ; int arg2 ; - npy_cdouble *arg3 ; + npy_cfloat *arg3 ; std::vector *arg4 = (std::vector *) 0 ; std::vector *arg5 = (std::vector *) 0 ; - std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; @@ -20848,7 +20853,7 @@ int is_new_object3 ; std::vector *tmp4 ; std::vector *tmp5 ; - std::vector *tmp6 ; + std::vector *tmp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20862,7 +20867,7 @@ arg5 = tmp5; } { - tmp6 = new std::vector(); + tmp6 = new std::vector(); arg6 = tmp6; } if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; @@ -20880,11 +20885,11 @@ npy_intp size[2] = { -1,-1 }; - array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CDOUBLE, &is_new_object3); + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CFLOAT, &is_new_object3); if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; - arg3 = (npy_cdouble*) array3->data; + arg3 = (npy_cfloat*) array3->data; } - densetocsr(arg1,arg2,(npy_cdouble const (*))arg3,arg4,arg5,arg6); + densetocsr(arg1,arg2,(npy_cfloat const (*))arg3,arg4,arg5,arg6); resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20902,8 +20907,8 @@ } { int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_cdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CFLOAT); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_cfloat)*length); delete arg6; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } @@ -20923,19 +20928,19 @@ PyObject *resultobj = 0; int arg1 ; int arg2 ; - npy_clongdouble *arg3 ; + npy_cdouble *arg3 ; std::vector *arg4 = (std::vector *) 0 ; std::vector *arg5 = (std::vector *) 0 ; - std::vector *arg6 = (std::vector *) 0 ; + std::vector *arg6 = (std::vector *) 0 ; int val1 ; int ecode1 = 0 ; int val2 ; int ecode2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; + PyArrayObject *array3 = NULL ; + int is_new_object3 ; std::vector *tmp4 ; std::vector *tmp5 ; - std::vector *tmp6 ; + std::vector *tmp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -20949,7 +20954,7 @@ arg5 = tmp5; } { - tmp6 = new std::vector(); + tmp6 = new std::vector(); arg6 = tmp6; } if (!PyArg_ParseTuple(args,(char *)"OOO:densetocsr",&obj0,&obj1,&obj2)) SWIG_fail; @@ -20963,12 +20968,15 @@ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "densetocsr" "', argument " "2"" of type '" "int""'"); } arg2 = static_cast< int >(val2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_npy_clongdouble, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "densetocsr" "', argument " "3"" of type '" "npy_clongdouble const []""'"); - } - arg3 = reinterpret_cast< npy_clongdouble * >(argp3); - densetocsr(arg1,arg2,(npy_clongdouble const (*))arg3,arg4,arg5,arg6); + { + npy_intp size[2] = { + -1,-1 + }; + array3 = obj_to_array_contiguous_allow_conversion(obj2, PyArray_CDOUBLE, &is_new_object3); + if (!array3 || !require_dimensions(array3,2) || !require_size(array3,size,1)) SWIG_fail; + arg3 = (npy_cdouble*) array3->data; + } + densetocsr(arg1,arg2,(npy_cdouble const (*))arg3,arg4,arg5,arg6); resultobj = SWIG_Py_Void(); { int length = (arg4)->size(); @@ -20986,13 +20994,19 @@ } { int length = (arg6)->size(); - PyObject *obj = PyArray_FromDims(1, &length, PyArray_CLONGDOUBLE); - memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_clongdouble)*length); + PyObject *obj = PyArray_FromDims(1, &length, PyArray_CDOUBLE); + memcpy(PyArray_DATA(obj),&((*(arg6))[0]),sizeof(npy_cdouble)*length); delete arg6; resultobj = helper_appendToTuple( resultobj, (PyObject *)obj ); } + { + if (is_new_object3 && array3) Py_DECREF(array3); + } return resultobj; fail: + { + if (is_new_object3 && array3) Py_DECREF(array3); + } return NULL; } @@ -21020,7 +21034,7 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_FLOAT)) ? 1 : 0; + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_INT)) ? 1 : 0; } if (_v) { return _wrap_densetocsr__SWIG_1(self, args); @@ -21041,7 +21055,7 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_DOUBLE)) ? 1 : 0; + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONG)) ? 1 : 0; } if (_v) { return _wrap_densetocsr__SWIG_2(self, args); @@ -21062,7 +21076,7 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_LONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_FLOAT)) ? 1 : 0; } if (_v) { return _wrap_densetocsr__SWIG_3(self, args); @@ -21083,7 +21097,7 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CFLOAT)) ? 1 : 0; + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_DOUBLE)) ? 1 : 0; } if (_v) { return _wrap_densetocsr__SWIG_4(self, args); @@ -21104,7 +21118,7 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CDOUBLE)) ? 1 : 0; + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CFLOAT)) ? 1 : 0; } if (_v) { return _wrap_densetocsr__SWIG_5(self, args); @@ -21125,7 +21139,7 @@ } if (_v) { { - _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CLONGDOUBLE)) ? 1 : 0; + _v = (is_array(argv[2]) && PyArray_CanCastSafely(PyArray_TYPE(argv[2]),PyArray_CDOUBLE)) ? 1 : 0; } if (_v) { return _wrap_densetocsr__SWIG_6(self, args); @@ -21135,7 +21149,7 @@ } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n densetocsr<(float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(long double)>(int const,int const,long double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cfloat)>(int const,int const,npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_cdouble)>(int const,int const,npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(npy_clongdouble)>(int const,int const,npy_clongdouble const [],std::vector *,std::vector *,std::vector *)\n"); + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'densetocsr'.\n Possible C/C++ prototypes are:\n densetocsr<(int,int)>(int const,int const,int const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,long)>(int const,int const,long const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,float)>(int const,int const,float const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,double)>(int const,int const,double const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,npy_cfloat)>(int const,int const,npy_cfloat const [],std::vector *,std::vector *,std::vector *)\n densetocsr<(int,npy_cdouble)>(int const,int const,npy_cdouble const [],std::vector *,std::vector *,std::vector *)\n"); return NULL; } @@ -21144,8 +21158,8 @@ { (char *)"csrtocsc", _wrap_csrtocsc, METH_VARARGS, NULL}, { (char *)"csctocsr", _wrap_csctocsr, METH_VARARGS, NULL}, { (char *)"csrtocoo", _wrap_csrtocoo, METH_VARARGS, NULL}, + { (char *)"csctocoo", _wrap_csctocoo, METH_VARARGS, NULL}, { (char *)"cootocsr", _wrap_cootocsr, METH_VARARGS, NULL}, - { (char *)"csctocoo", _wrap_csctocoo, METH_VARARGS, NULL}, { (char *)"cootocsc", _wrap_cootocsc, METH_VARARGS, NULL}, { (char *)"csrplcsr", _wrap_csrplcsr, METH_VARARGS, NULL}, { (char *)"cscplcsc", _wrap_cscplcsc, METH_VARARGS, NULL}, @@ -21165,47 +21179,39 @@ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_npy_clongdouble = {"_p_npy_clongdouble", "npy_clongdouble *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorTdouble_t = {"_p_std__vectorTdouble_t", "std::vector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorTfloat_t = {"_p_std__vectorTfloat_t", "std::vector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorTint_t = {"_p_std__vectorTint_t", "std::vector *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_std__vectorTlong_double_t = {"_p_std__vectorTlong_double_t", "std::vector *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorTlong_t = {"_p_std__vectorTlong_t", "std::vector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorTnpy_cdouble_t = {"_p_std__vectorTnpy_cdouble_t", "std::vector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorTnpy_cfloat_t = {"_p_std__vectorTnpy_cfloat_t", "std::vector *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_std__vectorTnpy_clongdouble_t = {"_p_std__vectorTnpy_clongdouble_t", "std::vector *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_char, - &_swigt__p_npy_clongdouble, &_swigt__p_std__vectorTdouble_t, &_swigt__p_std__vectorTfloat_t, &_swigt__p_std__vectorTint_t, - &_swigt__p_std__vectorTlong_double_t, + &_swigt__p_std__vectorTlong_t, &_swigt__p_std__vectorTnpy_cdouble_t, &_swigt__p_std__vectorTnpy_cfloat_t, - &_swigt__p_std__vectorTnpy_clongdouble_t, }; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_npy_clongdouble[] = { {&_swigt__p_npy_clongdouble, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorTdouble_t[] = { {&_swigt__p_std__vectorTdouble_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorTfloat_t[] = { {&_swigt__p_std__vectorTfloat_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorTint_t[] = { {&_swigt__p_std__vectorTint_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_std__vectorTlong_double_t[] = { {&_swigt__p_std__vectorTlong_double_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorTlong_t[] = { {&_swigt__p_std__vectorTlong_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorTnpy_cdouble_t[] = { {&_swigt__p_std__vectorTnpy_cdouble_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorTnpy_cfloat_t[] = { {&_swigt__p_std__vectorTnpy_cfloat_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_std__vectorTnpy_clongdouble_t[] = { {&_swigt__p_std__vectorTnpy_clongdouble_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_char, - _swigc__p_npy_clongdouble, _swigc__p_std__vectorTdouble_t, _swigc__p_std__vectorTfloat_t, _swigc__p_std__vectorTint_t, - _swigc__p_std__vectorTlong_double_t, + _swigc__p_std__vectorTlong_t, _swigc__p_std__vectorTnpy_cdouble_t, _swigc__p_std__vectorTnpy_cfloat_t, - _swigc__p_std__vectorTnpy_clongdouble_t, }; From scipy-svn at scipy.org Tue Jan 9 06:58:39 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 05:58:39 -0600 (CST) Subject: [Scipy-svn] r2511 - trunk/Lib/sparse Message-ID: <20070109115839.83A8039C0AB@new.scipy.org> Author: timl Date: 2007-01-09 05:58:34 -0600 (Tue, 09 Jan 2007) New Revision: 2511 Modified: trunk/Lib/sparse/sparse.py Log: code cleanups Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-09 11:36:44 UTC (rev 2510) +++ trunk/Lib/sparse/sparse.py 2007-01-09 11:58:34 UTC (rev 2511) @@ -6,10 +6,13 @@ """ from numpy import zeros, isscalar, real, imag, asarray, asmatrix, matrix, \ - ndarray, ceil, amax, rank, conj, searchsorted, ndarray, \ + ndarray, amax, rank, conj, searchsorted, ndarray, \ less, where, greater, array, transpose, empty, ones, \ arange, shape, intc import numpy +from scipy.sparse.sparsetools import densetocsr, csrtocsc, csrtodense, cscplcsc, \ + cscelmulcsc, cscmux, csrmux, csrmucsr, csrtocoo, cootocsc, cootocsr, \ + cscmucsc, csctocoo, csctocsr, csrplcsr, csrelmulcsr import sparsetools import itertools, operator, copy from bisect import bisect_left @@ -493,7 +496,9 @@ s = s*1.0 if (rank(s) == 2): self.shape = s.shape - self.indptr,self.rowind,self.data = sparsetools.densetocsr(s.shape[1],s.shape[0],s.T) + self.indptr, self.rowind, self.data = densetocsr(s.shape[1], \ + s.shape[0], \ + s.T) else: raise ValueError, "dense array must have rank 1 or 2" elif isspmatrix(arg1): @@ -512,7 +517,11 @@ self.indptr = s.indptr elif isinstance(s, csr_matrix): self.shape = s.shape - self.indptr,self.rowind,self.data = sparsetools.csrtocsc(s.shape[0],s.shape[1],s.indptr,s.colind,s.data) + self.indptr, self.rowind, self.data = csrtocsc(s.shape[0], + s.shape[1], + s.indptr, + s.colind, + s.data) else: temp = s.tocsc() self.data = temp.data @@ -645,10 +654,11 @@ ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" - indptr,rowind,data = sparsetools.cscplcsc(self.shape[0],self.shape[1], \ - self.indptr,self.rowind,self.data,\ - ocs.indptr,ocs.rowind,ocs.data) - return csc_matrix((data,rowind,indptr), self.shape) + indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, \ + self.data, ocs.indptr, \ + ocs.rowind, ocs.data) + return csc_matrix((data, rowind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. return self.todense() + other @@ -663,10 +673,11 @@ ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" - indptr,rowind,data = sparsetools.cscplcsc(self.shape[0],self.shape[1], \ - self.indptr,self.rowind,self.data,\ - ocs.indptr,ocs.rowind,ocs.data) - return csc_matrix((data,rowind,indptr),self.shape) + indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, \ + self.data, ocs.indptr, ocs.rowind, \ + ocs.data) + return csc_matrix((data, rowind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them return other + self.todense() @@ -719,10 +730,11 @@ ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" - indptr,rowind,data = sparsetools.cscelmulcsc(self.shape[0],self.shape[1],\ - self.indptr,self.rowind,self.data,\ - ocs.indptr,ocs.rowind,ocs.data) - return csc_matrix((data,rowind,indptr),(self.shape[0],ocs.shape[1])) + indptr, rowind, data = cscelmulcsc(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, \ + self.data, ocs.indptr, \ + ocs.rowind, ocs.data) + return csc_matrix((data, rowind, indptr), (self.shape[0], ocs.shape[1])) def transpose(self, copy=False): M, N = self.shape @@ -785,8 +797,8 @@ #if len(other) != self.shape[1]: # raise ValueError, "dimension mismatch" oth = numpy.ravel(other) - y = sparsetools.cscmux(self.shape[0], self.shape[1],\ - self.indptr, self.rowind, self.data, oth) + y = cscmux(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, self.data, oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -810,7 +822,7 @@ cd = conj(self.data) else: cd = self.data - y = sparsetools.csrmux(self.shape[1],self.shape[0],self.indptr,self.rowind,cd,oth) + y = csrmux(self.shape[1], self.shape[0], self.indptr, self.rowind, cd, oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an @@ -830,8 +842,9 @@ if (K1 != K2): raise ValueError, "shape mismatch error" other = other.tocsc() - indptr,rowind,data = sparsetools.cscmucsc(M,N,self.indptr,self.rowind,self.data,\ - other.indptr,other.rowind,other.data) + indptr, rowind, data = cscmucsc(M, N, self.indptr, self.rowind, \ + self.data, other.indptr, \ + other.rowind, other.data) return csc_matrix((data, rowind, indptr), (M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation @@ -936,7 +949,7 @@ rowind = self.rowind[indices] - start data = self.data[indices] - indptr = numpy.array([0,len(indices)]) + indptr = numpy.array([0, len(indices)]) return csc_matrix((data, rowind, indptr), dims=(stop-start, 1), \ dtype=self.dtype) @@ -956,13 +969,14 @@ return new def tocoo(self): - rows,cols,data = sparsetools.csctocoo(self.shape[0],self.shape[1],\ - self.indptr,self.rowind,self.data) - return coo_matrix((data,(rows,cols)), self.shape) + rows, cols, data = csctocoo(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, self.data) + return coo_matrix((data, (rows, cols)), self.shape) def tocsr(self): - indptr,colind,data = sparsetools.csctocsr(self.shape[0],self.shape[1],self.indptr,self.rowind,self.data) - return csr_matrix((data,colind,indptr), self.shape) + indptr, colind, data = csctocsr(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, self.data) + return csr_matrix((data, colind, indptr), self.shape) def toarray(self): return self.tocsr().toarray() @@ -1186,9 +1200,11 @@ other = other.tocsr() if (other.shape != self.shape): raise ValueError, "inconsistent shapes" - indptr,colind,data = sparsetools.csrplcsr(self.shape[0],other.shape[1],\ - self.indptr,self.colind,self.data,other.indptr,other.colind,other.data) - return csr_matrix((data,colind,indptr),self.shape) + indptr, colind, data = csrplcsr(self.shape[0], other.shape[1], \ + self.indptr, self.colind, + self.data, other.indptr, \ + other.colind, other.data) + return csr_matrix((data, colind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. return self.todense() + other @@ -1241,10 +1257,11 @@ other = other.tocsr() if (other.shape != self.shape): raise ValueError, "inconsistent shapes" - indptr,colind,data = sparsetools.csrelmulcsr(self.shape[0],other.shape[1],\ - self.indptr,self.colind,self.data,\ - other.indptr,other.colind,other.data) - return csr_matrix((data,colind,indptr),(self.shape[0],other.shape[1])) + indptr, colind, data = csrelmulcsr(self.shape[0], other.shape[1], \ + self.indptr, self.colind, \ + self.data, other.indptr, \ + other.colind, other.data) + return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) else: raise TypeError, "unsupported type for sparse matrix power" @@ -1274,7 +1291,7 @@ indptr = self.indptr for i in xrange(m): out[i] = data[indptr[i] : indptr[i+1]].sum() - if axis==1: + if axis == 1: # Output is a (m x 1) dense matrix return asmatrix(out).T else: @@ -1295,7 +1312,7 @@ #if len(other) != self.shape[1]: # raise ValueError, "dimension mismatch" oth = numpy.ravel(other) - y = sparsetools.csrmux(self.shape[0],self.shape[1],self.indptr,self.colind,self.data,oth) + y = csrmux(self.shape[0], self.shape[1], self.indptr, self.colind, self.data, oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -1316,7 +1333,7 @@ cd = self.data oth = numpy.ravel(other) - y = sparsetools.cscmux(self.shape[0],self.shape[1],self.indptr,self.rowind,cd,oth) + y = cscmux(self.shape[0], self.shape[1], self.indptr, self.rowind, cd, oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' was an @@ -1329,14 +1346,14 @@ if isspmatrix(other): M, K1 = self.shape K2, N = other.shape - a, rowa, ptra = self.data, self.colind, self.indptr if (K1 != K2): raise ValueError, "shape mismatch error" other = other.tocsr() - indptr,colind,data = sparsetools.csrmucsr(self.shape[0],other.shape[1],\ - self.indptr,self.colind,self.data,\ - other.indptr,other.colind,other.data) - return csr_matrix((data,colind,indptr),(self.shape[0],other.shape[1])) + indptr, colind, data = csrmucsr(M, N, \ + self.indptr, self.colind, \ + self.data, other.indptr, \ + other.colind, other.data) + return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! @@ -1390,8 +1407,8 @@ colind = self.colind[indices] - start data = self.data[indices] - indptr = numpy.array([0,len(indices)]) - return csr_matrix((data, colind, indptr), dims=(1,stop-start), \ + indptr = numpy.array([0, len(indices)]) + return csr_matrix((data, colind, indptr), dims=(1, stop-start), \ dtype=self.dtype) def __setitem__(self, key, val): @@ -1456,18 +1473,20 @@ return self def tocoo(self): - rows,cols,data = sparsetools.csrtocoo(self.shape[0],self.shape[1],\ - self.indptr,self.colind,self.data) - return coo_matrix((data,(rows,cols)),self.shape) + rows, cols, data = csrtocoo(self.shape[0], self.shape[1], \ + self.indptr, self.colind, self.data) + return coo_matrix((data, (rows, cols)), self.shape) def tocsc(self): - indptr,rowind,data = sparsetools.csrtocsc(self.shape[0],self.shape[1],self.indptr,self.colind,self.data) - return csc_matrix((data,rowind,indptr),self.shape) + indptr, rowind, data = csrtocsc(self.shape[0], self.shape[1], \ + self.indptr, self.colind, self.data) + return csc_matrix((data, rowind, indptr), self.shape) def toarray(self): - data = numpy.zeros(self.shape,self.data.dtype) - sparsetools.csrtodense(self.shape[0],self.shape[1],self.indptr,self.colind,self.data,data) + data = numpy.zeros(self.shape, self.data.dtype) + csrtodense(self.shape[0], self.shape[1], self.indptr, self.colind, + self.data, data) return data def prune(self): @@ -1484,7 +1503,7 @@ self.nzmax = nnz self._check() - def ensure_sorted_indices(self,inplace=False): + def ensure_sorted_indices(self, inplace=False): """Return a copy of this matrix where the column indices are sorted """ if inplace: @@ -1667,9 +1686,9 @@ # [self.get((element, j), 0) for element in seq] # ** Instead just add the non-zero elements. This uses # ** linear time in the number of non-zeros: - for (ii,jj) in self: + for (ii, jj) in self: if jj == j and ii >= first and ii <= last: - dict.__setitem__(new, (ii-first,0), \ + dict.__setitem__(new, (ii-first, 0), \ dict.__getitem__(self, (ii,jj))) else: ################################### @@ -1702,9 +1721,9 @@ # [self.get((i, element), 0) for element in seq] # ** Instead loop over the non-zero elements. This is slower # ** if there are many non-zeros - for (ii,jj) in self: + for (ii, jj) in self: if ii == i and jj >= first and jj <= last: - dict.__setitem__(new, (0,jj-first), \ + dict.__setitem__(new, (0, jj-first), \ dict.__getitem__(self, (ii,jj))) return new @@ -1958,11 +1977,10 @@ base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) - N = len(cols_or_rows) if indx: for key in self: num = searchsorted(cols_or_rows, key[1]) - if cols_or_rows[num]==key[1]: + if cols_or_rows[num] == key[1]: newkey = (key[0], num) ext[newkey] = self[key] else: @@ -1971,7 +1989,7 @@ else: for key in self: num = searchsorted(cols_or_rows, key[0]) - if cols_or_rows[num]==key[0]: + if cols_or_rows[num] == key[0]: newkey = (num, key[1]) ext[newkey] = self[key] else: @@ -2034,7 +2052,6 @@ ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey0 != current_row: - N = ikey0-current_row row_ptr[current_row+1:ikey0+1] = k current_row = ikey0 data[k] = dict.__getitem__(self, key) @@ -2067,7 +2084,6 @@ ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey1 != current_col: - N = ikey1-current_col col_ptr[current_col+1:ikey1+1] = k current_col = ikey1 data[k] = self[key] @@ -2099,9 +2115,9 @@ " integers" if newM < M or newN < N: # Remove all elements outside new dimensions - for (i,j) in self.keys(): + for (i, j) in self.keys(): if i >= newM or j >= newN: - del self[i,j] + del self[i, j] self.shape = (newM, newN) @@ -2163,8 +2179,8 @@ # Use 2 steps to ensure dims has length 2. M, N = dims self.shape = (M, N) - self.row = asarray(ij[0],dtype=numpy.intc) - self.col = asarray(ij[1],dtype=numpy.intc) + self.row = asarray(ij[0], dtype=numpy.intc) + self.col = asarray(ij[1], dtype=numpy.intc) self.data = asarray(obj, dtype=self.dtype) self._check() @@ -2191,17 +2207,17 @@ #sort by increasing rows first, columns second if getattr(self, '_is_normalized', None): #columns already sorted, use stable sort for rows - P = numpy.argsort(self.row,kind='mergesort') + P = numpy.argsort(self.row, kind='mergesort') return self.data[P], self.row[P], self.col[P] else: #nothing already sorted - P = numpy.lexsort(keys=(self.col,self.row)) + P = numpy.lexsort(keys=(self.col, self.row)) return self.data[P], self.row[P], self.col[P] if getattr(self, '_is_normalized', None): return self.data, self.row, self.col #sort by increasing rows first, columns second - P = numpy.lexsort(keys=(self.row,self.col)) - self.data,self.row,self.col = self.data[P], self.row[P], self.col[P] + P = numpy.lexsort(keys=(self.row, self.col)) + self.data, self.row, self.col = self.data[P], self.row[P], self.col[P] setattr(self, '_is_normalized', 1) return self.data, self.row, self.col @@ -2215,16 +2231,20 @@ if self.nnz == 0: return csc_matrix(self.shape, dtype=self.dtype) else: - indptr,rowind,data = sparsetools.cootocsc(self.shape[0],self.shape[1],self.size,self.row,self.col,self.data) - return csc_matrix((data,rowind,indptr),self.shape) + indptr, rowind, data = cootocsc(self.shape[0], self.shape[1], \ + self.size, self.row, self.col, \ + self.data) + return csc_matrix((data, rowind, indptr), self.shape) def tocsr(self): if self.nnz == 0: return csr_matrix(self.shape, dtype=self.dtype) else: - indptr,colind,data = sparsetools.cootocsr(self.shape[0],self.shape[1],self.size,self.row,self.col,self.data) - return csr_matrix((data,colind,indptr),self.shape) + indptr, colind, data = cootocsr(self.shape[0], self.shape[1], \ + self.size, self.row, self.col, \ + self.data) + return csr_matrix((data, colind, indptr), self.shape) def tocoo(self, copy=False): if copy: @@ -2533,7 +2553,7 @@ # Multiply by zero: return the zero matrix return new # Multiply this scalar by every element. - new.data = [[val * other for val in rowvals] for rowvals in new.data] + new.data = [[val*other for val in rowvals] for rowvals in new.data] return new else: return self.dot(other) @@ -2720,8 +2740,8 @@ offsets = (offsets,) offsets = array(offsets, copy=False, dtype=numpy.intc) assert(len(offsets) == diags.shape[0]) - indptr,rowind,data = sparsetools.spdiags(M,N,len(offsets),offsets,diags) - return csc_matrix((data,rowind,indptr),(M,N)) + indptr, rowind, data = sparsetools.spdiags(M, N, len(offsets), offsets, diags) + return csc_matrix((data, rowind, indptr), (M, N)) def spidentity(n, dtype='d'): """ From scipy-svn at scipy.org Tue Jan 9 22:19:37 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 21:19:37 -0600 (CST) Subject: [Scipy-svn] r2514 - trunk/Lib/sparse Message-ID: <20070110031937.E14C039C1ED@new.scipy.org> Author: timl Date: 2007-01-09 21:19:32 -0600 (Tue, 09 Jan 2007) New Revision: 2514 Modified: trunk/Lib/sparse/sparse.py Log: introduce a new base class to handle the commonalities between csc and csr matrices and reduce duplicated code. Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-09 16:52:09 UTC (rev 2513) +++ trunk/Lib/sparse/sparse.py 2007-01-10 03:19:32 UTC (rev 2514) @@ -374,6 +374,13 @@ csc = self.tocsc() return csc.tocoo() + def toself(self, copy=False): + if copy: + new = self.copy() + else: + new = self + return new + def copy(self): csc = self.tocsc() return csc.copy() @@ -459,7 +466,177 @@ fd.write(format % (ir, ic, data)) fd.close() -class csc_matrix(spmatrix): +class _sc_matrix(spmatrix): + + def astype(self, t): + out = self.copy() + out.data = out.data.astype(t) + out.dtype = out.data.dtype + out.ftype = _transtabl[out.dtype.char] + return out + + def __repr__(self): + format = self.getformat() + return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ + "elements (space for %d)\n\tin %s format>" % \ + (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ + _formats[format][1])) + + + + def __add__(self, other, self_ind, other_ind, fn, cls): + # First check if argument is a scalar + if isscalarlike(other): + # Now we would add this scalar to every element. + raise NotImplementedError, 'adding a scalar to a CSC or CSR ' \ + 'matrix is not yet supported' + elif isspmatrix(other): + other = other.tocsc() + if (other.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, ind, data = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) + return cls((data, ind, indptr), self.shape) + elif isdense(other): + # Convert this matrix to a dense matrix and add them + return other + self.todense() + else: + raise TypeError, "unsupported type for sparse matrix addition" + + + def __mul__(self, other): + """ Scalar, vector, or matrix multiplication + """ + if isscalarlike(other): + new = self.copy() + new.data = other * new.data # allows type conversion + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + return self.dot(other) + + + def __rmul__(self, other): # other * self + if isscalarlike(other): + new = self.copy() + new.data = other * new.data # allows type conversion + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + # Don't use asarray unless we have to + try: + tr = other.transpose() + except AttributeError: + tr = asarray(other).transpose() + return self.transpose().dot(tr).transpose() + + + def __neg__(self): + new = self.copy() + new.data *= -1 + return new + + def __pow__(self, other, self_ind, other_ind, fn, cls): + """ Element-by-element power (unless other is a scalar, in which + case return the matrix power.) + """ + if isscalarlike(other): + new = self.copy() + new.data = new.data ** other + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + elif isspmatrix(other): + other = other.tocsr() + if (other.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, ind, data = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) + return cls((data, ind, indptr), (self.shape[0], other.shape[1])) + else: + raise TypeError, "unsupported type for sparse matrix power" + + + def matmat(self, other, self_ind, other_ind, cls): + if isspmatrix(other): + M, K1 = self.shape + K2, N = other.shape + if (K1 != K2): + raise ValueError, "shape mismatch error" + other = other.tocsc() + indptr, ind, data = cscmucsc(M, N, self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) + return cls((data, ind, indptr), (M, N)) + elif isdense(other): + # This is SLOW! We need a more efficient implementation + # of sparse * dense matrix multiplication! + return self.matmat(csc_matrix(other)) + else: + raise TypeError, "need a dense or sparse matrix" + + def matvec(self, other, self_ind, fn): + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like dense matrix objects can. + #if len(other) != self.shape[1]: + # raise ValueError, "dimension mismatch" + oth = numpy.ravel(other) + y = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, self.data, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # If 'other' was an (nx1) column vector, transpose the result + # to obtain an (mx1) column vector. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + elif isspmatrix(other): + raise TypeError, "use matmat() for sparse * sparse" + else: + raise TypeError, "need a dense vector" + + def rmatvec(self, other, shape0, shape1, fn, conjugate=True): + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like dense matrix objects can. + # if len(other) != self.shape[0]: + # raise ValueError, "dimension mismatch" + if conjugate: + cd = conj(self.data) + else: + cd = self.data + oth = numpy.ravel(other) + y = fn(shape0, shape1, self.indptr, self.rowind, cd, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # In the (unlikely) event that this matrix is 1x1 and 'other' was an + # (mx1) column vector, transpose the result. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + elif isspmatrix(other): + raise TypeError, "use matmat() for sparse * sparse" + else: + raise TypeError, "need a dense vector" + + def getdata(self, ind): + return self.data[ind] + + def tocoo(self, fn, self_ind): + rows, cols, data = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, self.data) + return coo_matrix((data, (rows, cols)), self.shape) + + + +class csc_matrix(_cs_matrix): """ Compressed sparse column matrix This can be instantiated in several ways: - csc_matrix(d) @@ -481,7 +658,7 @@ standard CSC representation """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): - spmatrix.__init__(self) + _cs_matrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSC format @@ -591,7 +768,6 @@ M = max(oldM, M) N = max(0, oldN, N, len(self.indptr) - 1) self.shape = (M, N) - self._check() def _check(self): @@ -601,7 +777,6 @@ M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind) - if (rank(self.data) != 1) or (rank(self.rowind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, rowind, and indptr arrays "\ @@ -630,19 +805,6 @@ self.ftype = _transtabl[self.dtype.char] - def astype(self, t): - out = self.copy() - out.data = out.data.astype(t) - out.dtype = out.data.dtype - out.ftype = _transtabl[out.dtype.char] - return out - - def __repr__(self): - format = self.getformat() - return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ - "elements (space for %d)\n\tin %s format>" % \ - (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ - _formats[format][1])) def __radd__(self, other): """ Function supporting the operation: self + other. @@ -666,75 +828,10 @@ raise TypeError, "unsupported type for sparse matrix addition" def __add__(self, other): - if isscalarlike(other): - raise NotImplementedError, 'adding a scalar to a CSC matrix is ' \ - 'not yet supported' - elif isspmatrix(other): - ocs = other.tocsc() - if (ocs.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, \ - self.data, ocs.indptr, ocs.rowind, \ - ocs.data) - return csc_matrix((data, rowind, indptr), self.shape) - elif isdense(other): - # Convert this matrix to a dense matrix and add them - return other + self.todense() - else: - raise TypeError, "unsupported type for sparse matrix addition" + _cs_matrix.__add__(self, other, self.rowind, other.rowind, cscplcsc, csc_matrix) - def __mul__(self, other): - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - new = self.copy() - new.data *= other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - return self.dot(other) - - def __rmul__(self, other): # other * self - if isscalarlike(other): - new = self.copy() - new.data = other * new.data - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - # Don't use asarray unless we have to - try: - tr = other.transpose() - except AttributeError: - tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() - - def __neg__(self): - new = self.copy() - new.data *= -1 - return new - def __pow__(self, other): - """ Element-by-element power (unless other is a scalar, in which - case return the matrix power.) - """ - if isscalarlike(other): - new = self.copy() - new.data = new.data ** other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - ocs = other.tocsc() - if (ocs.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, rowind, data = cscelmulcsc(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, \ - self.data, ocs.indptr, \ - ocs.rowind, ocs.data) - return csc_matrix((data, rowind, indptr), (self.shape[0], ocs.shape[1])) + _cs_matrix.__pow__(self, other, self.rowind, other.rowind, cscelmulcsc, csc_matrix) def transpose(self, copy=False): M, N = self.shape @@ -769,10 +866,10 @@ m, n = self.shape data = self.data if axis in (0, None): - indptr = self.indptr out = empty(n, dtype=self.dtype) # The first element in column j has index indptr[j], the last # indptr[j+1] + indptr = self.indptr for j in xrange(n): out[j] = data[indptr[j] : indptr[j+1]].sum() if axis == 0: @@ -788,70 +885,15 @@ out[rowind[k]] += data[k] # Output is a (m x 1) dense matrix return asmatrix(out).T - - + def matvec(self, other): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like with dense matrix objects. - #if len(other) != self.shape[1]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - y = cscmux(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # If 'other' was an (nx1) column vector, transpose the result - # to obtain an (mx1) column vector. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" + _cs_matrix.matvec(self, other, self.rowind, cscmux) def rmatvec(self, other, conjugate=True): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like with dense matrix objects. - #if len(other) != self.shape[0]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - if conjugate: - cd = conj(self.data) - else: - cd = self.data - y = csrmux(self.shape[1], self.shape[0], self.indptr, self.rowind, cd, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # In the (unlikely) event that this matrix is 1x1 and 'other' was an - # (mx1) column vector, transpose the result. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" + _cs_matrix.rmatvec(self, other, shape[1], shape[0], cscmux, conjugate=conjugate) def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - other = other.tocsc() - indptr, rowind, data = cscmucsc(M, N, self.indptr, self.rowind, \ - self.data, other.indptr, \ - other.rowind, other.data) - return csc_matrix((data, rowind, indptr), (M, N)) - elif isdense(other): - # This is SLOW! We need a more efficient implementation - # of sparse * dense matrix multiplication! - return self.matmat(csc_matrix(other)) - else: - raise TypeError, "need a dense or sparse matrix" + _cs_matrix.matmat(self, other, self.rowind, other.rowind, csc_matrix) def __getitem__(self, key): @@ -958,24 +1000,15 @@ col = searchsorted(self.indptr, ind+1)-1 return (row, col) - def getdata(self, ind): - return self.data[ind] - def tocsc(self, copy=False): - if copy: - new = self.copy() - else: - new = self - return new + return self.toself(copy) def tocoo(self): - rows, cols, data = csctocoo(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data) - return coo_matrix((data, (rows, cols)), self.shape) + _cs_matrix.tocoo(self, csctocoo, self.rowind) def tocsr(self): indptr, colind, data = csctocsr(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data) + self.indptr, self.rowind, self.data) return csr_matrix((data, colind, indptr), self.shape) def toarray(self): @@ -1019,7 +1052,7 @@ return new -class csr_matrix(spmatrix): +class csr_matrix(_cs_matrix): """ Compressed sparse row matrix This can be instantiated in several ways: - csr_matrix(d) @@ -1041,7 +1074,7 @@ standard CSR representation """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): - spmatrix.__init__(self) + _cs_matrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format @@ -1179,94 +1212,13 @@ self.ftype = _transtabl[self.dtype.char] - def astype(self, t): - out = self.copy() - out.data = out.data.astype(t) - out.dtype = out.data.dtype - out.ftype = _transtabl[out.dtype.char] - return out - - def __repr__(self): - format = self.getformat() - return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ - "elements (space for %d)\n\tin %s format>" % \ - (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ - _formats[format][1])) def __add__(self, other): - # First check if argument is a scalar - if isscalarlike(other): - # Now we would add this scalar to every element. - raise NotImplementedError, 'adding a scalar to a CSR matrix ' \ - 'is not yet supported' - elif isspmatrix(other): - other = other.tocsr() - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, colind, data = csrplcsr(self.shape[0], other.shape[1], \ - self.indptr, self.colind, - self.data, other.indptr, \ - other.colind, other.data) - return csr_matrix((data, colind, indptr), self.shape) - elif isdense(other): - # Convert this matrix to a dense matrix and add them. - return self.todense() + other - else: - raise TypeError, "unsupported type for sparse matrix addition" + _cs_matrix.__add__(self, other, self.colind, other.colind, csrplcsr, csr_matrix) - def __mul__(self, other): - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - new = self.copy() - new.data = other * new.data # allows type conversion - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - return self.dot(other) - def __rmul__(self, other): # other * self - if isscalarlike(other): - new = self.copy() - new.data = other * new.data # allows type conversion - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - # Don't use asarray unless we have to - try: - tr = other.transpose() - except AttributeError: - tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() - - def __neg__(self): - new = self.copy() - new.data *= -1 - return new - def __pow__(self, other): - """ Element-by-element power (unless other is a scalar, in which - case return the matrix power.) - """ - if isscalarlike(other): - new = self.copy() - new.data = new.data ** other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - elif isspmatrix(other): - other = other.tocsr() - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, colind, data = csrelmulcsr(self.shape[0], other.shape[1], \ - self.indptr, self.colind, \ - self.data, other.indptr, \ - other.colind, other.data) - return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) - else: - raise TypeError, "unsupported type for sparse matrix power" + _cs_matrix.__pow__(self, other, self.colind, other.colind, csrelmulcsr, csr_matrix) def transpose(self, copy=False): M, N = self.shape @@ -1309,60 +1261,13 @@ return asmatrix(out) def matvec(self, other): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like dense matrix objects can. - #if len(other) != self.shape[1]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - y = csrmux(self.shape[0], self.shape[1], self.indptr, self.colind, self.data, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # If 'other' was an (nx1) column vector, transpose the result - # to obtain an (mx1) column vector. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - + _cs_matrix.matvec(self, other, self.colind, csrmux) + def rmatvec(self, other, conjugate=True): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like dense matrix objects can. - #if len(other) != self.shape[0]: - # raise ValueError, "dimension mismatch" - func = getattr(sparsetools, self.ftype+'cscmux') - if conjugate: - cd = conj(self.data) - else: - cd = self.data + _cs_matrix.rmatvec(self, other, shape[0], shape[1], csrmux, conjugate=conjugate) - oth = numpy.ravel(other) - y = cscmux(self.shape[0], self.shape[1], self.indptr, self.rowind, cd, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # In the (unlikely) event that this matrix is 1x1 and 'other' was an - # (mx1) column vector, transpose the result. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - other = other.tocsr() - indptr, colind, data = csrmucsr(M, N, \ - self.indptr, self.colind, \ - self.data, other.indptr, \ - other.colind, other.data) - return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) - elif isdense(other): - # This is SLOW! We need a more efficient implementation - # of sparse * dense matrix multiplication! - return self.matmat(csc_matrix(other)) - else: - raise TypeError, "need a dense or sparse matrix" + _cs_matrix.matmat(self, other, self.colind, other.colind, csr_matrix) def __getitem__(self, key): @@ -1466,19 +1371,11 @@ row = searchsorted(self.indptr, ind+1)-1 return (row, col) - def getdata(self, ind): - return self.data[ind] - def tocsr(self, copy=False): - if copy: - return self.copy() - else: - return self + return self.toself(copy) def tocoo(self): - rows, cols, data = csrtocoo(self.shape[0], self.shape[1], \ - self.indptr, self.colind, self.data) - return coo_matrix((data, (rows, cols)), self.shape) + _cs_matrix.tocoo(self, csrtocoo, self.colind) def tocsc(self): indptr, rowind, data = csrtocsc(self.shape[0], self.shape[1], \ @@ -2253,10 +2150,7 @@ return csr_matrix((data, colind, indptr), self.shape) def tocoo(self, copy=False): - if copy: - return self.copy() - else: - return self + return self.toself(copy) class lil_matrix(spmatrix): From scipy-svn at scipy.org Tue Jan 9 23:05:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 22:05:50 -0600 (CST) Subject: [Scipy-svn] r2515 - trunk/Lib/sparse Message-ID: <20070110040550.3DA4739C0CF@new.scipy.org> Author: timl Date: 2007-01-09 22:05:39 -0600 (Tue, 09 Jan 2007) New Revision: 2515 Modified: trunk/Lib/sparse/sparse.py Log: fix typo Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-10 03:19:32 UTC (rev 2514) +++ trunk/Lib/sparse/sparse.py 2007-01-10 04:05:39 UTC (rev 2515) @@ -466,7 +466,7 @@ fd.write(format % (ir, ic, data)) fd.close() -class _sc_matrix(spmatrix): +class _cs_matrix(spmatrix): def astype(self, t): out = self.copy() From scipy-svn at scipy.org Tue Jan 9 23:18:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 22:18:57 -0600 (CST) Subject: [Scipy-svn] r2516 - trunk/Lib/sparse Message-ID: <20070110041857.CC1CD39C1E9@new.scipy.org> Author: timl Date: 2007-01-09 22:18:44 -0600 (Tue, 09 Jan 2007) New Revision: 2516 Modified: trunk/Lib/sparse/sparse.py Log: cleanups and a bugfix from previous change Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-10 04:05:39 UTC (rev 2515) +++ trunk/Lib/sparse/sparse.py 2007-01-10 04:18:44 UTC (rev 2516) @@ -563,16 +563,16 @@ raise TypeError, "unsupported type for sparse matrix power" - def matmat(self, other, self_ind, other_ind, cls): + def _matmat(self, other, self_ind, other_ind, fn, cls): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" other = other.tocsc() - indptr, ind, data = cscmucsc(M, N, self.indptr, self_ind, \ - self.data, other.indptr, \ - other_ind, other.data) + indptr, ind, data = fn(M, N, self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) return cls((data, ind, indptr), (M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation @@ -581,7 +581,7 @@ else: raise TypeError, "need a dense or sparse matrix" - def matvec(self, other, self_ind, fn): + def _matvec(self, other, self_ind, fn): if isdense(other): # This check is too harsh -- it prevents a column vector from # being created on-the-fly like dense matrix objects can. @@ -602,7 +602,7 @@ else: raise TypeError, "need a dense vector" - def rmatvec(self, other, shape0, shape1, fn, conjugate=True): + def _rmatvec(self, other, shape0, shape1, fn, conjugate=True): if isdense(other): # This check is too harsh -- it prevents a column vector from # being created on-the-fly like dense matrix objects can. @@ -616,8 +616,8 @@ y = fn(shape0, shape1, self.indptr, self.rowind, cd, oth) if isinstance(other, matrix): y = asmatrix(y) - # In the (unlikely) event that this matrix is 1x1 and 'other' was an - # (mx1) column vector, transpose the result. + # In the (unlikely) event that this matrix is 1x1 and 'other' + # was an (mx1) column vector, transpose the result. if other.ndim == 2 and other.shape[1] == 1: y = y.T return y @@ -629,7 +629,7 @@ def getdata(self, ind): return self.data[ind] - def tocoo(self, fn, self_ind): + def _tocoo(self, fn, self_ind): rows, cols, data = fn(self.shape[0], self.shape[1], \ self.indptr, self_ind, self.data) return coo_matrix((data, (rows, cols)), self.shape) @@ -887,13 +887,13 @@ return asmatrix(out).T def matvec(self, other): - _cs_matrix.matvec(self, other, self.rowind, cscmux) + _cs_matrix._matvec(self, other, self.rowind, cscmux) def rmatvec(self, other, conjugate=True): - _cs_matrix.rmatvec(self, other, shape[1], shape[0], cscmux, conjugate=conjugate) + _cs_matrix._rmatvec(self, other, shape[1], shape[0], cscmux, conjugate=conjugate) def matmat(self, other): - _cs_matrix.matmat(self, other, self.rowind, other.rowind, csc_matrix) + _cs_matrix._matmat(self, other, self.rowind, other.rowind, cscmucsc, csc_matrix) def __getitem__(self, key): @@ -1004,7 +1004,7 @@ return self.toself(copy) def tocoo(self): - _cs_matrix.tocoo(self, csctocoo, self.rowind) + _cs_matrix._tocoo(self, csctocoo, self.rowind) def tocsr(self): indptr, colind, data = csctocsr(self.shape[0], self.shape[1], \ @@ -1032,13 +1032,9 @@ """Return a copy of this matrix where the row indices are sorted """ if inplace: -## temp = self.tocsr().tocsc() -## self.rowind = temp.rowind -## self.indptr = temp.indptr -## self.data = temp.data - sparsetools.ensure_sorted_indices( self.shape[1],self.shape[0], - self.indptr,self.rowind, - self.data ) + sparsetools.ensure_sorted_indices(self.shape[1], self.shape[0], + self.indptr, self.rowind, + self.data ) else: return self.tocsr().tocsc() @@ -1261,13 +1257,13 @@ return asmatrix(out) def matvec(self, other): - _cs_matrix.matvec(self, other, self.colind, csrmux) + _cs_matrix._matvec(self, other, self.colind, csrmux) def rmatvec(self, other, conjugate=True): - _cs_matrix.rmatvec(self, other, shape[0], shape[1], csrmux, conjugate=conjugate) + _cs_matrix._rmatvec(self, other, shape[0], shape[1], csrmux, conjugate=conjugate) def matmat(self, other): - _cs_matrix.matmat(self, other, self.colind, other.colind, csr_matrix) + _cs_matrix._matmat(self, other, self.colind, other.colind, csrmucsr, csr_matrix) def __getitem__(self, key): @@ -1375,7 +1371,7 @@ return self.toself(copy) def tocoo(self): - _cs_matrix.tocoo(self, csrtocoo, self.colind) + _cs_matrix._tocoo(self, csrtocoo, self.colind) def tocsc(self): indptr, rowind, data = csrtocsc(self.shape[0], self.shape[1], \ @@ -1407,13 +1403,9 @@ """Return a copy of this matrix where the column indices are sorted """ if inplace: -## temp = self.tocsc().tocsr() -## self.colind = temp.colind -## self.indptr = temp.indptr -## self.data = temp.data - sparsetools.ensure_sorted_indices( self.shape[0],self.shape[1], - self.indptr,self.colind, - self.data ) + sparsetools.ensure_sorted_indices(self.shape[0], self.shape[1], + self.indptr, self.colind, + self.data ) else: return self.tocsc().tocsr() From scipy-svn at scipy.org Tue Jan 9 23:32:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 22:32:07 -0600 (CST) Subject: [Scipy-svn] r2517 - trunk/Lib/sparse Message-ID: <20070110043207.1F63639C24C@new.scipy.org> Author: timl Date: 2007-01-09 22:32:02 -0600 (Tue, 09 Jan 2007) New Revision: 2517 Modified: trunk/Lib/sparse/sparse.py Log: revert the last few changes while I sort out all the bugs. sorry. Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-10 04:18:44 UTC (rev 2516) +++ trunk/Lib/sparse/sparse.py 2007-01-10 04:32:02 UTC (rev 2517) @@ -374,13 +374,6 @@ csc = self.tocsc() return csc.tocoo() - def toself(self, copy=False): - if copy: - new = self.copy() - else: - new = self - return new - def copy(self): csc = self.tocsc() return csc.copy() @@ -466,177 +459,7 @@ fd.write(format % (ir, ic, data)) fd.close() -class _cs_matrix(spmatrix): - - def astype(self, t): - out = self.copy() - out.data = out.data.astype(t) - out.dtype = out.data.dtype - out.ftype = _transtabl[out.dtype.char] - return out - - def __repr__(self): - format = self.getformat() - return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ - "elements (space for %d)\n\tin %s format>" % \ - (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ - _formats[format][1])) - - - - def __add__(self, other, self_ind, other_ind, fn, cls): - # First check if argument is a scalar - if isscalarlike(other): - # Now we would add this scalar to every element. - raise NotImplementedError, 'adding a scalar to a CSC or CSR ' \ - 'matrix is not yet supported' - elif isspmatrix(other): - other = other.tocsc() - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, ind, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, \ - self.data, other.indptr, \ - other_ind, other.data) - return cls((data, ind, indptr), self.shape) - elif isdense(other): - # Convert this matrix to a dense matrix and add them - return other + self.todense() - else: - raise TypeError, "unsupported type for sparse matrix addition" - - - def __mul__(self, other): - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - new = self.copy() - new.data = other * new.data # allows type conversion - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - return self.dot(other) - - - def __rmul__(self, other): # other * self - if isscalarlike(other): - new = self.copy() - new.data = other * new.data # allows type conversion - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - # Don't use asarray unless we have to - try: - tr = other.transpose() - except AttributeError: - tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() - - - def __neg__(self): - new = self.copy() - new.data *= -1 - return new - - def __pow__(self, other, self_ind, other_ind, fn, cls): - """ Element-by-element power (unless other is a scalar, in which - case return the matrix power.) - """ - if isscalarlike(other): - new = self.copy() - new.data = new.data ** other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - elif isspmatrix(other): - other = other.tocsr() - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, ind, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, \ - self.data, other.indptr, \ - other_ind, other.data) - return cls((data, ind, indptr), (self.shape[0], other.shape[1])) - else: - raise TypeError, "unsupported type for sparse matrix power" - - - def _matmat(self, other, self_ind, other_ind, fn, cls): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - other = other.tocsc() - indptr, ind, data = fn(M, N, self.indptr, self_ind, \ - self.data, other.indptr, \ - other_ind, other.data) - return cls((data, ind, indptr), (M, N)) - elif isdense(other): - # This is SLOW! We need a more efficient implementation - # of sparse * dense matrix multiplication! - return self.matmat(csc_matrix(other)) - else: - raise TypeError, "need a dense or sparse matrix" - - def _matvec(self, other, self_ind, fn): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like dense matrix objects can. - #if len(other) != self.shape[1]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - y = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, self.data, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # If 'other' was an (nx1) column vector, transpose the result - # to obtain an (mx1) column vector. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" - - def _rmatvec(self, other, shape0, shape1, fn, conjugate=True): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like dense matrix objects can. - # if len(other) != self.shape[0]: - # raise ValueError, "dimension mismatch" - if conjugate: - cd = conj(self.data) - else: - cd = self.data - oth = numpy.ravel(other) - y = fn(shape0, shape1, self.indptr, self.rowind, cd, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # In the (unlikely) event that this matrix is 1x1 and 'other' - # was an (mx1) column vector, transpose the result. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" - - def getdata(self, ind): - return self.data[ind] - - def _tocoo(self, fn, self_ind): - rows, cols, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, self.data) - return coo_matrix((data, (rows, cols)), self.shape) - - - -class csc_matrix(_cs_matrix): +class csc_matrix(spmatrix): """ Compressed sparse column matrix This can be instantiated in several ways: - csc_matrix(d) @@ -658,7 +481,7 @@ standard CSC representation """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): - _cs_matrix.__init__(self) + spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSC format @@ -768,6 +591,7 @@ M = max(oldM, M) N = max(0, oldN, N, len(self.indptr) - 1) self.shape = (M, N) + self._check() def _check(self): @@ -777,6 +601,7 @@ M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind) + if (rank(self.data) != 1) or (rank(self.rowind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, rowind, and indptr arrays "\ @@ -805,6 +630,19 @@ self.ftype = _transtabl[self.dtype.char] + def astype(self, t): + out = self.copy() + out.data = out.data.astype(t) + out.dtype = out.data.dtype + out.ftype = _transtabl[out.dtype.char] + return out + + def __repr__(self): + format = self.getformat() + return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ + "elements (space for %d)\n\tin %s format>" % \ + (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ + _formats[format][1])) def __radd__(self, other): """ Function supporting the operation: self + other. @@ -828,10 +666,75 @@ raise TypeError, "unsupported type for sparse matrix addition" def __add__(self, other): - _cs_matrix.__add__(self, other, self.rowind, other.rowind, cscplcsc, csc_matrix) + if isscalarlike(other): + raise NotImplementedError, 'adding a scalar to a CSC matrix is ' \ + 'not yet supported' + elif isspmatrix(other): + ocs = other.tocsc() + if (ocs.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, \ + self.data, ocs.indptr, ocs.rowind, \ + ocs.data) + return csc_matrix((data, rowind, indptr), self.shape) + elif isdense(other): + # Convert this matrix to a dense matrix and add them + return other + self.todense() + else: + raise TypeError, "unsupported type for sparse matrix addition" + def __mul__(self, other): + """ Scalar, vector, or matrix multiplication + """ + if isscalarlike(other): + new = self.copy() + new.data *= other + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + return self.dot(other) + + def __rmul__(self, other): # other * self + if isscalarlike(other): + new = self.copy() + new.data = other * new.data + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + # Don't use asarray unless we have to + try: + tr = other.transpose() + except AttributeError: + tr = asarray(other).transpose() + return self.transpose().dot(tr).transpose() + + def __neg__(self): + new = self.copy() + new.data *= -1 + return new + def __pow__(self, other): - _cs_matrix.__pow__(self, other, self.rowind, other.rowind, cscelmulcsc, csc_matrix) + """ Element-by-element power (unless other is a scalar, in which + case return the matrix power.) + """ + if isscalarlike(other): + new = self.copy() + new.data = new.data ** other + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + ocs = other.tocsc() + if (ocs.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, rowind, data = cscelmulcsc(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, \ + self.data, ocs.indptr, \ + ocs.rowind, ocs.data) + return csc_matrix((data, rowind, indptr), (self.shape[0], ocs.shape[1])) def transpose(self, copy=False): M, N = self.shape @@ -866,10 +769,10 @@ m, n = self.shape data = self.data if axis in (0, None): + indptr = self.indptr out = empty(n, dtype=self.dtype) # The first element in column j has index indptr[j], the last # indptr[j+1] - indptr = self.indptr for j in xrange(n): out[j] = data[indptr[j] : indptr[j+1]].sum() if axis == 0: @@ -885,15 +788,70 @@ out[rowind[k]] += data[k] # Output is a (m x 1) dense matrix return asmatrix(out).T - + + def matvec(self, other): - _cs_matrix._matvec(self, other, self.rowind, cscmux) + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like with dense matrix objects. + #if len(other) != self.shape[1]: + # raise ValueError, "dimension mismatch" + oth = numpy.ravel(other) + y = cscmux(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, self.data, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # If 'other' was an (nx1) column vector, transpose the result + # to obtain an (mx1) column vector. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + elif isspmatrix(other): + raise TypeError, "use matmat() for sparse * sparse" + else: + raise TypeError, "need a dense vector" def rmatvec(self, other, conjugate=True): - _cs_matrix._rmatvec(self, other, shape[1], shape[0], cscmux, conjugate=conjugate) + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like with dense matrix objects. + #if len(other) != self.shape[0]: + # raise ValueError, "dimension mismatch" + oth = numpy.ravel(other) + if conjugate: + cd = conj(self.data) + else: + cd = self.data + y = csrmux(self.shape[1], self.shape[0], self.indptr, self.rowind, cd, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # In the (unlikely) event that this matrix is 1x1 and 'other' was an + # (mx1) column vector, transpose the result. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + elif isspmatrix(other): + raise TypeError, "use matmat() for sparse * sparse" + else: + raise TypeError, "need a dense vector" def matmat(self, other): - _cs_matrix._matmat(self, other, self.rowind, other.rowind, cscmucsc, csc_matrix) + if isspmatrix(other): + M, K1 = self.shape + K2, N = other.shape + if (K1 != K2): + raise ValueError, "shape mismatch error" + other = other.tocsc() + indptr, rowind, data = cscmucsc(M, N, self.indptr, self.rowind, \ + self.data, other.indptr, \ + other.rowind, other.data) + return csc_matrix((data, rowind, indptr), (M, N)) + elif isdense(other): + # This is SLOW! We need a more efficient implementation + # of sparse * dense matrix multiplication! + return self.matmat(csc_matrix(other)) + else: + raise TypeError, "need a dense or sparse matrix" def __getitem__(self, key): @@ -1000,15 +958,24 @@ col = searchsorted(self.indptr, ind+1)-1 return (row, col) + def getdata(self, ind): + return self.data[ind] + def tocsc(self, copy=False): - return self.toself(copy) + if copy: + new = self.copy() + else: + new = self + return new def tocoo(self): - _cs_matrix._tocoo(self, csctocoo, self.rowind) + rows, cols, data = csctocoo(self.shape[0], self.shape[1], \ + self.indptr, self.rowind, self.data) + return coo_matrix((data, (rows, cols)), self.shape) def tocsr(self): indptr, colind, data = csctocsr(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data) + self.indptr, self.rowind, self.data) return csr_matrix((data, colind, indptr), self.shape) def toarray(self): @@ -1032,9 +999,13 @@ """Return a copy of this matrix where the row indices are sorted """ if inplace: - sparsetools.ensure_sorted_indices(self.shape[1], self.shape[0], - self.indptr, self.rowind, - self.data ) +## temp = self.tocsr().tocsc() +## self.rowind = temp.rowind +## self.indptr = temp.indptr +## self.data = temp.data + sparsetools.ensure_sorted_indices( self.shape[1],self.shape[0], + self.indptr,self.rowind, + self.data ) else: return self.tocsr().tocsc() @@ -1048,7 +1019,7 @@ return new -class csr_matrix(_cs_matrix): +class csr_matrix(spmatrix): """ Compressed sparse row matrix This can be instantiated in several ways: - csr_matrix(d) @@ -1070,7 +1041,7 @@ standard CSR representation """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): - _cs_matrix.__init__(self) + spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format @@ -1208,13 +1179,94 @@ self.ftype = _transtabl[self.dtype.char] + def astype(self, t): + out = self.copy() + out.data = out.data.astype(t) + out.dtype = out.data.dtype + out.ftype = _transtabl[out.dtype.char] + return out + + def __repr__(self): + format = self.getformat() + return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ + "elements (space for %d)\n\tin %s format>" % \ + (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ + _formats[format][1])) def __add__(self, other): - _cs_matrix.__add__(self, other, self.colind, other.colind, csrplcsr, csr_matrix) + # First check if argument is a scalar + if isscalarlike(other): + # Now we would add this scalar to every element. + raise NotImplementedError, 'adding a scalar to a CSR matrix ' \ + 'is not yet supported' + elif isspmatrix(other): + other = other.tocsr() + if (other.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, colind, data = csrplcsr(self.shape[0], other.shape[1], \ + self.indptr, self.colind, + self.data, other.indptr, \ + other.colind, other.data) + return csr_matrix((data, colind, indptr), self.shape) + elif isdense(other): + # Convert this matrix to a dense matrix and add them. + return self.todense() + other + else: + raise TypeError, "unsupported type for sparse matrix addition" + def __mul__(self, other): + """ Scalar, vector, or matrix multiplication + """ + if isscalarlike(other): + new = self.copy() + new.data = other * new.data # allows type conversion + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + return self.dot(other) + def __rmul__(self, other): # other * self + if isscalarlike(other): + new = self.copy() + new.data = other * new.data # allows type conversion + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + # Don't use asarray unless we have to + try: + tr = other.transpose() + except AttributeError: + tr = asarray(other).transpose() + return self.transpose().dot(tr).transpose() + + def __neg__(self): + new = self.copy() + new.data *= -1 + return new + def __pow__(self, other): - _cs_matrix.__pow__(self, other, self.colind, other.colind, csrelmulcsr, csr_matrix) + """ Element-by-element power (unless other is a scalar, in which + case return the matrix power.) + """ + if isscalarlike(other): + new = self.copy() + new.data = new.data ** other + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + elif isspmatrix(other): + other = other.tocsr() + if (other.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, colind, data = csrelmulcsr(self.shape[0], other.shape[1], \ + self.indptr, self.colind, \ + self.data, other.indptr, \ + other.colind, other.data) + return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) + else: + raise TypeError, "unsupported type for sparse matrix power" def transpose(self, copy=False): M, N = self.shape @@ -1257,13 +1309,60 @@ return asmatrix(out) def matvec(self, other): - _cs_matrix._matvec(self, other, self.colind, csrmux) - + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like dense matrix objects can. + #if len(other) != self.shape[1]: + # raise ValueError, "dimension mismatch" + oth = numpy.ravel(other) + y = csrmux(self.shape[0], self.shape[1], self.indptr, self.colind, self.data, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # If 'other' was an (nx1) column vector, transpose the result + # to obtain an (mx1) column vector. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + def rmatvec(self, other, conjugate=True): - _cs_matrix._rmatvec(self, other, shape[0], shape[1], csrmux, conjugate=conjugate) + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like dense matrix objects can. + #if len(other) != self.shape[0]: + # raise ValueError, "dimension mismatch" + func = getattr(sparsetools, self.ftype+'cscmux') + if conjugate: + cd = conj(self.data) + else: + cd = self.data + oth = numpy.ravel(other) + y = cscmux(self.shape[0], self.shape[1], self.indptr, self.rowind, cd, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # In the (unlikely) event that this matrix is 1x1 and 'other' was an + # (mx1) column vector, transpose the result. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + def matmat(self, other): - _cs_matrix._matmat(self, other, self.colind, other.colind, csrmucsr, csr_matrix) + if isspmatrix(other): + M, K1 = self.shape + K2, N = other.shape + if (K1 != K2): + raise ValueError, "shape mismatch error" + other = other.tocsr() + indptr, colind, data = csrmucsr(M, N, \ + self.indptr, self.colind, \ + self.data, other.indptr, \ + other.colind, other.data) + return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) + elif isdense(other): + # This is SLOW! We need a more efficient implementation + # of sparse * dense matrix multiplication! + return self.matmat(csc_matrix(other)) + else: + raise TypeError, "need a dense or sparse matrix" def __getitem__(self, key): @@ -1367,11 +1466,19 @@ row = searchsorted(self.indptr, ind+1)-1 return (row, col) + def getdata(self, ind): + return self.data[ind] + def tocsr(self, copy=False): - return self.toself(copy) + if copy: + return self.copy() + else: + return self def tocoo(self): - _cs_matrix._tocoo(self, csrtocoo, self.colind) + rows, cols, data = csrtocoo(self.shape[0], self.shape[1], \ + self.indptr, self.colind, self.data) + return coo_matrix((data, (rows, cols)), self.shape) def tocsc(self): indptr, rowind, data = csrtocsc(self.shape[0], self.shape[1], \ @@ -1403,9 +1510,13 @@ """Return a copy of this matrix where the column indices are sorted """ if inplace: - sparsetools.ensure_sorted_indices(self.shape[0], self.shape[1], - self.indptr, self.colind, - self.data ) +## temp = self.tocsc().tocsr() +## self.colind = temp.colind +## self.indptr = temp.indptr +## self.data = temp.data + sparsetools.ensure_sorted_indices( self.shape[0],self.shape[1], + self.indptr,self.colind, + self.data ) else: return self.tocsc().tocsr() @@ -2142,7 +2253,10 @@ return csr_matrix((data, colind, indptr), self.shape) def tocoo(self, copy=False): - return self.toself(copy) + if copy: + return self.copy() + else: + return self class lil_matrix(spmatrix): From scipy-svn at scipy.org Wed Jan 10 00:39:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 9 Jan 2007 23:39:33 -0600 (CST) Subject: [Scipy-svn] r2518 - trunk/Lib/sparse Message-ID: <20070110053933.94B8339C118@new.scipy.org> Author: timl Date: 2007-01-09 23:39:28 -0600 (Tue, 09 Jan 2007) New Revision: 2518 Modified: trunk/Lib/sparse/sparse.py Log: recommit sparse changes. now with passing tests and no segaults Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-10 04:32:02 UTC (rev 2517) +++ trunk/Lib/sparse/sparse.py 2007-01-10 05:39:28 UTC (rev 2518) @@ -374,6 +374,13 @@ csc = self.tocsc() return csc.tocoo() + def toself(self, copy=False): + if copy: + new = self.copy() + else: + new = self + return new + def copy(self): csc = self.tocsc() return csc.copy() @@ -459,7 +466,194 @@ fd.write(format % (ir, ic, data)) fd.close() -class csc_matrix(spmatrix): +class _cs_matrix(spmatrix): + + def astype(self, t): + out = self.copy() + out.data = out.data.astype(t) + out.dtype = out.data.dtype + out.ftype = _transtabl[out.dtype.char] + return out + + def __repr__(self): + format = self.getformat() + return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ + "elements (space for %d)\n\tin %s format>" % \ + (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ + _formats[format][1])) + + + + def __add__(self, other, self_ind, other_ind, fn, cls): + # First check if argument is a scalar + if isscalarlike(other): + # Now we would add this scalar to every element. + raise NotImplementedError, 'adding a scalar to a CSC or CSR ' \ + 'matrix is not yet supported' + elif isspmatrix(other): + other = other.tocsc() + if (other.shape != self.shape): + raise ValueError, "inconsistent shapes" + if other_ind: + other = other.tocsc() + other_ind = other.rowind + else: + other = other.tocsr() + other_ind = other.colind + indptr, ind, data = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) + return cls((data, ind, indptr), self.shape) + elif isdense(other): + # Convert this matrix to a dense matrix and add them + return other + self.todense() + else: + raise TypeError, "unsupported type for sparse matrix addition" + + + def __mul__(self, other): + """ Scalar, vector, or matrix multiplication + """ + if isscalarlike(other): + new = self.copy() + new.data = other * new.data # allows type conversion + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + return self.dot(other) + + + def __rmul__(self, other): # other * self + if isscalarlike(other): + new = self.copy() + new.data = other * new.data # allows type conversion + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + else: + # Don't use asarray unless we have to + try: + tr = other.transpose() + except AttributeError: + tr = asarray(other).transpose() + return self.transpose().dot(tr).transpose() + + + def __neg__(self): + new = self.copy() + new.data *= -1 + return new + + def __pow__(self, other, self_ind, other_ind, fn, cls): + """ Element-by-element power (unless other is a scalar, in which + case return the matrix power.) + """ + if isscalarlike(other): + new = self.copy() + new.data = new.data ** other + new.dtype = new.data.dtype + new.ftype = _transtabl[new.dtype.char] + return new + elif isspmatrix(other): + if other_ind: + other = other.tocsc() + other_ind = other.rowind + else: + other = other.tocsr() + other_ind = other.colind + + if (other.shape != self.shape): + raise ValueError, "inconsistent shapes" + indptr, ind, data = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) + return cls((data, ind, indptr), (self.shape[0], other.shape[1])) + else: + raise TypeError, "unsupported type for sparse matrix power" + + + def _matmat(self, other, self_ind, other_ind, fn, cls): + if isspmatrix(other): + M, K1 = self.shape + K2, N = other.shape + if (K1 != K2): + raise ValueError, "shape mismatch error" + if other_ind: + other = other.tocsc() + other_ind = other.rowind + else: + other = other.tocsr() + other_ind = other.colind + indptr, ind, data = fn(M, N, self.indptr, self_ind, \ + self.data, other.indptr, \ + other_ind, other.data) + return cls((data, ind, indptr), (M, N)) + elif isdense(other): + # This is SLOW! We need a more efficient implementation + # of sparse * dense matrix multiplication! + return self.matmat(csc_matrix(other)) + else: + raise TypeError, "need a dense or sparse matrix" + + def _matvec(self, other, self_ind, fn): + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like dense matrix objects can. + #if len(other) != self.shape[1]: + # raise ValueError, "dimension mismatch" + oth = numpy.ravel(other) + y = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, self.data, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # If 'other' was an (nx1) column vector, transpose the result + # to obtain an (mx1) column vector. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + elif isspmatrix(other): + raise TypeError, "use matmat() for sparse * sparse" + else: + raise TypeError, "need a dense vector" + + def _rmatvec(self, other, shape0, shape1, fn, conjugate=True): + if isdense(other): + # This check is too harsh -- it prevents a column vector from + # being created on-the-fly like dense matrix objects can. + # if len(other) != self.shape[0]: + # raise ValueError, "dimension mismatch" + if conjugate: + cd = conj(self.data) + else: + cd = self.data + oth = numpy.ravel(other) + y = fn(shape0, shape1, self.indptr, self.rowind, cd, oth) + if isinstance(other, matrix): + y = asmatrix(y) + # In the (unlikely) event that this matrix is 1x1 and 'other' + # was an (mx1) column vector, transpose the result. + if other.ndim == 2 and other.shape[1] == 1: + y = y.T + return y + elif isspmatrix(other): + raise TypeError, "use matmat() for sparse * sparse" + else: + raise TypeError, "need a dense vector" + + def getdata(self, ind): + return self.data[ind] + + def _tocoo(self, fn, self_ind): + rows, cols, data = fn(self.shape[0], self.shape[1], \ + self.indptr, self_ind, self.data) + return coo_matrix((data, (rows, cols)), self.shape) + + + +class csc_matrix(_cs_matrix): """ Compressed sparse column matrix This can be instantiated in several ways: - csc_matrix(d) @@ -481,7 +675,7 @@ standard CSC representation """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): - spmatrix.__init__(self) + _cs_matrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSC format @@ -591,7 +785,6 @@ M = max(oldM, M) N = max(0, oldN, N, len(self.indptr) - 1) self.shape = (M, N) - self._check() def _check(self): @@ -601,7 +794,6 @@ M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind) - if (rank(self.data) != 1) or (rank(self.rowind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, rowind, and indptr arrays "\ @@ -630,19 +822,6 @@ self.ftype = _transtabl[self.dtype.char] - def astype(self, t): - out = self.copy() - out.data = out.data.astype(t) - out.dtype = out.data.dtype - out.ftype = _transtabl[out.dtype.char] - return out - - def __repr__(self): - format = self.getformat() - return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ - "elements (space for %d)\n\tin %s format>" % \ - (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ - _formats[format][1])) def __radd__(self, other): """ Function supporting the operation: self + other. @@ -666,75 +845,10 @@ raise TypeError, "unsupported type for sparse matrix addition" def __add__(self, other): - if isscalarlike(other): - raise NotImplementedError, 'adding a scalar to a CSC matrix is ' \ - 'not yet supported' - elif isspmatrix(other): - ocs = other.tocsc() - if (ocs.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, \ - self.data, ocs.indptr, ocs.rowind, \ - ocs.data) - return csc_matrix((data, rowind, indptr), self.shape) - elif isdense(other): - # Convert this matrix to a dense matrix and add them - return other + self.todense() - else: - raise TypeError, "unsupported type for sparse matrix addition" + return _cs_matrix.__add__(self, other, self.rowind, True, cscplcsc, csc_matrix) - def __mul__(self, other): - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - new = self.copy() - new.data *= other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - return self.dot(other) - - def __rmul__(self, other): # other * self - if isscalarlike(other): - new = self.copy() - new.data = other * new.data - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - # Don't use asarray unless we have to - try: - tr = other.transpose() - except AttributeError: - tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() - - def __neg__(self): - new = self.copy() - new.data *= -1 - return new - def __pow__(self, other): - """ Element-by-element power (unless other is a scalar, in which - case return the matrix power.) - """ - if isscalarlike(other): - new = self.copy() - new.data = new.data ** other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - ocs = other.tocsc() - if (ocs.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, rowind, data = cscelmulcsc(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, \ - self.data, ocs.indptr, \ - ocs.rowind, ocs.data) - return csc_matrix((data, rowind, indptr), (self.shape[0], ocs.shape[1])) + return _cs_matrix.__pow__(self, other, self.rowind, True, cscelmulcsc, csc_matrix) def transpose(self, copy=False): M, N = self.shape @@ -769,10 +883,10 @@ m, n = self.shape data = self.data if axis in (0, None): - indptr = self.indptr out = empty(n, dtype=self.dtype) # The first element in column j has index indptr[j], the last # indptr[j+1] + indptr = self.indptr for j in xrange(n): out[j] = data[indptr[j] : indptr[j+1]].sum() if axis == 0: @@ -788,70 +902,15 @@ out[rowind[k]] += data[k] # Output is a (m x 1) dense matrix return asmatrix(out).T - - + def matvec(self, other): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like with dense matrix objects. - #if len(other) != self.shape[1]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - y = cscmux(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # If 'other' was an (nx1) column vector, transpose the result - # to obtain an (mx1) column vector. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" + return _cs_matrix._matvec(self, other, self.rowind, cscmux) def rmatvec(self, other, conjugate=True): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like with dense matrix objects. - #if len(other) != self.shape[0]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - if conjugate: - cd = conj(self.data) - else: - cd = self.data - y = csrmux(self.shape[1], self.shape[0], self.indptr, self.rowind, cd, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # In the (unlikely) event that this matrix is 1x1 and 'other' was an - # (mx1) column vector, transpose the result. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - elif isspmatrix(other): - raise TypeError, "use matmat() for sparse * sparse" - else: - raise TypeError, "need a dense vector" + return _cs_matrix._rmatvec(self, other, shape[1], shape[0], cscmux, conjugate=conjugate) def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - other = other.tocsc() - indptr, rowind, data = cscmucsc(M, N, self.indptr, self.rowind, \ - self.data, other.indptr, \ - other.rowind, other.data) - return csc_matrix((data, rowind, indptr), (M, N)) - elif isdense(other): - # This is SLOW! We need a more efficient implementation - # of sparse * dense matrix multiplication! - return self.matmat(csc_matrix(other)) - else: - raise TypeError, "need a dense or sparse matrix" + return _cs_matrix._matmat(self, other, self.rowind, True, cscmucsc, csc_matrix) def __getitem__(self, key): @@ -958,24 +1017,15 @@ col = searchsorted(self.indptr, ind+1)-1 return (row, col) - def getdata(self, ind): - return self.data[ind] - def tocsc(self, copy=False): - if copy: - new = self.copy() - else: - new = self - return new + return self.toself(copy) def tocoo(self): - rows, cols, data = csctocoo(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data) - return coo_matrix((data, (rows, cols)), self.shape) + return _cs_matrix._tocoo(self, csctocoo, self.rowind) def tocsr(self): indptr, colind, data = csctocsr(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data) + self.indptr, self.rowind, self.data) return csr_matrix((data, colind, indptr), self.shape) def toarray(self): @@ -999,13 +1049,9 @@ """Return a copy of this matrix where the row indices are sorted """ if inplace: -## temp = self.tocsr().tocsc() -## self.rowind = temp.rowind -## self.indptr = temp.indptr -## self.data = temp.data - sparsetools.ensure_sorted_indices( self.shape[1],self.shape[0], - self.indptr,self.rowind, - self.data ) + sparsetools.ensure_sorted_indices(self.shape[1], self.shape[0], + self.indptr, self.rowind, + self.data ) else: return self.tocsr().tocsc() @@ -1019,7 +1065,7 @@ return new -class csr_matrix(spmatrix): +class csr_matrix(_cs_matrix): """ Compressed sparse row matrix This can be instantiated in several ways: - csr_matrix(d) @@ -1041,7 +1087,7 @@ standard CSR representation """ def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): - spmatrix.__init__(self) + _cs_matrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format @@ -1179,94 +1225,13 @@ self.ftype = _transtabl[self.dtype.char] - def astype(self, t): - out = self.copy() - out.data = out.data.astype(t) - out.dtype = out.data.dtype - out.ftype = _transtabl[out.dtype.char] - return out - - def __repr__(self): - format = self.getformat() - return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ - "elements (space for %d)\n\tin %s format>" % \ - (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ - _formats[format][1])) def __add__(self, other): - # First check if argument is a scalar - if isscalarlike(other): - # Now we would add this scalar to every element. - raise NotImplementedError, 'adding a scalar to a CSR matrix ' \ - 'is not yet supported' - elif isspmatrix(other): - other = other.tocsr() - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, colind, data = csrplcsr(self.shape[0], other.shape[1], \ - self.indptr, self.colind, - self.data, other.indptr, \ - other.colind, other.data) - return csr_matrix((data, colind, indptr), self.shape) - elif isdense(other): - # Convert this matrix to a dense matrix and add them. - return self.todense() + other - else: - raise TypeError, "unsupported type for sparse matrix addition" + return _cs_matrix.__add__(self, other, self.colind, False, csrplcsr, csr_matrix) - def __mul__(self, other): - """ Scalar, vector, or matrix multiplication - """ - if isscalarlike(other): - new = self.copy() - new.data = other * new.data # allows type conversion - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - return self.dot(other) - def __rmul__(self, other): # other * self - if isscalarlike(other): - new = self.copy() - new.data = other * new.data # allows type conversion - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - else: - # Don't use asarray unless we have to - try: - tr = other.transpose() - except AttributeError: - tr = asarray(other).transpose() - return self.transpose().dot(tr).transpose() - - def __neg__(self): - new = self.copy() - new.data *= -1 - return new - def __pow__(self, other): - """ Element-by-element power (unless other is a scalar, in which - case return the matrix power.) - """ - if isscalarlike(other): - new = self.copy() - new.data = new.data ** other - new.dtype = new.data.dtype - new.ftype = _transtabl[new.dtype.char] - return new - elif isspmatrix(other): - other = other.tocsr() - if (other.shape != self.shape): - raise ValueError, "inconsistent shapes" - indptr, colind, data = csrelmulcsr(self.shape[0], other.shape[1], \ - self.indptr, self.colind, \ - self.data, other.indptr, \ - other.colind, other.data) - return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) - else: - raise TypeError, "unsupported type for sparse matrix power" + return _cs_matrix.__pow__(self, other, self.colind, False, csrelmulcsr, csr_matrix) def transpose(self, copy=False): M, N = self.shape @@ -1309,60 +1274,13 @@ return asmatrix(out) def matvec(self, other): - if isdense(other): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like dense matrix objects can. - #if len(other) != self.shape[1]: - # raise ValueError, "dimension mismatch" - oth = numpy.ravel(other) - y = csrmux(self.shape[0], self.shape[1], self.indptr, self.colind, self.data, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # If 'other' was an (nx1) column vector, transpose the result - # to obtain an (mx1) column vector. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - + return _cs_matrix._matvec(self, other, self.colind, csrmux) + def rmatvec(self, other, conjugate=True): - # This check is too harsh -- it prevents a column vector from - # being created on-the-fly like dense matrix objects can. - #if len(other) != self.shape[0]: - # raise ValueError, "dimension mismatch" - func = getattr(sparsetools, self.ftype+'cscmux') - if conjugate: - cd = conj(self.data) - else: - cd = self.data + return _cs_matrix._rmatvec(self, other, shape[0], shape[1], csrmux, conjugate=conjugate) - oth = numpy.ravel(other) - y = cscmux(self.shape[0], self.shape[1], self.indptr, self.rowind, cd, oth) - if isinstance(other, matrix): - y = asmatrix(y) - # In the (unlikely) event that this matrix is 1x1 and 'other' was an - # (mx1) column vector, transpose the result. - if other.ndim == 2 and other.shape[1] == 1: - y = y.T - return y - def matmat(self, other): - if isspmatrix(other): - M, K1 = self.shape - K2, N = other.shape - if (K1 != K2): - raise ValueError, "shape mismatch error" - other = other.tocsr() - indptr, colind, data = csrmucsr(M, N, \ - self.indptr, self.colind, \ - self.data, other.indptr, \ - other.colind, other.data) - return csr_matrix((data, colind, indptr), (self.shape[0], other.shape[1])) - elif isdense(other): - # This is SLOW! We need a more efficient implementation - # of sparse * dense matrix multiplication! - return self.matmat(csc_matrix(other)) - else: - raise TypeError, "need a dense or sparse matrix" + return _cs_matrix._matmat(self, other, self.colind, False, csrmucsr, csr_matrix) def __getitem__(self, key): @@ -1466,19 +1384,11 @@ row = searchsorted(self.indptr, ind+1)-1 return (row, col) - def getdata(self, ind): - return self.data[ind] - def tocsr(self, copy=False): - if copy: - return self.copy() - else: - return self + return self.toself(copy) def tocoo(self): - rows, cols, data = csrtocoo(self.shape[0], self.shape[1], \ - self.indptr, self.colind, self.data) - return coo_matrix((data, (rows, cols)), self.shape) + return _cs_matrix._tocoo(self, csrtocoo, self.colind) def tocsc(self): indptr, rowind, data = csrtocsc(self.shape[0], self.shape[1], \ @@ -1510,13 +1420,9 @@ """Return a copy of this matrix where the column indices are sorted """ if inplace: -## temp = self.tocsc().tocsr() -## self.colind = temp.colind -## self.indptr = temp.indptr -## self.data = temp.data - sparsetools.ensure_sorted_indices( self.shape[0],self.shape[1], - self.indptr,self.colind, - self.data ) + sparsetools.ensure_sorted_indices(self.shape[0], self.shape[1], + self.indptr, self.colind, + self.data ) else: return self.tocsc().tocsr() @@ -2253,10 +2159,7 @@ return csr_matrix((data, colind, indptr), self.shape) def tocoo(self, copy=False): - if copy: - return self.copy() - else: - return self + return self.toself(copy) class lil_matrix(spmatrix): From scipy-svn at scipy.org Wed Jan 10 08:02:43 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 07:02:43 -0600 (CST) Subject: [Scipy-svn] r2519 - in trunk/Lib/sandbox: . xplt Message-ID: <20070110130243.DEE1F39C03D@new.scipy.org> Author: rc Date: 2007-01-10 07:02:32 -0600 (Wed, 10 Jan 2007) New Revision: 2519 Removed: trunk/Lib/sandbox/umfpack/ Modified: trunk/Lib/sandbox/setup.py trunk/Lib/sandbox/xplt/setup.py Log: removed obsolete version of umfpack wrappers Modified: trunk/Lib/sandbox/setup.py =================================================================== --- trunk/Lib/sandbox/setup.py 2007-01-10 05:39:28 UTC (rev 2518) +++ trunk/Lib/sandbox/setup.py 2007-01-10 13:02:32 UTC (rev 2519) @@ -47,13 +47,13 @@ #config.add_subpackage('odr') # Delaunay triangulation and Natural Neighbor interpolation - #config.add_subpackage('delaunay') + config.add_subpackage('delaunay') # Gist-based plotting library for X11 #config.add_subpackage('xplt') # elementwise numerical expressions - #config.add_subpackage('numexpr') + config.add_subpackage('numexpr') # Statistical models #config.add_subpackage('models') Modified: trunk/Lib/sandbox/xplt/setup.py =================================================================== --- trunk/Lib/sandbox/xplt/setup.py 2007-01-10 05:39:28 UTC (rev 2518) +++ trunk/Lib/sandbox/xplt/setup.py 2007-01-10 13:02:32 UTC (rev 2519) @@ -245,8 +245,9 @@ ] gistpath = os.path.join(get_python_lib(1),config.path_in_package,"gistdata") + gistpath = os.path.join('/home/share/software',gistpath[1:]) gistpath = gistpath.replace("\\",r"\\\\") - + print gistpath def get_playsource(extension,build_dir): if windows: playsource = winsource + allsource From scipy-svn at scipy.org Wed Jan 10 08:16:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 07:16:13 -0600 (CST) Subject: [Scipy-svn] r2520 - in trunk/Lib/sandbox: . xplt Message-ID: <20070110131613.E32DA39C02F@new.scipy.org> Author: rc Date: 2007-01-10 07:15:48 -0600 (Wed, 10 Jan 2007) New Revision: 2520 Modified: trunk/Lib/sandbox/setup.py trunk/Lib/sandbox/xplt/setup.py Log: reverting commit by mistake Modified: trunk/Lib/sandbox/setup.py =================================================================== --- trunk/Lib/sandbox/setup.py 2007-01-10 13:02:32 UTC (rev 2519) +++ trunk/Lib/sandbox/setup.py 2007-01-10 13:15:48 UTC (rev 2520) @@ -47,13 +47,13 @@ #config.add_subpackage('odr') # Delaunay triangulation and Natural Neighbor interpolation - config.add_subpackage('delaunay') + #config.add_subpackage('delaunay') # Gist-based plotting library for X11 #config.add_subpackage('xplt') # elementwise numerical expressions - config.add_subpackage('numexpr') + #config.add_subpackage('numexpr') # Statistical models #config.add_subpackage('models') Modified: trunk/Lib/sandbox/xplt/setup.py =================================================================== --- trunk/Lib/sandbox/xplt/setup.py 2007-01-10 13:02:32 UTC (rev 2519) +++ trunk/Lib/sandbox/xplt/setup.py 2007-01-10 13:15:48 UTC (rev 2520) @@ -245,9 +245,8 @@ ] gistpath = os.path.join(get_python_lib(1),config.path_in_package,"gistdata") - gistpath = os.path.join('/home/share/software',gistpath[1:]) gistpath = gistpath.replace("\\",r"\\\\") - print gistpath + def get_playsource(extension,build_dir): if windows: playsource = winsource + allsource From scipy-svn at scipy.org Wed Jan 10 09:14:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 08:14:19 -0600 (CST) Subject: [Scipy-svn] r2521 - trunk/Lib/sparse Message-ID: <20070110141419.076E739C041@new.scipy.org> Author: wnbell Date: 2007-01-10 08:14:16 -0600 (Wed, 10 Jan 2007) New Revision: 2521 Modified: trunk/Lib/sparse/sparse.py Log: Added missing check for indptr dtype and small changes to .transpose() Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-10 13:15:48 UTC (rev 2520) +++ trunk/Lib/sparse/sparse.py 2007-01-10 14:14:16 UTC (rev 2521) @@ -812,7 +812,9 @@ "the size of data list" if (self.rowind.dtype != numpy.intc): self.rowind = self.rowind.astype(numpy.intc) + if (self.indptr.dtype != numpy.intc): self.indptr = self.indptr.astype(numpy.intc) + self.nnz = nnz self.nzmax = nzmax self.dtype = self.data.dtype @@ -852,18 +854,18 @@ def transpose(self, copy=False): M, N = self.shape - new = csr_matrix((N, M), nzmax=self.nzmax, dtype=self.dtype) + if copy: - new.data = self.data.copy() - new.colind = self.rowind.copy() - new.indptr = self.indptr.copy() + data = self.data.copy() + colind = self.rowind.copy() + indptr = self.indptr.copy() else: - new.data = self.data - new.colind = self.rowind - new.indptr = self.indptr - new._check() - return new + data = self.data + colind = self.rowind + indptr = self.indptr + return csr_matrix((data,colind,indptr),(N,M)) + def conj(self, copy=False): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) if copy: @@ -1215,7 +1217,9 @@ "the size of data list" if (self.colind.dtype != numpy.intc): self.colind = self.colind.astype(numpy.intc) + if (self.indptr.dtype != numpy.intc): self.indptr = self.indptr.astype(numpy.intc) + self.nnz = nnz self.nzmax = nzmax self.dtype = self.data.dtype @@ -1235,18 +1239,18 @@ def transpose(self, copy=False): M, N = self.shape - new = csc_matrix((N, M), nzmax=self.nzmax, dtype=self.dtype) + if copy: - new.data = self.data.copy() - new.rowind = self.colind.copy() - new.indptr = self.indptr.copy() + data = self.data.copy() + rowind = self.colind.copy() + indptr = self.indptr.copy() else: - new.data = self.data - new.rowind = self.colind - new.indptr = self.indptr - new._check() - return new + data = self.data + rowind = self.colind + indptr = self.indptr + return csc_matrix((data,rowind,indptr),(N,M)) + def sum(self, axis=None): # Override the base class sum method for efficiency in the cases # axis=1 and axis=None. From scipy-svn at scipy.org Wed Jan 10 10:42:31 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 09:42:31 -0600 (CST) Subject: [Scipy-svn] r2522 - in trunk/Lib/linsolve: . umfpack umfpack/tests Message-ID: <20070110154231.9E9FA39C21C@new.scipy.org> Author: rc Date: 2007-01-10 09:42:24 -0600 (Wed, 10 Jan 2007) New Revision: 2522 Modified: trunk/Lib/linsolve/info.py trunk/Lib/linsolve/linsolve.py trunk/Lib/linsolve/umfpack/tests/test_umfpack.py trunk/Lib/linsolve/umfpack/umfpack.py Log: assumeSortedIndices support for umfpack\n Modified: trunk/Lib/linsolve/info.py =================================================================== --- trunk/Lib/linsolve/info.py 2007-01-10 14:14:16 UTC (rev 2521) +++ trunk/Lib/linsolve/info.py 2007-01-10 15:42:24 UTC (rev 2522) @@ -6,8 +6,8 @@ solve real or complex linear systems in both single and double precisions. It is automatically replaced by UMFPACK, if available. Note that UMFPACK works in double precision only, so switch it off by ->>> use_solver( use = {'useUmfpack': False} ) -to solve in the single precision. +>>> use_solver( useUmfpack = False ) +to solve in the single precision. See also use_solver documentation. Example session: @@ -20,14 +20,14 @@ >>> a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5) >>> b = array([1, 2, 3, 4, 5]) >>> print "Solve: single precision complex:" ->>> use_solver( use = {'useUmfpack' : False} ) +>>> use_solver( useUmfpack = False ) >>> a = a.astype('F') >>> x = spsolve(a, b) >>> print x >>> print "Error: ", a*x-b >>> >>> print "Solve: double precision complex:" ->>> use_solver( use = {'useUmfpack' : True} ) +>>> use_solver( useUmfpack = True ) >>> a = a.astype('D') >>> x = spsolve(a, b) >>> print x @@ -40,7 +40,7 @@ >>> print "Error: ", a*x-b >>> >>> print "Solve: single precision:" ->>> use_solver( use = {'useUmfpack' : False} ) +>>> use_solver( useUmfpack = False ) >>> a = a.astype('f') >>> x = spsolve(a, b.astype('f')) >>> print x Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-01-10 14:14:16 UTC (rev 2521) +++ trunk/Lib/linsolve/linsolve.py 2007-01-10 15:42:24 UTC (rev 2522) @@ -10,15 +10,26 @@ isUmfpack = False useUmfpack = True -def use_solver( use ): +def use_solver( **kwargs ): """ + Valid keyword arguments with defaults (other ignored): + useUmfpack = True + assumeSortedIndices = False + The default sparse solver is umfpack when available. This can be changed by - passing "use = {'useUmfpack' : False}" - which then causes the always present SuperLU based solver to be used. + passing useUmfpack = False, which then causes the always present SuperLU + based solver to be used. + + Umfpack requires a CSR/CSC matrix to have sorted column/row indices. If + sure that the matrix fulfills this, pass assumeSortedIndices = + True to gain some speed. """ - for key, val in use.iteritems(): - globals()[key] = val + if kwargs.has_key( 'useUmfpack' ): + globals()['useUmfpack'] = kwargs['useUmfpack'] + if isUmfpack: + umfpack.configure( **kwargs ) + def _toCS_superLU( A ): if hasattr(A, 'tocsc') and not isspmatrix_csr( A ): mat = A.tocsc() @@ -71,7 +82,8 @@ family = {'d' : 'di', 'D' : 'zi'} umf = umfpack.UmfpackContext( family[mat.dtype.char] ) - return umf.linsolve( umfpack.UMFPACK_A, mat, b, autoTranspose = True ) + return umf.linsolve( umfpack.UMFPACK_A, mat, b, + autoTranspose = True ) else: mat, csc = _toCS_superLU( A ) @@ -116,14 +128,14 @@ a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5) b = array([1, 2, 3, 4, 5]) print "Solve: single precision complex:" - use_solver( use = {'useUmfpack' : False} ) + use_solver( useUmfpack = False ) a = a.astype('F') x = spsolve(a, b) print x print "Error: ", a*x-b print "Solve: double precision complex:" - use_solver( use = {'useUmfpack' : True} ) + use_solver( useUmfpack = True ) a = a.astype('D') x = spsolve(a, b) print x @@ -136,7 +148,7 @@ print "Error: ", a*x-b print "Solve: single precision:" - use_solver( use = {'useUmfpack' : False} ) + use_solver( useUmfpack = False ) a = a.astype('f') x = spsolve(a, b.astype('f')) print x Modified: trunk/Lib/linsolve/umfpack/tests/test_umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-01-10 14:14:16 UTC (rev 2521) +++ trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-01-10 15:42:24 UTC (rev 2522) @@ -23,7 +23,7 @@ def check_solve_complex_without_umfpack(self): """Solve: single precision complex""" - linsolve.use_solver( {'useUmfpack' : False} ) + linsolve.use_solver( useUmfpack = False ) a = self.a.astype('F') b = self.b x = linsolve.spsolve(a, b) @@ -34,7 +34,7 @@ def check_solve_without_umfpack(self): """Solve: single precision""" - linsolve.use_solver( {'useUmfpack' : False} ) + linsolve.use_solver( useUmfpack = False ) a = self.a.astype('f') b = self.b x = linsolve.spsolve(a, b.astype('f')) @@ -45,7 +45,7 @@ def check_solve_complex_umfpack(self): """Solve with UMFPACK: double precision complex""" - linsolve.use_solver( {'useUmfpack' : True} ) + linsolve.use_solver( useUmfpack = True ) a = self.a.astype('D') b = self.b x = linsolve.spsolve(a, b) @@ -55,7 +55,7 @@ def check_solve_umfpack(self): """Solve with UMFPACK: double precision""" - linsolve.use_solver( {'useUmfpack' : True} ) + linsolve.use_solver( useUmfpack = True ) a = self.a.astype('d') b = self.b x = linsolve.spsolve(a, b) Modified: trunk/Lib/linsolve/umfpack/umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-10 14:14:16 UTC (rev 2521) +++ trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-10 15:42:24 UTC (rev 2522) @@ -15,7 +15,24 @@ except: _um = None +assumeSortedIndices = False + ## +# 10.01.2006, c +def configure( **kwargs ): + """ + Valid keyword arguments with defaults (other ignored): + assumeSortedIndices = False + + Umfpack requires a CSR/CSC matrix to have sorted column/row indices. If + sure that the matrix fulfills this, pass assumeSortedIndices = + True to gain some speed. + """ + if kwargs.has_key( 'assumeSortedIndices' ): + globals()['assumeSortedIndices'] = kwargs['assumeSortedIndices'] + + +## # 30.11.2005, c def updateDictWithVars( adict, module, pattern, group = None ): match = re.compile( pattern ).match @@ -330,15 +347,15 @@ ## # 30.11.2005, c - # 01.12.2005 - # 01.03.2006 + # last revision: 10.01.2007 def symbolic( self, mtx ): """Symbolic object (symbolic LU decomposition) computation for a given sparsity pattern.""" self.free_symbolic() - #row/column indices cannot be assumed to be sorted - mtx.ensure_sorted_indices(inplace=True) + if not assumeSortedIndices: + # row/column indices cannot be assumed to be sorted + mtx.ensure_sorted_indices( inplace = True ) indx = self._getIndx( mtx ) if self.isReal: @@ -373,9 +390,6 @@ self.free_numeric() - #row/column indices cannot be assumed to be sorted - mtx.ensure_sorted_indices(inplace=True) - if self._symbolic is None: self.symbolic( mtx ) From scipy-svn at scipy.org Wed Jan 10 12:48:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 11:48:42 -0600 (CST) Subject: [Scipy-svn] r2523 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070110174842.B116939C235@new.scipy.org> Author: pierregm Date: 2007-01-10 11:48:37 -0600 (Wed, 10 Jan 2007) New Revision: 2523 Added: trunk/Lib/sandbox/maskedarray/mrecords.py trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG Log: cf changelog Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-10 15:42:24 UTC (rev 2522) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-10 17:48:37 UTC (rev 2523) @@ -1,3 +1,11 @@ +#2007-01-10 : Mrecords +# : - Defines a class of records that support masked arrays +#2007-01-08 : Core: +# : - Forced to reset the class defaults after initialization +# : - Forced the MaskedArray class defaults to be reset +# : - Modified __array_finallize__ to allow objects w/ _data and _mask fields to be recognized as MA +#2007-01-04 : Core: +# : - Fixed a but in masked_all_like #2007-01-02 : Extras # : - Made sure that apply_along_axis output the proper fill_value # : Core Property changes on: trunk/Lib/sandbox/maskedarray/CHANGELOG ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-10 15:42:24 UTC (rev 2522) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-10 17:48:37 UTC (rev 2523) @@ -0,0 +1,633 @@ +"""mrecords +Defines a class of record arrays supporting masked arrays. + +: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 sys +import types + +import numpy as N +from numpy import bool_, complex_, float_, int_, str_, object_ +import numpy.core.numeric as numeric +import numpy.core.numerictypes as ntypes +from numpy.core.defchararray import chararray +from numpy.core.records import find_duplicate +from numpy import bool_ + +from numpy.core.records import format_parser, record, recarray + +ndarray = numeric.ndarray +_byteorderconv = N.core.records._byteorderconv +_typestr = ntypes._typestr + +import maskedarray as MA +reload(MA) +filled = MA.filled +getmaskarray = MA.getmaskarray +masked = MA.masked +nomask = MA.nomask +mask_or = MA.mask_or +masked_array = MA.masked_array + +import warnings +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) + + +class mrecarray(ndarray): + """ + +:IVariables: + - `__localfdict` : Dictionary + Dictionary of local fields (`f0_data`, `f0_mask`...) + - `__globalfdict` : Dictionary + Dictionary of global fields, as the combination of a `_data` and a `_mask`. + (`f0`) + """ + __localfdict = {} + __globalfdict = {} + def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None, + formats=None, names=None, titles=None, + byteorder=None, aligned=False, hard_mask=False): + + if dtype is not None: + descr = numeric.dtype(dtype) + else: + descr = format_parser(formats, names, titles, aligned, byteorder)._descr + + if buf is None: + mrec = ndarray.__new__(subtype, shape, (record, descr)) + else: + mrec = ndarray.__new__(subtype, shape, (record, descr), + buffer=buf, offset=offset, + strides=strides) + # Stores the field names in directories.. + mrec.__localfdict = dict(descr.fields) + mrec.__globalfdict = {} + keys = sorted(mrec.__localfdict.keys()) + for i in range(len(keys)//2): + ikey = keys[2*i] + nkey = "_".join(ikey.split('_')[:-1]) + (dfield, mfield) = ("%s_data" % nkey, "%s_mask" % nkey) + mrec.__globalfdict[nkey] = dict(_data=mrec.__localfdict[dfield], + _mask=mrec.__localfdict[mfield]) + mrec._hardmask = hard_mask + return mrec + + def __getallfields(self,fieldname): + """Returns all the fields sharing the same fieldname base. + The fieldname base is either `_data` or `_mask`.""" + logging.debug('__getallfields(%s)' % fieldname) + (names, formats, offsets, objs) = ([], [], [], []) + fkeyname = '%%s%s' % fieldname + for s in self._mrecarray__globalfdict.keys(): + fkey = fkeyname % s + fattr = self._mrecarray__localfdict[fkey] + names.append(s) + obj = self.__getobj(ndarray.__getitem__(self,fkey)) + objs.append(obj) + formats.append(fattr[0]) + offsets.append(fattr[1]) + descr = [(n,f) for (n,f) in zip(names, formats)] + return N.core.records.fromarrays(objs, dtype=descr) + + def _getdata(self): + """Returns all the `_data` fields.""" + return self.__getallfields('_data') + + def _getfieldmask(self): + """Returns a recarray of the mask of each field.""" + return self.__getallfields('_mask') + + def _getmask(self): + """Returns the mask of the mrecarray. + An element of the mrecarray is considered masked when all the corresponding + fields are masked.""" + nbfields = len(self.dtype )//2 + recmask = self._getfieldmask().view(bool_).reshape(-1,nbfields) + return recmask.all(1) + + def __getobj(self, obj, viewtype=ndarray): + "Returns an object as a view of a ndarray, or as itself." + if (isinstance(obj, ndarray) and obj.dtype.isbuiltin): + return obj.view(viewtype) + return obj + #...................................................... + def __getattribute__(self, attr): + try: + # Returns a generic attribute + return object.__getattribute__(self,attr) + except AttributeError: + # OK, so attr must be a field name + pass + # Get the list of fields ...... + fdict = ndarray.__getattribute__(self,'_mrecarray__localfdict') or {} + # Case #1: attr is a basic field + if attr in fdict.keys(): + fattr = fdict[attr] + obj = self.getfield(*fattr) + if obj.dtype.fields: + return obj + if obj.dtype.char in 'SU': + return obj.view(chararray) + return obj.view(ndarray) + # Case #2: attr is acompund field + elif ("%s_data" % attr) in fdict.keys(): + data = self.getfield(*fdict["%s_data" % attr ][:2]) + mask = self.getfield(*fdict["%s_mask" % attr ][:2]) + return MA.masked_array(data.view(ndarray), + mask=mask.view(ndarray), + copy=False) + # Case #3/4/5: attr is a generic field + elif attr == '_data': + func = ndarray.__getattribute__(self,'_mrecarray__getallfields') + return func.__call__('_data') + elif attr == '_fieldmask': + func = ndarray.__getattribute__(self,'_mrecarray__getallfields') + return func.__call__('_mask') + elif attr == '_mask': + logging.debug('__getattribute__: all fields %s' % attr) + func = ndarray.__getattribute__(self,'_getmask') + return func.__call__() + # Case #6: attr is not a field at all ! + else: + raise AttributeError, "record array has no attribute %s" % attr + +# Save the dictionary +# If the attr is a field name and not in the saved dictionary +# Undo any "setting" of the attribute and do a setfield +# Thus, you can't create attributes on-the-fly that are field names. + + def __setattr__(self, attr, val): + # gets some status on attr: an existing field ? a new attribute ? + fdict = ndarray.__getattribute__(self,'_mrecarray__localfdict') or {} + gdict = ndarray.__getattribute__(self,'_mrecarray__globalfdict') or {} + attrlist = fdict.keys() + ['_data', '_fieldmask', '_mask'] + isvalidattr = (attr in attrlist ) or ('%s_data' % attr in attrlist) + newattr = attr not in self.__dict__ + + try: + # Is attr a generic attribute ? + ret = object.__setattr__(self, attr, val) + except: + # Not a generic attribute: exit if it's not a valid field + if not isvalidattr: + exctype, value = sys.exc_info()[:2] + raise exctype, value + else: + if not isvalidattr: + return ret + if newattr: # We just added this one + try: # or this setattr worked on an internal + # attribute. + object.__delattr__(self, attr) + except: + return ret + + # Case #1.: Basic field ............ + if attr in fdict.keys(): + return self.setfield(val, *fdict[attr][:2]) + # Case #2 Compund field ............ + elif ("%s_data" % attr) in fdict.keys(): + data = self.setfield(filled(val), *fdict["%s_data" % attr ][:2]) + mask = self.setfield(getmaskarray(val), *fdict["%s_mask" % attr ][:2]) + return + elif attr == '_data': + fval = filled(val) + for k in gdict.keys(): + self.setfield(fval, *gdict["%s_data" % k ][:2]) + return +# func = ndarray.__getattribute__(self,'_mrecarray__getallfields') +# return func.__call__('_data') + elif attr == '_fieldmask': + mval = getmaskarray(val) + for k in gdict.keys(): + self.setfield(mval, *gdict["%s_mask" % k ][:2]) + return +# func = ndarray.__getattribute__(self,'_mrecarray__getallfields') +# return func.__call__('_mask') + elif attr == '_mask': + logging.debug(" setattr _mask to %s [%s]" % (val,(val is nomask))) + if self._hardmask: + logging.debug("setattr: object has hardmask") + if val is not nomask: + mval = getmaskarray(val) + for k in gdict.keys(): + fkey = fdict["%s_mask" % k ][:2] + m = mask_or(mval, self.getfield(*fkey)) + logging.debug("setattr: set %s to %s" % (k,m)) + self.setfield(m, *fkey) + else: + mval = getmaskarray(val) + for k in gdict.keys(): + self.setfield(mval, *fdict["%s_mask" % k ][:2]) + logging.debug('__getattribute__: all fields %s' % attr) + return +# func = ndarray.__getattribute__(self,'_getmask') +# return func.__call__() + + + #...................................................... + def __getitem__(self, indx): + logging.debug('__getitem__ got %s' % indx) + try: + obj = ndarray.__getitem__(self, indx) + except ValueError: + if indx in self.__globalfdict.keys(): + objd = ndarray.__getitem__(self, "%s_data" % indx) + objm = ndarray.__getitem__(self, "%s_mask" % indx) + return MA.masked_array(objd.view(ndarray), + mask=objm.view(ndarray)) + elif indx in ['_data', '_fieldmask']: + return self.__getallfields(indx) + elif indx == '_mask': + return self._getmask() + else: + msg = "Cannot do anything w/ indx '%s'!" % indx + raise ValueError, msg + +# logging.debug('__getitem__ send %s' % type(self.__getobj(obj))) + return self.__getobj(obj) + #....................................................... + def field(self,attr, val=None): + """Sets the field `attr` to the new value `val`. + If `val` is None, returns the corresponding field. + """ + if isinstance(attr,int): + names = ndarray.__getattribute__(self,'dtype').names + attr = names[attr] + + fdict = ndarray.__getattribute__(self,'_mrecarray__localfdict') or {} + f = fdict[attr] + # Case #1: just retrieve the data ....... + if val is None: + try: + return self.__getattribute__(attr) + except: + raise ValueError, "Unable to retrieve field '%s'" % attr + # Case #2: set the field to a new value .. + else: + try: + return self.__setattribute__(attr) + except: + raise ValueError, "Unable to set field '%s'" % attr + #...................................................... + def view(self, obj): + """Returns a view of the mrecarray.""" + try: + if issubclass(obj, ndarray): + logging.debug('direct view as %s' % obj) + return ndarray.view(self, obj) + except TypeError: + pass + dtype = numeric.dtype(obj) + if dtype.fields is None: + return self.__array__().view(dtype) + return ndarray.view(self, obj) + #............................................ + def harden_mask(self): + "Forces the mask to hard" + self._hardmask = True + def soften_mask(self): + "Forces the mask to soft" + self._hardmask = False + +#####--------------------------------------------------------------------------- +#---- --- Constructors --- +#####--------------------------------------------------------------------------- +def _splitfields(descr): + """Creates a new descriptor from the descriptor `descr`. + The initial fields are renamed by adding a `_data` suffix to the name. + Their dtype is kept. + New fields are also created from the initial ones by adding a `_mask` suffix + to the name. + The dtype of these latter is set to `bool_` + """ + mdescr = [] + for (n,d) in descr.descr: + mdescr.append( ("%s_data" % n, d) ) + mdescr.append( ("%s_mask" % n, bool_) ) + return numeric.dtype(mdescr) + +def fromarrays(arraylist, dtype=None, shape=None, formats=None, + names=None, titles=None, aligned=False, byteorder=None): + """Creates a mrecarray from a (flat) list of masked arrays. + +:Parameters: + - `arraylist` : Sequence + A list of (masked) arrays. Each element of the sequence is first converted + to a masked array if needed. If a 2D array is passed as argument, it is + processed line by line + - `dtype` : numeric.dtype + Data type descriptor. + - `shape` : Integer *[None]* + Number of records. If None, `shape` is defined from the shape of the first + array in the list. + - `formats` : + (Description to write) + - `names` : + (description to write) + - `titles`: + (Description to write) + - `aligned`: Boolen *[False]* + (Description to write, not used anyway) + - `byteorder`: Boolen *[None]* + (Description to write, not used anyway) + + + """ + arraylist = [MA.asarray(x) for x in arraylist] + # Define/check the shape..................... + if shape is None or shape == 0: + shape = arraylist[0].shape + if isinstance(shape, int): + shape = (shape,) + # Define formats from scratch ............... + if formats is None and dtype is None: + # go through each object in the list to see if it is an ndarray + # and determine the formats. + formats = '' + for obj in arraylist: + if not isinstance(obj, ndarray): + raise ValueError, "item in the array list must be an ndarray." + formats += _typestr[obj.dtype.type] + if issubclass(obj.dtype.type, ntypes.flexible): + formats += `obj.itemsize` + formats += ',' + formats = formats[:-1] + + logging.debug("fromarrays: formats",formats) + # Define the dtype .......................... + if dtype is not None: + descr = numeric.dtype(dtype) + _names = descr.names + else: + parsed = format_parser(formats, names, titles, aligned, byteorder) + _names = parsed._names + descr = parsed._descr + # Determine shape from data-type............. + if len(descr) != len(arraylist): + msg = "Mismatch between the number of fields (%i) and the number of "\ + "arrays (%i)" + raise ValueError, msg % (len(descr), len(arraylist)) + d0 = descr[0].shape + nn = len(d0) + if nn > 0: + shape = shape[:-nn] + # Make sure the shape is the correct one .... + for k, obj in enumerate(arraylist): + nn = len(descr[k].shape) + testshape = obj.shape[:len(obj.shape)-nn] + if testshape != shape: + raise ValueError, "Array-shape mismatch in array %d" % k + # Reconstruct the descriptor, by creating a _data and _mask version + mdescr = _splitfields(descr) + _array = mrecarray(shape, mdescr) + _names = mdescr.names + # Populate the record array (makes a copy) + for i in range(len(arraylist)): + logging.debug("fromarrays: i:%i-%s/%s" % \ + (i, arraylist[i]._data, MA.getmaskarray(arraylist[i]))) + logging.debug("fromarrays: i:%i-%s/%s" % \ + (i,_names[2*i], _names[2*i+1])) + _array[_names[2*i]] = arraylist[i]._data + _array[_names[2*i+1]] = getmaskarray(arraylist[i]) + return _array +#.............................................................................. +def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None, + titles=None, aligned=False, byteorder=None): + """Creates a mrecarray from a list of records. + + The data in the same field can be heterogeneous, they will be promoted + to the highest data type. This method is intended for creating + smaller record arrays. If used to create large array without formats + defined + + r=fromrecords([(2,3.,'abc')]*100000) + + it can be slow. + + If formats is None, then this will auto-detect formats. Use list of + tuples rather than list of lists for faster processing. + + >>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3') + >>> print r[0] + (456, 'dbe', 1.2) + >>> r.col1 + array([456, 2]) + >>> r.col2 + chararray(['dbe', 'de']) + >>> import cPickle + >>> print cPickle.loads(cPickle.dumps(r)) + recarray[ + (456, 'dbe', 1.2), + (2, 'de', 1.3) + ] + """ + # Case #1: reclist is in fact a mrecarray ........ + if isinstance(reclist, mrecarray): + mdescr = reclist.dtype + shape = reclist.shape + _array = mrecarray(shape, mdescr) + for (i,r) in enumerate(reclist): + _array[i] = r + return _array + + # No format, no dtype: create from to arrays ..... + nfields = len(reclist[0]) + if formats is None and dtype is None: # slower + if isinstance(reclist, recarray): + arrlist = [reclist.field(i) for i in range(len(reclist.dtype))] + if names is None: + names = nrec.dtype.names + else: + obj = numeric.array(reclist,dtype=object) + arrlist = [numeric.array(obj[...,i].tolist()) + for i in xrange(nfields)] + return fromarrays(arrlist, formats=formats, shape=shape, names=names, + titles=titles, aligned=aligned, byteorder=byteorder) + # Construct the descriptor ....................... + if dtype is not None: + descr = numeric.dtype(dtype) + _names = descr.names + else: + parsed = format_parser(formats, names, titles, aligned, byteorder) + _names = parsed._names + descr = parsed._descr + mdescr = _splitfields(descr) + + try: + retval = numeric.array(reclist, dtype = descr) + except TypeError: # list of lists instead of list of tuples + if (shape is None or shape == 0): + shape = len(reclist)*2 + if isinstance(shape, (int, long)): + shape = (shape*2,) + if len(shape) > 1: + raise ValueError, "Can only deal with 1-d array." + _array = recarray(shape, mdescr) + raise NotImplementedError,"I should really test that..." + for k in xrange(_array.size): + _array[k] = tuple(reclist[k]) + return _array + else: + if shape is not None and retval.shape != shape: + retval.shape = shape + # + tmp = retval.view(recarray) + _array = mrecarray(shape, mdescr) + for n in tmp.dtype.names: + _array['%s_data' % n] = tmp[n] + _array['%s_mask' % n] = nomask + return _array + +def _guessvartypes(arr): + """Tries to guess the dtypes of the str_ ndarray `arr`, by testing element-wise + conversion. Returns a list of dtypes. + The array is first converted to ndarray. If the array is 2D, the test is + performed on the first line. An exception is raised if the file is 3D or more. + """ + vartypes = [] + arr = numeric.asarray(arr) + if len(arr.shape) == 2 : + arr = arr[0] + elif len(arr.shape) > 2: + raise ValueError, "The array should be 2D at most!" + # Start the conversion loop ....... + for f in arr: + try: + val = int(f) + except ValueError: + try: + val = float(f) + except ValueError: + try: + val = complex(f) + except ValueError: + print "str_!" + vartypes.append(arr.dtype) + else: + vartypes.append(complex_) + else: + vartypes.append(float_) + else: + vartypes.append(int_) + return vartypes + +def openfile(fname): + "Opens the file handle of file `fname`" + # A file handle ................... + if hasattr(fname, 'readline'): + return fname + # Try to open the file and guess its type + try: + f = open(fname) + except IOError: + raise IOError, "No such file: '%s'" % fname + if f.readline()[:2] != "\\x": + f.seek(0,0) + return f + raise NotImplementedError, "Wow, binary file" + + +def fromtextfile(fname, delimitor=None, commentchar='#', missingchar='', + varnames=None, vartypes=None): + """Creates a mrecarray from data stored in the file `filename`. + +:Parameters: + - `filename` : file name/handle + Handle of an opened file. + - `delimitor` : Character *None* + Alphanumeric character used to separate columns in the file. + If None, any (group of) white spacestring(s) will be used. + - `commentchar` : String *['#']* + Alphanumeric character used to mark the start of a comment. + - `missingchar` : String *['']* + String indicating missing data, and used to create the masks. + - `varnames` : Sequence *[None]* + Sequence of the variable names. If None, a list will be created from + the first non empty line of the file. + - `vartypes` : Sequence *[None]* + Sequence of the variables dtypes. If None, the sequence will be estimated + from the first non-commented line. + + + Ultra simple: the varnames are in the header, one line""" + # Try to open the file ...................... + f = openfile(fname) + # Get the first non-empty line as the varnames + while True: + line = f.readline() + firstline = line[:line.find(commentchar)].strip() + _varnames = firstline.split(delimitor) + print "_VARNAMES:%s-"%_varnames, len(_varnames) + if len(_varnames) > 1: + break + if varnames is None: + varnames = _varnames + # Get the data .............................. + _variables = [line.strip().split(delimitor) for line in f + if line[0] != commentchar and len(line) > 1] + _variables = N.array(_variables) + #_variables = MA.masked_equal(_variables,'') + (nvars, nfields) = _variables.shape + # Try to guess the dtype .................... + if vartypes is None: + vartypes = _guessvartypes(_variables[0]) + else: + vartypes = [numeric.dtype(v) for v in vartypes] + if len(vartypes) != nfields: + msg = "Attempting to %i dtypes for %i fields!" + msg += " Reverting to default." + warnings.warn(msg % (len(vartypes), nfields)) + vartypes = _guessvartypes(_variables[0]) + # Construct the descriptor .................. + mdescr = [(n,f) for (n,f) in zip(varnames, vartypes)] + # Get the data and the mask ................. + # We just need a list of masked_arrays. It's easier to create it like that: + _mask = (_variables.T == '') + _datalist = [masked_array(a,mask=m,dtype=t) + for (a,m,t) in zip(_variables.T, _mask, vartypes)] + return fromarrays(_datalist, dtype=mdescr) + + + +################################################################################ +from maskedarray.testutils import assert_equal, assert_array_equal +if 1: + if 0: + 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]) +#............................................................................... + + + + + + Property changes on: trunk/Lib/sandbox/maskedarray/mrecords.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py 2007-01-10 15:42:24 UTC (rev 2522) +++ trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py 2007-01-10 17:48:37 UTC (rev 2523) @@ -0,0 +1,131 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for mrecarray. + +: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 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 +reload(maskedarray.testutils) +from maskedarray.testutils import * + +import maskedarray.core as MA +#reload(MA) +import maskedarray.mrecords +#reload(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 Property changes on: trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Wed Jan 10 14:12:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 13:12:27 -0600 (CST) Subject: [Scipy-svn] r2524 - trunk/Lib/sandbox/timeseries Message-ID: <20070110191227.9E8C039C00F@new.scipy.org> Author: mattknox_ca Date: 2007-01-10 13:12:24 -0600 (Wed, 10 Jan 2007) New Revision: 2524 Modified: trunk/Lib/sandbox/timeseries/tsdate.py Log: changed dateOf function to simply wrap cseries code Modified: trunk/Lib/sandbox/timeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/tsdate.py 2007-01-10 17:48:37 UTC (rev 2523) +++ trunk/Lib/sandbox/timeseries/tsdate.py 2007-01-10 19:12:24 UTC (rev 2524) @@ -1,4 +1,6 @@ import corelib +import cseries +import numpy as np import mx.DateTime class Date: @@ -191,102 +193,5 @@ if date.freq == toFreq: return date - elif date.freq == 'D': - - if toFreq == 'B': - # BEFORE result: preceeding Friday if date is a weekend, same day otherwise - # AFTER result: following Monday if date is a weekend, same day otherwise - tempDate = date.mxDate - if _rel == 'B': - if tempDate.day_of_week >= 5: tempDate -= (tempDate.day_of_week - 4) - elif _rel == 'A': - if tempDate.day_of_week >= 5: tempDate += 7 - tempDate.day_of_week - return Date(freq='B', mxDate=tempDate) - - elif toFreq == 'M': return Date(freq='M', year=date.year(), month=date.month()) - - elif toFreq == 'S': - if _rel == 'B': return Date(freq='S', year=date.year(), month=date.month(), day=date.day(), seconds=0) - elif _rel == "A": return Date(freq='S', year=date.year(), month=date.month(), day=date.day(), seconds=24*60*60-1) - - elif toFreq == 'Q': return Date(freq='Q', year=date.year(), quarter=date.quarter()) - - elif toFreq == 'A': return Date(freq='A', year=date.year()) - - elif date.freq == 'B': - - if toFreq == 'D': return Date(freq='D', year=date.year(), month=date.month(), day=date.day()) - - elif toFreq == 'M': return Date(freq='M', year=date.year(), month=date.month()) - - elif toFreq == 'S': - if _rel == 'B': return Date(freq='S', year=date.year(), month=date.month(), day=date.day(), seconds=0) - elif _rel == 'A': return Date(freq='S', year=date.year(), month=date.month(), dday=ate.day(), seconds=24*60*60-1) - - elif toFreq == 'Q': return Date(freq='Q', year=date.year(), quarter=date.quarter()) - - elif toFreq == 'A': return Date(freq='A', year=date.year()) - - elif date.freq == 'M': - - if toFreq == 'D': - tempDate = date.mxDate - if _rel == 'B': - return Date(freq='D', year=date.year(), month=date.month(), day=1) - elif _rel == 'A': - if date.month() == 12: - tempMonth = 1 - tempYear = date.year() + 1 - else: - tempMonth = date.month() + 1 - tempYear = date.year() - return Date('D', year=tempYear, month=tempMonth, day=1)-1 - - elif toFreq == 'B': - if _rel == 'B': return dateOf(dateOf(date, 'D', "BEFORE"), 'B', "AFTER") - elif _rel == 'A': return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") - - elif toFreq == 'S': - if _rel == 'B': return dateOf(dateOf(date, 'D', "BEFORE"), 'S', "BEFORE") - elif _rel == 'A': return dateOf(dateOf(date, 'D', "AFTER"), 'S', "AFTER") - - elif toFreq == 'Q': return Date(freq='Q', year=date.year(), quarter=date.quarter()) - - elif toFreq == 'A': return Date(freq='A', year=date.year()) - - elif date.freq == 'S': - - if toFreq == 'D': - return Date('D', year=date.year(), month=date.month(), day=date.day()) - elif toFreq == 'B': - if _rel == 'B': return dateOf(dateOf(date, 'D'), 'B', "BEFORE") - elif _rel == 'A': return dateOf(dateOf(date, 'D'), 'B', "AFTER") - elif toFreq == 'M': - return Date(freq='M', year=date.year(), month=date.month()) - - elif date.freq == 'Q': - - if toFreq == 'D': - if _rel == 'B': return dateOf(date-1, 'D', "AFTER")+1 - elif _rel == 'A': return Date(freq='D', year=date.year(), month=date.month(), day=date.day()) - elif toFreq == 'B': - if _rel == 'B': return dateOf(dateOf(date, 'D'), 'B', "AFTER") - if _rel == 'A': return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") - elif toFreq == 'M': - if _rel == 'B': return dateOf(date-1, 'M', "AFTER")+1 - elif _rel == 'A': return Date(freq='M', year=date.year(), month=date.month()) - elif toFreq == 'A': return Date(freq='A', year=date.year()) - elif date.freq == 'A': - - if toFreq == 'D': - if _rel == 'B': return Date(freq='D', year=date.year(), month=1, day=1) - elif _rel == 'A': return Date(freq='D', year=date.year(), month=12, day=31) - elif toFreq == 'B': - if _rel == 'B': return dateOf(dateOf(date, 'D'), 'B', "AFTER") - if _rel == 'A': return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") - elif toFreq == 'M': - if _rel == 'B': return Date(freq='M', year=date.year(), month=1) - elif _rel == 'A': return Date(freq='M', year=date.year(), month=12) - elif toFreq == 'Q': - if _rel == 'B': return Date(freq='Q', year=date.year(), quarter=1) - elif _rel == 'A': return Date(freq='Q', year=date.year(), quarter=4) \ No newline at end of file + else: + return Date(freq=toFreq, value=cseries.asfreq(np.asarray(date.value), date.freq, toFreq, _rel)) From scipy-svn at scipy.org Wed Jan 10 14:13:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 13:13:23 -0600 (CST) Subject: [Scipy-svn] r2525 - trunk/Lib/sandbox/timeseries Message-ID: <20070110191323.D55D239C00F@new.scipy.org> Author: mattknox_ca Date: 2007-01-10 13:13:21 -0600 (Wed, 10 Jan 2007) New Revision: 2525 Modified: trunk/Lib/sandbox/timeseries/timeseries.py Log: modified convert method to reflect latest cseries code Modified: trunk/Lib/sandbox/timeseries/timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-10 19:12:24 UTC (rev 2524) +++ trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-10 19:13:21 UTC (rev 2525) @@ -201,6 +201,7 @@ _values = cRetVal['values'] _mask = cRetVal['mask'] + startIndex = cRetVal['startindex'] tempData = ma.array(_values) tempMask = ma.make_mask(_mask) @@ -208,14 +209,8 @@ if func is not None and tempData.ndim == 2: tempData = corelib.apply_along_axis(func, 1, tempData) - - startIndex = cseries.asfreq(numpy.asarray(int(self.start_date())), fromFreq, toFreq, 'BEFORE') - newStart = tsdate.Date(freq=toFreq, value=startIndex) - endIndex = cseries.asfreq(numpy.asarray(int(self.end_date())), fromFreq, toFreq, 'AFTER') - newEnd = tsdate.Date(freq=toFreq, value=endIndex) - - return adjust_endpoints(TimeSeries(tempData, freq=toFreq, observed=self.observed, start_date=startIndex), start_date=newStart, end_date=newEnd) + return TimeSeries(tempData, freq=toFreq, observed=self.observed, start_date=startIndex) else: return copytools.deepcopy(self) From scipy-svn at scipy.org Wed Jan 10 14:13:52 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 13:13:52 -0600 (CST) Subject: [Scipy-svn] r2526 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070110191352.7FC8F39C00F@new.scipy.org> Author: mattknox_ca Date: 2007-01-10 13:13:48 -0600 (Wed, 10 Jan 2007) New Revision: 2526 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: major overhaul Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-10 19:13:21 UTC (rev 2525) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-10 19:13:48 UTC (rev 2526) @@ -9,517 +9,616 @@ /////////////////////////////////////////////////////////////////////// +// helpers for frequency conversion routines // -static //PyArrayObject * -setArrayItem_1D(PyArrayObject **theArray, long index, PyObject *newVal) -{ - if (index >= 0) - { - //set value in array - PyArray_SETITEM(*theArray, PyArray_GetPtr(*theArray, &index), newVal); +static long DtoB_weekday(long fromDate) { return (((fromDate / 7) * 5) + fromDate%7); } + +static long DtoB_WeekendToMonday(mxDateTimeObject *dailyDate) { + + long absdate = dailyDate->absdate; + if (dailyDate->day_of_week > 4) { + //change to Monday after weekend + absdate += (7 - dailyDate->day_of_week); } - + return DtoB_weekday(absdate); } -static //PyArrayObject * -setArrayItem_2D(PyArrayObject **theArray, long index_x, long index_y, PyObject *newVal) -{ - long idx[] = {index_x, index_y}; +static long DtoB_WeekendToFriday(mxDateTimeObject *dailyDate) { - if (index_x >= 0 && index_y >= 0) { - //set value in array - PyArray_SETITEM(*theArray, PyArray_GetPtr(*theArray, idx), newVal); + long absdate = dailyDate->absdate; + if (dailyDate->day_of_week > 4) { + //change to friday before weekend + absdate -= (dailyDate->day_of_week - 4); } + return DtoB_weekday(absdate); +} +static long absdate_from_ymd(int y, int m, int d) { + mxDateTimeObject *tempDate; + long result; + + tempDate = (mxDateTimeObject *)mxDateTime.DateTime_FromDateAndTime(y,m,d,0,0,0); + result = (long)(tempDate->absdate); + Py_DECREF(tempDate); + return result; } -static int -freqVal(char freq) -{ - switch(freq) - { - case 'A': - //annual - return 1; - case 'Q': - //quarterly - return 2; - case 'M': - //monthly - return 3; - case 'B': - //business - return 4; - case 'D': - //daily - return 5; - default: - return 0; - } +static mxDateTimeObject *day_before_mxobj(int y, int m, int d) { + return (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(absdate_from_ymd(y, m, d) - 1, 0); } -static long -toDaily(long fromDate, char fromFreq) -{ - long absdate; - int y,m,d; +/* +returns Date(y, m, d) converted to business frequency. +If the initial result is a weekend, the following Monday is returned +*/ +static long busday_before(int y, int m, int d) { + mxDateTimeObject *dailyDate; + long result; - mxDateTimeObject *theDate; + dailyDate = (mxDateTimeObject *)mxDateTime.DateTime_FromDateAndTime(y,m,d,0,0,0); + result = DtoB_WeekendToMonday(dailyDate); - //convert fromDate to days since (0 AD - 1 day) - switch(fromFreq) - { - case 'D': - absdate = fromDate; - break; - case 'B': - absdate = ((fromDate-1)/5)*7 + (fromDate-1)%5 + 1; - break; - case 'M': - y = fromDate/12; - m = fromDate%12; + Py_DECREF(dailyDate); + return result; +} - if (m == 0) - { - m = 12; - y--; - } - d=1; - break; - case 'Q': - y = fromDate/4; - m = (fromDate%4) * 3 - 2; +/* +returns Date(y, m, d) - 1 converted to business frequency. +If the initial result is a weekend, the preceding Friday is returned +*/ +static long busday_after(int y, int m, int d) { + mxDateTimeObject *dailyDate; + long result; - if (m < 1) - { - m += 12; - y--; - } - else if (m == 12) - { - m = 1; - y++; - } - d=1; - break; - case 'A': - y = fromDate; - m = 1; - d = 1; - break; - default: - return -1; - } + dailyDate = day_before_mxobj(y,m,d); + result = DtoB_WeekendToFriday(dailyDate); - if (freqVal(fromFreq) < 4) - { - theDate = (mxDateTimeObject *)mxDateTime.DateTime_FromDateAndTime(y,m,d,0,0,0); - absdate = (long)(theDate->absdate); - } + Py_DECREF(dailyDate); + return result; +} - return absdate; +/////////////////////////////////////////////// +// frequency specifc conversion routines +// each function must take an integer fromDate and a char relation ('B' or 'A' for 'BEFORE' or 'AFTER') + +//************ FROM ANNUAL *************** + +static long asfreq_AtoQ(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 4 + 1; } + else { return (fromDate + 1) * 4; } } +static long asfreq_AtoM(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 12 + 1; } + else { return (fromDate + 1) * 12; } +} -static long -getDateInfo_sub(long dateNum, char freq, char info) { +static long asfreq_AtoW(long fromDate, char relation) { return 0; } - long monthNum; - mxDateTimeObject *convDate; - convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(toDaily(dateNum,freq),0); +static long asfreq_AtoB(long fromDate, char relation) { + if (relation == 'B') { return busday_before(fromDate,1,1); } + else { return busday_after(fromDate+1,1,1); } +} - switch(info) - { - case 'Y': //year +static long asfreq_AtoD(long fromDate, char relation) { + if (relation == 'B') { return absdate_from_ymd(fromDate,1,1); } + else { return absdate_from_ymd(fromDate+1,1,1) - 1; } +} - return (long)(convDate->year); +static long asfreq_AtoH(long fromDate, char relation) { return 0; } +static long asfreq_AtoT(long fromDate, char relation) { return 0; } +static long asfreq_AtoS(long fromDate, char relation) { return 0; } - case 'Q': //quarter - monthNum = (long)(convDate->month); - return ((monthNum-1)/3)+1; - case 'M': //month - return (long)(convDate->month); +//************ FROM QUARTERLY *************** - case 'D': //day - return (long)(convDate->day); +static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1) / 4; } - case 'W': //day of week - return (long)(convDate->day_of_week); - default: - return -1; +static long asfreq_QtoM(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 3 - 2; } + else { return fromDate * 3; } +} + +static long asfreq_QtoW(long fromDate, char relation) { return 0; } + +static void QtoD_ym(long fromDate, long *y, long *m) { + *y = (fromDate - 1) / 4; + *m = fromDate * 3 - 12 * (*y) - 2; +} + +static long asfreq_QtoB(long fromDate, char relation) { + + long y, m; + + if (relation == 'B') { + QtoD_ym(fromDate, &y, &m); + return busday_before(y,m,1); + } else { + QtoD_ym(fromDate+1, &y, &m); + return busday_after(y, m, 1); } } +static long asfreq_QtoD(long fromDate, char relation) { -static char cseries_getDateInfo_doc[] = ""; -static PyObject * -cseries_getDateInfo(PyObject *self, PyObject *args) -{ - char *freq; - char *info; + long y, m; - PyArrayObject *array; - PyArrayObject *tempArray; - PyArrayObject *newArray; + if (relation == 'B') { + QtoD_ym(fromDate, &y, &m); + return absdate_from_ymd(y, m, 1); + } else { + QtoD_ym(fromDate+1, &y, &m); + return absdate_from_ymd(y, m, 1) - 1; + } +} - char *getptr; - PyObject *val; - long i, lngVal, dInfo, dim; +static long asfreq_QtoH(long fromDate, char relation) { return 0; } +static long asfreq_QtoT(long fromDate, char relation) { return 0; } +static long asfreq_QtoS(long fromDate, char relation) { return 0; } - if (!PyArg_ParseTuple(args, "Oss:getDateInfo(array, freq, info)", &tempArray, &freq, &info)) return NULL; - array = PyArray_GETCONTIGUOUS(tempArray); +//************ FROM MONTHLY *************** - dim = array->dimensions[0]; +static long asfreq_MtoA(long fromDate, char relation) { return (fromDate - 1) / 12; } +static long asfreq_MtoQ(long fromDate, char relation) { return (fromDate - 1) / 3 + 1; } - //initialize new array - newArray = (PyArrayObject*)PyArray_SimpleNew(array->nd, &dim, array->descr->type_num); +static long asfreq_MtoW(long fromDate, char relation) { return 0; } - for (i = 0; i < array->dimensions[0]; i++) - { - getptr = array->data + i*array->strides[0]; - val = PyArray_GETITEM(array, getptr); - lngVal = PyInt_AsLong(val); - dInfo = getDateInfo_sub(lngVal, *freq, *info); +static void MtoD_ym(long fromDate, long *y, long *m) { + *y = (fromDate - 1) / 12; + *m = fromDate - 12 * (*y); +} - setArrayItem_1D(&newArray, i, PyInt_FromLong(dInfo)); +static long asfreq_MtoB(long fromDate, char relation) { + + long y, m; + + if (relation == 'B') { + MtoD_ym(fromDate, &y, &m); + return busday_before(y,m,1); + } else { + MtoD_ym(fromDate+1, &y, &m); + return busday_after(y, m, 1); } +} - return (PyObject *) newArray; +static long asfreq_MtoD(long fromDate, char relation) { + long y, m; + + if (relation == 'B') { + MtoD_ym(fromDate, &y, &m); + return absdate_from_ymd(y, m, 1); + } else { + MtoD_ym(fromDate+1, &y, &m); + return absdate_from_ymd(y, m, 1) - 1; + } } +static long asfreq_MtoH(long fromDate, char relation) { return 0; } +static long asfreq_MtoT(long fromDate, char relation) { return 0; } +static long asfreq_MtoS(long fromDate, char relation) { return 0; } -/* -convert fromDate to a date at toFreq according to relation -*/ -static long -asfreq(long fromDate, char fromFreq, char toFreq, char relation) -{ - long absdate, secsInDay; - long converted; - int y,m, doAfter; - mxDateTimeObject *convDate; +//************ FROM WEEKLY *************** - secsInDay = 86400; - doAfter = 0; +static long asfreq_WtoA(long fromDate, char relation) { return 0; } +static long asfreq_WtoQ(long fromDate, char relation) { return 0; } +static long asfreq_WtoM(long fromDate, char relation) { return 0; } +static long asfreq_WtoB(long fromDate, char relation) { return 0; } +static long asfreq_WtoD(long fromDate, char relation) { return 0; } +static long asfreq_WtoH(long fromDate, char relation) { return 0; } +static long asfreq_WtoT(long fromDate, char relation) { return 0; } +static long asfreq_WtoS(long fromDate, char relation) { return 0; } - if (relation == 'A') { - switch(fromFreq) - { - case 'D': //daily +//************ FROM DAILY *************** - switch(toFreq) - { - case 'A': - break; - case 'Q': - break; - case 'M': - break; - case 'B': - break; - default: - doAfter = 1; - break; - } - break; +static long asfreq_DtoA(long fromDate, char relation) { + mxDateTimeObject *mxDate; + long result; - case 'B': //business + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); + result = (long)(mxDate->year); + Py_DECREF(mxDate); + return result; +} - switch(toFreq) - { - case 'A': - break; - case 'Q': - break; - case 'M': - break; - case 'D': - break; - default: - doAfter = 1; - break; - } - break; +static long asfreq_DtoQ(long fromDate, char relation) { - case 'M': //monthly + mxDateTimeObject *mxDate; + long result; - switch(toFreq) - { - case 'A': - break; - case 'Q': - break; - default: - doAfter = 1; - break; - } - break; + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); + result = (long)((mxDate->year) * 4 + (mxDate->month-1)/3 + 1); + Py_DECREF(mxDate); + return result; +} - case 'Q': //quarterly +static long asfreq_DtoM(long fromDate, char relation) { + mxDateTimeObject *mxDate; + long result; - switch(toFreq) - { - case 'A': - break; - default: - doAfter = 1; - break; - } - break; + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); + result = (long)((mxDate->year) * 12 + mxDate->month); + Py_DECREF(mxDate); + return result; +} - case 'A': //annual - doAfter = 1; - break; - } +static long asfreq_DtoW(long fromDate, char relation) { return 0; } - } +static long asfreq_DtoB(long fromDate, char relation) { + mxDateTimeObject *mxDate; + long result; - if (doAfter) { - absdate = toDaily(fromDate + 1, fromFreq); + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); + if (relation == 'B') { + result = DtoB_WeekendToFriday(mxDate); } else { - absdate = toDaily(fromDate, fromFreq); + result = DtoB_WeekendToMonday(mxDate); } - convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(absdate,0); + Py_DECREF(mxDate); + return result; +} - y = convDate->year; - m = convDate->month; +static long asfreq_DtoB_forConvert(long fromDate, char relation) { + mxDateTimeObject *mxDate; + long result; - //convert convDate to appropriate # of periods according to toFreq - switch(toFreq) - { - case 'D': - converted = absdate; - break; - case 'B': - if (convDate->day_of_week > 4) //is weekend day - { - if (fromFreq == 'D' && relation == 'B') { - //change to friday before weekend - absdate -= (convDate->day_of_week - 4); - } else { - //change to Monday after weekend - absdate += (7 - convDate->day_of_week); - } - } - //converted = (long)((absdate / 7 * 5.0) + absdate%7); - converted = (long)((absdate / 7 * 5.0) + absdate%7); - break; - case 'M': - converted = (long)(y*12 + m); - break; - case 'Q': - converted = (long)(y*4 + ((m-1)/3) + 1); - break; - case 'A': - converted = (long)(y); - break; - default: - return -1; - } + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); - if (doAfter) { - return converted-1; + if (mxDate->day_of_week > 4) { + result = -1; } else { - return converted; + result = DtoB_weekday(mxDate->absdate); } + + Py_DECREF(mxDate); + return result; } -/* -for use internally by the convert function. Same as the asfreq function, -except going from daily to business returns -1 always if fromDate is on -a weekend -*/ -static long -asfreq_forseries(long fromDate, char fromFreq, char toFreq, char relation) -{ - mxDateTimeObject *convDate; +static long asfreq_DtoH(long fromDate, char relation) { return 0; } +static long asfreq_DtoT(long fromDate, char relation) { return 0; } +static long asfreq_DtoS(long fromDate, char relation) { return 0; } - if (fromFreq == 'D' && toFreq == 'B') { - convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate,0); - if (convDate->day_of_week > 4) //is weekend day - { - return -1; - } - } +//************ FROM BUSINESS *************** - return asfreq(fromDate, fromFreq, toFreq, relation); -} +static long asfreq_BtoD(long fromDate, char relation) { + return ((fromDate-1)/5)*7 + (fromDate-1)%5 + 1; } -static int validFreq(char freq) { - switch(freq) +static long asfreq_BtoA(long fromDate, char relation) { + return asfreq_DtoA(asfreq_BtoD(fromDate, relation), relation); } + +static long asfreq_BtoQ(long fromDate, char relation) { + return asfreq_DtoQ(asfreq_BtoD(fromDate, relation), relation); } + +static long asfreq_BtoM(long fromDate, char relation) { + return asfreq_DtoM(asfreq_BtoD(fromDate, relation), relation); } + +static long asfreq_BtoW(long fromDate, char relation) { + return asfreq_DtoW(asfreq_BtoD(fromDate, relation), relation); } + +static long asfreq_BtoH(long fromDate, char relation) { + return asfreq_DtoH(asfreq_BtoD(fromDate, relation), relation); } + +static long asfreq_BtoT(long fromDate, char relation) { + return asfreq_DtoT(asfreq_BtoD(fromDate, relation), relation); } + +static long asfreq_BtoS(long fromDate, char relation) { + return asfreq_DtoS(asfreq_BtoD(fromDate, relation), relation); } + +//************ FROM HOURLY *************** + +static long asfreq_HtoA(long fromDate, char relation) { return 0; } +static long asfreq_HtoQ(long fromDate, char relation) { return 0; } +static long asfreq_HtoM(long fromDate, char relation) { return 0; } +static long asfreq_HtoW(long fromDate, char relation) { return 0; } +static long asfreq_HtoB(long fromDate, char relation) { return 0; } +static long asfreq_HtoB_forConvert(long fromDate, char relation) { return 0; } +static long asfreq_HtoD(long fromDate, char relation) { return 0; } +static long asfreq_HtoT(long fromDate, char relation) { return 0; } +static long asfreq_HtoS(long fromDate, char relation) { return 0; } + +//************ FROM MINUTELY *************** + +static long asfreq_TtoA(long fromDate, char relation) { return 0; } +static long asfreq_TtoQ(long fromDate, char relation) { return 0; } +static long asfreq_TtoM(long fromDate, char relation) { return 0; } +static long asfreq_TtoW(long fromDate, char relation) { return 0; } +static long asfreq_TtoB(long fromDate, char relation) { return 0; } +static long asfreq_TtoB_forConvert(long fromDate, char relation) { return 0; } +static long asfreq_TtoD(long fromDate, char relation) { return 0; } +static long asfreq_TtoH(long fromDate, char relation) { return 0; } +static long asfreq_TtoS(long fromDate, char relation) { return 0; } + +//************ FROM SECONDLY *************** + +static long asfreq_StoA(long fromDate, char relation) { return 0; } +static long asfreq_StoQ(long fromDate, char relation) { return 0; } +static long asfreq_StoM(long fromDate, char relation) { return 0; } +static long asfreq_StoW(long fromDate, char relation) { return 0; } +static long asfreq_StoB(long fromDate, char relation) { return 0; } +static long asfreq_StoB_forConvert(long fromDate, char relation) { return 0; } +static long asfreq_StoD(long fromDate, char relation) { return 0; } +static long asfreq_StoH(long fromDate, char relation) { return 0; } +static long asfreq_StoT(long fromDate, char relation) { return 0; } + +static long nofunc(long fromDate, char relation) { return -1; } + +// end of frequency specific conversion routines + +// return a pointer to appropriate conversion function +static long (*get_asfreq_func(char fromFreq, char toFreq, int forConvert))(long, char) { + + switch(fromFreq) { case 'A': - return 1; + switch(toFreq) + { + case 'Q': return &asfreq_AtoQ; + case 'M': return &asfreq_AtoM; + case 'W': return &asfreq_AtoW; + case 'B': return &asfreq_AtoB; + case 'D': return &asfreq_AtoD; + case 'H': return &asfreq_AtoH; + case 'T': return &asfreq_AtoT; + case 'S': return &asfreq_AtoS; + default: return &nofunc; + } + case 'Q': - return 1; + switch(toFreq) + { + case 'A': return &asfreq_QtoA; + case 'M': return &asfreq_QtoM; + case 'W': return &asfreq_QtoW; + case 'B': return &asfreq_QtoB; + case 'D': return &asfreq_QtoD; + case 'H': return &asfreq_QtoH; + case 'T': return &asfreq_QtoT; + case 'S': return &asfreq_QtoS; + default: return &nofunc; + } + case 'M': - return 1; + switch(toFreq) + { + case 'A': return &asfreq_MtoA; + case 'Q': return &asfreq_MtoQ; + case 'W': return &asfreq_MtoW; + case 'B': return &asfreq_MtoB; + case 'D': return &asfreq_MtoD; + case 'H': return &asfreq_MtoH; + case 'T': return &asfreq_MtoT; + case 'S': return &asfreq_MtoS; + default: return &nofunc; + } + + case 'W': + switch(toFreq) + { + case 'A': return &asfreq_WtoA; + case 'Q': return &asfreq_WtoQ; + case 'M': return &asfreq_WtoM; + case 'B': return &asfreq_WtoB; + case 'D': return &asfreq_WtoD; + case 'H': return &asfreq_WtoH; + case 'T': return &asfreq_WtoT; + case 'S': return &asfreq_WtoS; + default: return &nofunc; + } + case 'B': - return 1; + switch(toFreq) + { + case 'A': return &asfreq_BtoA; + case 'Q': return &asfreq_BtoQ; + case 'M': return &asfreq_BtoM; + case 'W': return &asfreq_BtoW; + case 'D': return &asfreq_BtoD; + case 'H': return &asfreq_BtoH; + case 'T': return &asfreq_BtoT; + case 'S': return &asfreq_BtoS; + default: return &nofunc; + } + case 'D': - return 1; - default: - return 0; + switch(toFreq) + { + case 'A': return &asfreq_DtoA; + case 'Q': return &asfreq_DtoQ; + case 'M': return &asfreq_DtoM; + case 'W': return &asfreq_DtoW; + case 'B': + if (forConvert) { return &asfreq_DtoB_forConvert; } + else { return &asfreq_DtoB; } + case 'H': return &asfreq_DtoH; + case 'T': return &asfreq_DtoT; + case 'S': return &asfreq_DtoS; + default: return &nofunc; + } + + case 'H': + switch(toFreq) + { + case 'A': return &asfreq_HtoA; + case 'Q': return &asfreq_HtoQ; + case 'M': return &asfreq_HtoM; + case 'W': return &asfreq_HtoW; + case 'B': + if (forConvert) { return &asfreq_HtoB_forConvert; } + else { return &asfreq_HtoB; } + case 'D': return &asfreq_HtoD; + case 'T': return &asfreq_HtoT; + case 'S': return &asfreq_HtoS; + default: return &nofunc; + } + + case 'T': + switch(toFreq) + { + case 'A': return &asfreq_TtoA; + case 'Q': return &asfreq_TtoQ; + case 'M': return &asfreq_TtoM; + case 'W': return &asfreq_TtoW; + case 'B': + if (forConvert) { return &asfreq_TtoB_forConvert; } + else { return &asfreq_TtoB; } + case 'D': return &asfreq_TtoD; + case 'H': return &asfreq_TtoH; + case 'S': return &asfreq_TtoS; + default: return &nofunc; + } + + case 'S': + switch(toFreq) + { + case 'A': return &asfreq_StoA; + case 'Q': return &asfreq_StoQ; + case 'M': return &asfreq_StoM; + case 'W': return &asfreq_StoW; + case 'B': + if (forConvert) { return &asfreq_StoB_forConvert; } + else { return &asfreq_StoB; } + case 'D': return &asfreq_StoD; + case 'H': return &asfreq_StoH; + case 'T': return &asfreq_StoT; + default: return &nofunc; + } + default: return &nofunc; } } +static long dInfo_year(mxDateTimeObject *dateObj) { return dateObj->year; } +static long dInfo_quarter(mxDateTimeObject *dateObj) { return ((dateObj->month-1)/3)+1; } +static long dInfo_month(mxDateTimeObject *dateObj) { return dateObj->month; } +static long dInfo_day(mxDateTimeObject *dateObj) { return dateObj->day; } +static long dInfo_dow(mxDateTimeObject *dateObj) { return dateObj->day_of_week; } -static int -expand(long oldSize, char fromFreq, char toFreq, long *newLen, long *newHeight) +static char cseries_getDateInfo_doc[] = ""; +static PyObject * +cseries_getDateInfo(PyObject *self, PyObject *args) { + char *freq; + char *info; - int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; - int minBusDaysPerYear, minBusDaysPerQuarter, minBusDaysPerMonth; + PyArrayObject *array; + PyArrayObject *newArray; + PyArrayIterObject *iterSource, *iterResult; + mxDateTimeObject *convDate; - int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; - int minDaysPerYear, minDaysPerQuarter, minDaysPerMonth; + PyObject *val; + long dateNum, dInfo; - minBusDaysPerYear = 260; maxBusDaysPerYear = 262; - minBusDaysPerQuarter = 64; maxBusDaysPerQuarter = 66; - minBusDaysPerMonth = 20; maxBusDaysPerMonth = 23; + long (*toDaily)(long, char) = NULL; + long (*getDateInfo)(mxDateTimeObject*) = NULL; - minDaysPerYear = 365; maxDaysPerYear = 366; - minDaysPerQuarter = 90; maxDaysPerQuarter = 92; - minDaysPerMonth = 28; maxDaysPerMonth = 31; + if (!PyArg_ParseTuple(args, "Oss:getDateInfo(array, freq, info)", &array, &freq, &info)) return NULL; + newArray = (PyArrayObject *)PyArray_Copy(array); - if (!validFreq(fromFreq)) return 0; - if (!validFreq(toFreq)) return 0; + iterSource = (PyArrayIterObject *)PyArray_IterNew((PyObject *)array); + iterResult = (PyArrayIterObject *)PyArray_IterNew((PyObject *)newArray); - if (fromFreq == toFreq) { - *newLen = oldSize; - *newHeight = 1; - } else { + toDaily = get_asfreq_func(*freq, 'D', 0); - switch(fromFreq) - { - case 'A': //annual + switch(*info) + { + case 'Y': //year + getDateInfo = &dInfo_year; + break; + case 'Q': //quarter + getDateInfo = &dInfo_quarter; + break; + case 'M': //month + getDateInfo = &dInfo_month; + break; + case 'D': //day + getDateInfo = &dInfo_day; + break; + case 'W': //day of week + getDateInfo = &dInfo_dow; + break; + default: + return NULL; + } - switch(toFreq) - { - case 'Q': - *newLen = oldSize * 4; - *newHeight = 1; - break; - case 'M': - *newLen = oldSize * 12; - *newHeight = 1; - break; - case 'B': - *newLen = oldSize * maxBusDaysPerYear; - *newHeight = 1; - break; - case 'D': - *newLen = oldSize * maxDaysPerYear; - *newHeight = 1; - break; - } - break; + while (iterSource->index < iterSource->size) { - case 'Q': //quarterly + val = PyArray_GETITEM(array, iterSource->dataptr); + dateNum = PyInt_AsLong(val); - switch(toFreq) - { - case 'A': - *newLen = (oldSize / 4) + 2; - *newHeight = 4; - break; - case 'M': - *newLen = oldSize * 3; - *newHeight = 1; - break; - case 'B': - *newLen = oldSize * maxBusDaysPerQuarter; - *newHeight = 1; - break; - case 'D': - *newLen = oldSize * maxDaysPerQuarter; - *newHeight = 1; - break; - } - break; + convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(toDaily(dateNum, 'A'), 0); + dInfo = getDateInfo(convDate); + Py_DECREF(convDate); - case 'M': //monthly + PyArray_SETITEM(newArray, iterResult->dataptr, PyInt_FromLong(dInfo)); - switch(toFreq) - { - case 'A': - *newLen = (oldSize / 12) + 2; - *newHeight = 12; - break; - case 'Q': - *newLen = (oldSize / 3) + 2; - *newHeight = 3; - break; - case 'B': - *newLen = oldSize * maxBusDaysPerMonth; - *newHeight = 1; - break; - case 'D': - *newLen = oldSize * maxDaysPerMonth; - *newHeight = 1; - break; - } - break; + PyArray_ITER_NEXT(iterSource); + PyArray_ITER_NEXT(iterResult); + } - case 'B': //business + Py_DECREF(iterSource); + Py_DECREF(iterResult); - switch(toFreq) - { - case 'A': - *newLen = (oldSize / minBusDaysPerYear) + 2; - *newHeight = maxBusDaysPerYear; - break; - case 'Q': - *newLen = (oldSize / minBusDaysPerQuarter) + 2; - *newHeight = maxBusDaysPerQuarter; - break; - case 'M': - *newLen = (oldSize / minBusDaysPerMonth) + 2; - *newHeight = maxBusDaysPerMonth; - break; - case 'D': - *newLen = ((7 * oldSize)/5) + 2; - *newHeight = 1; - break; - } - break; + return (PyObject *) newArray; - case 'D': //daily +} - switch(toFreq) - { - case 'A': - *newLen = (oldSize / minDaysPerYear) + 2; - *newHeight = maxDaysPerYear; - break; - case 'Q': - *newLen = (oldSize / minDaysPerQuarter) + 2; - *newHeight = maxDaysPerQuarter; - break; - case 'M': - *newLen = (oldSize / minDaysPerMonth) + 2; - *newHeight = maxDaysPerMonth; - break; - case 'B': - *newLen = ((5 * oldSize)/7) + 2; - *newHeight = 1; - break; } - break; - } - } - return 1; +static long get_height(char fromFreq, char toFreq) { + int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; + int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; + + maxBusDaysPerYear = 262; + maxBusDaysPerQuarter = 66; + maxBusDaysPerMonth = 23; + + maxDaysPerYear = 366; + maxDaysPerQuarter = 92; + maxDaysPerMonth = 31; + + switch(fromFreq) + { + case 'A': return 1; + case 'Q': + switch(toFreq) + { + case 'A': return 4; + default: return 1; + } + case 'M': //monthly + switch(toFreq) + { + case 'A': return 12; + case 'Q': return 3; + default: return 1; + } + case 'B': //business + switch(toFreq) + { + case 'A': return maxBusDaysPerYear;; + case 'Q': return maxBusDaysPerQuarter; + case 'M': return maxBusDaysPerMonth; + case 'W': return 5; + default: return 1; + } + case 'D': //daily + switch(toFreq) + { + case 'A': return maxDaysPerYear;; + case 'Q': return maxDaysPerQuarter; + case 'M': return maxDaysPerMonth; + case 'W': return 7; + default: return 1; + } + default: return 1; + } } @@ -527,39 +626,37 @@ static PyObject * cseries_convert(PyObject *self, PyObject *args) { - PyArrayObject *array; - PyArrayObject *tempArray; - PyArrayObject *newArray; + PyArrayObject *array, *newArray; + PyArrayObject *mask, *newMask; - PyArrayObject *mask; - PyArrayObject *tempMask; - PyArrayObject *newMask; - PyObject *returnVal = NULL; - long startIndex, newStart, newStartYaxis; + long startIndex; + long newStart, newStartTemp; + long newEnd, newEndTemp; long newLen, newHeight; long i, currIndex, prevIndex; long nd; - long *dim; + npy_intp *dim, *newIdx; long currPerLen; char *fromFreq, *toFreq, *position; char relation; PyObject *val, *valMask; - int toFrVal, fromFrVal; + long (*asfreq_main)(long, char) = NULL; + long (*asfreq_endpoints)(long, char) = NULL; + long (*asfreq_reverse)(long, char) = NULL; returnVal = PyDict_New(); - if (!PyArg_ParseTuple(args, "OssslO:convert(array, fromfreq, tofreq, position, startIndex, mask)", &tempArray, &fromFreq, &toFreq, &position, &startIndex, &tempMask)) return NULL; + if (!PyArg_ParseTuple(args, "OssslO:convert(array, fromfreq, tofreq, position, startIndex, mask)", &array, &fromFreq, &toFreq, &position, &startIndex, &mask)) return NULL; if (toFreq[0] == fromFreq[0]) { + PyDict_SetItemString(returnVal, "values", (PyObject*)array); + PyDict_SetItemString(returnVal, "mask", (PyObject*)mask); - PyDict_SetItemString(returnVal, "values", (PyObject*)tempArray); - PyDict_SetItemString(returnVal, "mask", (PyObject*)tempMask); - return returnVal; } @@ -578,60 +675,57 @@ break; } - //get frequency numeric mapping - fromFrVal = freqVal(fromFreq[0]); - toFrVal = freqVal(toFreq[0]); + asfreq_main = get_asfreq_func(fromFreq[0], toFreq[0], 1); + asfreq_endpoints = get_asfreq_func(fromFreq[0], toFreq[0], 0); - array = PyArray_GETCONTIGUOUS(tempArray); - mask = PyArray_GETCONTIGUOUS(tempMask); + //convert start index to new frequency + newStartTemp = asfreq_main(startIndex, 'B'); + if (newStartTemp == -1) { newStart = asfreq_endpoints(startIndex, 'A'); } + else { newStart = newStartTemp; } - //expand size to fit new values if needed - if (!expand(array->dimensions[0], fromFreq[0], toFreq[0], &newLen, &newHeight)) return NULL; + //convert end index to new frequency + newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A'); + if (newEndTemp == -1) { newEnd = asfreq_endpoints(startIndex, 'B'); } + else { newEnd = newEndTemp; } - //convert start index to new frequency - newStart = asfreq(startIndex, fromFreq[0], toFreq[0], 'B'); + newLen = newEnd - newStart + 1; + newHeight = get_height(fromFreq[0], toFreq[0]); if (newHeight > 1) { - newStartYaxis = startIndex - asfreq(newStart, toFreq[0], fromFreq[0], 'B'); - currPerLen = newStartYaxis; + asfreq_reverse = get_asfreq_func(toFreq[0], fromFreq[0], 0); + currPerLen = startIndex - asfreq_reverse(newStart, 'B'); nd = 2; - dim = malloc(nd * sizeof(int)); + dim = PyDimMem_NEW(nd); dim[0] = newLen; dim[1] = newHeight; } else { - currPerLen = 0; nd = 1; - dim = malloc(nd * sizeof(int)); + dim = PyDimMem_NEW(nd); dim[0] = newLen; } + newIdx = PyDimMem_NEW(nd); newArray = (PyArrayObject*)PyArray_SimpleNew(nd, dim, array->descr->type_num); newMask = (PyArrayObject*)PyArray_SimpleNew(nd, dim, mask->descr->type_num); - free(dim); + PyDimMem_FREE(dim); PyArray_FILLWBYTE(newArray,0); PyArray_FILLWBYTE(newMask,1); - //initialize prevIndex prevIndex = newStart; //set values in the new array - for (i = 0; i < array->dimensions[0]; i++) - { + for (i = 0; i < array->dimensions[0]; i++) { - //get value from old array val = PyArray_GETITEM(array, PyArray_GetPtr(array, &i)); - - //get the mask corresponding to the old value valMask = PyArray_GETITEM(mask, PyArray_GetPtr(mask, &i)); - //find index for start of current period in new frequency - currIndex = asfreq_forseries(startIndex + i, fromFreq[0], toFreq[0], relation); + currIndex = asfreq_main(startIndex + i, relation); + newIdx[0] = currIndex-newStart; - if (newHeight > 1) { if (currIndex != prevIndex) @@ -641,23 +735,24 @@ prevIndex = currIndex; } - //set value in the new array - setArrayItem_2D(&newArray, currIndex-newStart, currPerLen, val); - setArrayItem_2D(&newMask, currIndex-newStart, currPerLen, valMask); - + newIdx[1] = currPerLen; currPerLen++; + } - } else { - - setArrayItem_1D(&newArray, currIndex-newStart, val); - setArrayItem_1D(&newMask, currIndex-newStart, valMask); - + if (newIdx[0] > -1) { + PyArray_SETITEM(newArray, PyArray_GetPtr(newArray, newIdx), val); + PyArray_SETITEM(newMask, PyArray_GetPtr(newMask, newIdx), valMask); } + Py_DECREF(val); + Py_DECREF(valMask); } + PyDimMem_FREE(newIdx); + PyDict_SetItemString(returnVal, "values", (PyObject*)newArray); PyDict_SetItemString(returnVal, "mask", (PyObject*)newMask); + PyDict_SetItemString(returnVal, "startindex", (PyObject*)PyInt_FromLong(newStart)); return returnVal; @@ -673,9 +768,12 @@ PyObject *fromDateObj, *toDateObj; char *fromFreq, *toFreq, *relation; long fromDate, toDate; + long (*asfreq_main)(long, char) = NULL; if (!PyArg_ParseTuple(args, "Osss:asfreq(fromDates, fromfreq, tofreq, relation)", &fromDates, &fromFreq, &toFreq, &relation)) return NULL; + asfreq_main = get_asfreq_func(fromFreq[0], toFreq[0], 0); + toDates = (PyArrayObject *)PyArray_Copy(fromDates); iterFrom = (PyArrayIterObject *)PyArray_IterNew((PyObject *)fromDates); @@ -688,15 +786,21 @@ fromDateObj = PyArray_GETITEM(fromDates, iterFrom->dataptr); fromDate = PyInt_AsLong(fromDateObj); - toDate = asfreq(fromDate, fromFreq[0], toFreq[0], relation[0]); + toDate = asfreq_main(fromDate, relation[0]); toDateObj = PyInt_FromLong(toDate); PyArray_SETITEM(toDates, iterTo->dataptr, toDateObj); + Py_DECREF(fromDateObj); + Py_DECREF(toDateObj); + PyArray_ITER_NEXT(iterFrom); PyArray_ITER_NEXT(iterTo); } + Py_DECREF(iterFrom); + Py_DECREF(iterTo); + return (PyObject *)toDates; } From scipy-svn at scipy.org Wed Jan 10 17:29:18 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 16:29:18 -0600 (CST) Subject: [Scipy-svn] r2527 - trunk/Lib/sandbox/maskedarray Message-ID: <20070110222918.4224F39C03A@new.scipy.org> Author: pierregm Date: 2007-01-10 16:29:16 -0600 (Wed, 10 Jan 2007) New Revision: 2527 Modified: trunk/Lib/sandbox/maskedarray/mrecords.py Log: Corrected a bug w/ missingchar in fromtextfile Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-10 19:13:48 UTC (rev 2526) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-10 22:29:16 UTC (rev 2527) @@ -447,7 +447,7 @@ if isinstance(reclist, recarray): arrlist = [reclist.field(i) for i in range(len(reclist.dtype))] if names is None: - names = nrec.dtype.names + names = reclist.dtype.names else: obj = numeric.array(reclist,dtype=object) arrlist = [numeric.array(obj[...,i].tolist()) @@ -568,7 +568,7 @@ line = f.readline() firstline = line[:line.find(commentchar)].strip() _varnames = firstline.split(delimitor) - print "_VARNAMES:%s-"%_varnames, len(_varnames) + logging.debug("_VARNAMES:%s-%s"% (_varnames,len(_varnames))) if len(_varnames) > 1: break if varnames is None: @@ -593,7 +593,7 @@ mdescr = [(n,f) for (n,f) in zip(varnames, vartypes)] # Get the data and the mask ................. # We just need a list of masked_arrays. It's easier to create it like that: - _mask = (_variables.T == '') + _mask = (_variables.T == missingchar) _datalist = [masked_array(a,mask=m,dtype=t) for (a,m,t) in zip(_variables.T, _mask, vartypes)] return fromarrays(_datalist, dtype=mdescr) From scipy-svn at scipy.org Wed Jan 10 20:03:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 19:03:28 -0600 (CST) Subject: [Scipy-svn] r2528 - trunk/Lib/sandbox/maskedarray Message-ID: <20070111010328.9CFA139C069@new.scipy.org> Author: pierregm Date: 2007-01-10 19:03:26 -0600 (Wed, 10 Jan 2007) New Revision: 2528 Modified: trunk/Lib/sandbox/maskedarray/mrecords.py Log: Commented out the logging statements in mrecords Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-10 22:29:16 UTC (rev 2527) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-11 01:03:26 UTC (rev 2528) @@ -28,18 +28,13 @@ _typestr = ntypes._typestr import maskedarray as MA -reload(MA) -filled = MA.filled -getmaskarray = MA.getmaskarray -masked = MA.masked -nomask = MA.nomask -mask_or = MA.mask_or -masked_array = MA.masked_array +#reload(MA) +from maskedarray import masked, nomask, mask_or, filled, getmaskarray, masked_array import warnings -import logging -logging.basicConfig(level=logging.DEBUG, - format='%(name)-15s %(levelname)s %(message)s',) +#import logging +#logging.basicConfig(level=logging.DEBUG, +# format='%(name)-15s %(levelname)s %(message)s',) class mrecarray(ndarray): @@ -85,7 +80,7 @@ def __getallfields(self,fieldname): """Returns all the fields sharing the same fieldname base. The fieldname base is either `_data` or `_mask`.""" - logging.debug('__getallfields(%s)' % fieldname) +# logging.debug('__getallfields(%s)' % fieldname) (names, formats, offsets, objs) = ([], [], [], []) fkeyname = '%%s%s' % fieldname for s in self._mrecarray__globalfdict.keys(): @@ -154,7 +149,7 @@ func = ndarray.__getattribute__(self,'_mrecarray__getallfields') return func.__call__('_mask') elif attr == '_mask': - logging.debug('__getattribute__: all fields %s' % attr) +# logging.debug('__getattribute__: all fields %s' % attr) func = ndarray.__getattribute__(self,'_getmask') return func.__call__() # Case #6: attr is not a field at all ! @@ -215,21 +210,21 @@ # func = ndarray.__getattribute__(self,'_mrecarray__getallfields') # return func.__call__('_mask') elif attr == '_mask': - logging.debug(" setattr _mask to %s [%s]" % (val,(val is nomask))) +# logging.debug(" setattr _mask to %s [%s]" % (val,(val is nomask))) if self._hardmask: - logging.debug("setattr: object has hardmask") +# logging.debug("setattr: object has hardmask") if val is not nomask: mval = getmaskarray(val) for k in gdict.keys(): fkey = fdict["%s_mask" % k ][:2] m = mask_or(mval, self.getfield(*fkey)) - logging.debug("setattr: set %s to %s" % (k,m)) +# logging.debug("setattr: set %s to %s" % (k,m)) self.setfield(m, *fkey) else: mval = getmaskarray(val) for k in gdict.keys(): self.setfield(mval, *fdict["%s_mask" % k ][:2]) - logging.debug('__getattribute__: all fields %s' % attr) +# logging.debug('__getattribute__: all fields %s' % attr) return # func = ndarray.__getattribute__(self,'_getmask') # return func.__call__() @@ -237,7 +232,7 @@ #...................................................... def __getitem__(self, indx): - logging.debug('__getitem__ got %s' % indx) +# logging.debug('__getitem__ got %s' % indx) try: obj = ndarray.__getitem__(self, indx) except ValueError: @@ -284,7 +279,7 @@ """Returns a view of the mrecarray.""" try: if issubclass(obj, ndarray): - logging.debug('direct view as %s' % obj) +# logging.debug('direct view as %s' % obj) return ndarray.view(self, obj) except TypeError: pass @@ -363,8 +358,7 @@ formats += `obj.itemsize` formats += ',' formats = formats[:-1] - - logging.debug("fromarrays: formats",formats) +# logging.debug("fromarrays: formats",formats) # Define the dtype .......................... if dtype is not None: descr = numeric.dtype(dtype) @@ -394,10 +388,10 @@ _names = mdescr.names # Populate the record array (makes a copy) for i in range(len(arraylist)): - logging.debug("fromarrays: i:%i-%s/%s" % \ - (i, arraylist[i]._data, MA.getmaskarray(arraylist[i]))) - logging.debug("fromarrays: i:%i-%s/%s" % \ - (i,_names[2*i], _names[2*i+1])) +# logging.debug("fromarrays: i:%i-%s/%s" % \ +# (i, arraylist[i]._data, MA.getmaskarray(arraylist[i]))) +# logging.debug("fromarrays: i:%i-%s/%s" % \ +# (i,_names[2*i], _names[2*i+1])) _array[_names[2*i]] = arraylist[i]._data _array[_names[2*i+1]] = getmaskarray(arraylist[i]) return _array @@ -512,7 +506,6 @@ try: val = complex(f) except ValueError: - print "str_!" vartypes.append(arr.dtype) else: vartypes.append(complex_) From scipy-svn at scipy.org Wed Jan 10 23:23:29 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 10 Jan 2007 22:23:29 -0600 (CST) Subject: [Scipy-svn] r2529 - in trunk/Lib: . fftpack fftpack/tests integrate integrate/tests interpolate interpolate/tests io io/tests lib lib/blas lib/blas/tests lib/lapack lib/lapack/tests linalg linalg/tests linsolve linsolve/umfpack linsolve/umfpack/tests maxentropy maxentropy/tests misc ndimage ndimage/tests optimize optimize/tests sandbox/arpack/tests sandbox/arraysetops/tests sandbox/cdavid/tests sandbox/exmplpackage/tests sandbox/exmplpackage/yyy/tests sandbox/models/tests sandbox/montecarlo/tests sandbox/spline sandbox/spline/tests signal signal/tests sparse sparse/tests special special/tests stats stats/tests weave weave/tests Message-ID: <20070111042329.6366239C037@new.scipy.org> Author: jarrod.millman Date: 2007-01-10 22:22:41 -0600 (Wed, 10 Jan 2007) New Revision: 2529 Modified: trunk/Lib/__init__.py trunk/Lib/fftpack/__init__.py trunk/Lib/fftpack/tests/test_basic.py trunk/Lib/fftpack/tests/test_helper.py trunk/Lib/fftpack/tests/test_pseudo_diffs.py trunk/Lib/integrate/__init__.py trunk/Lib/integrate/tests/test_integrate.py trunk/Lib/integrate/tests/test_quadpack.py trunk/Lib/integrate/tests/test_quadrature.py trunk/Lib/interpolate/__init__.py trunk/Lib/interpolate/tests/test_fitpack.py trunk/Lib/interpolate/tests/test_interpolate.py trunk/Lib/io/__init__.py trunk/Lib/io/tests/test_array_import.py trunk/Lib/io/tests/test_mio.py trunk/Lib/io/tests/test_mmio.py trunk/Lib/io/tests/test_recaster.py trunk/Lib/lib/__init__.py trunk/Lib/lib/blas/__init__.py trunk/Lib/lib/blas/tests/test_blas.py trunk/Lib/lib/blas/tests/test_fblas.py trunk/Lib/lib/lapack/__init__.py trunk/Lib/lib/lapack/tests/test_lapack.py trunk/Lib/linalg/__init__.py trunk/Lib/linalg/tests/test_basic.py trunk/Lib/linalg/tests/test_blas.py trunk/Lib/linalg/tests/test_decomp.py trunk/Lib/linalg/tests/test_fblas.py trunk/Lib/linalg/tests/test_lapack.py trunk/Lib/linalg/tests/test_matfuncs.py trunk/Lib/linsolve/__init__.py trunk/Lib/linsolve/umfpack/__init__.py trunk/Lib/linsolve/umfpack/tests/test_umfpack.py trunk/Lib/maxentropy/__init__.py trunk/Lib/maxentropy/tests/test_maxentropy.py trunk/Lib/misc/__init__.py trunk/Lib/misc/ppimport.py trunk/Lib/ndimage/__init__.py trunk/Lib/ndimage/tests/test_ndimage.py trunk/Lib/optimize/__init__.py trunk/Lib/optimize/tests/test_cobyla.py trunk/Lib/optimize/tests/test_optimize.py trunk/Lib/optimize/tests/test_zeros.py trunk/Lib/sandbox/arpack/tests/test_arpack.py trunk/Lib/sandbox/arpack/tests/test_speigs.py trunk/Lib/sandbox/arraysetops/tests/test_arraysetops.py trunk/Lib/sandbox/cdavid/tests/test_autocorr.py trunk/Lib/sandbox/cdavid/tests/test_lpc.py trunk/Lib/sandbox/exmplpackage/tests/test_foo.py trunk/Lib/sandbox/exmplpackage/yyy/tests/test_yyy.py trunk/Lib/sandbox/models/tests/test_formula.py trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py trunk/Lib/sandbox/spline/__init__.py trunk/Lib/sandbox/spline/tests/test_fitpack.py trunk/Lib/sandbox/spline/tests/test_interpolate.py trunk/Lib/signal/__init__.py trunk/Lib/signal/tests/test_signaltools.py trunk/Lib/sparse/__init__.py trunk/Lib/sparse/tests/test_sparse.py trunk/Lib/special/__init__.py trunk/Lib/special/tests/test_basic.py trunk/Lib/stats/__init__.py trunk/Lib/stats/tests/test_distributions.py trunk/Lib/stats/tests/test_morestats.py trunk/Lib/stats/tests/test_stats.py trunk/Lib/weave/__init__.py trunk/Lib/weave/tests/test_ast_tools.py trunk/Lib/weave/tests/test_blitz_tools.py trunk/Lib/weave/tests/test_build_tools.py trunk/Lib/weave/tests/test_c_spec.py trunk/Lib/weave/tests/test_catalog.py trunk/Lib/weave/tests/test_ext_tools.py trunk/Lib/weave/tests/test_inline_tools.py trunk/Lib/weave/tests/test_scxx.py trunk/Lib/weave/tests/test_scxx_dict.py trunk/Lib/weave/tests/test_scxx_object.py trunk/Lib/weave/tests/test_scxx_sequence.py trunk/Lib/weave/tests/test_size_check.py trunk/Lib/weave/tests/test_slice_handler.py trunk/Lib/weave/tests/test_standard_array_spec.py trunk/Lib/weave/tests/test_wx_spec.py Log: removed use of deprecated ScipyTest in favor of NumpyTest Modified: trunk/Lib/__init__.py =================================================================== --- trunk/Lib/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -71,10 +71,10 @@ def test(level=1, verbosity=1): """ Run Scipy tests suite with level and verbosity.""" - from numpy.testing import ScipyTest + from numpy.testing import NumpyTest import scipy scipy.pkgload() - return ScipyTest(scipy).test(level, verbosity) + return NumpyTest(scipy).test(level, verbosity) __doc__ += """ Modified: trunk/Lib/fftpack/__init__.py =================================================================== --- trunk/Lib/fftpack/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/fftpack/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -17,5 +17,5 @@ del k, register_func -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/fftpack/tests/test_basic.py =================================================================== --- trunk/Lib/fftpack/tests/test_basic.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/fftpack/tests/test_basic.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -90,7 +90,7 @@ x1[0] = x[0] return direct_idft(x1).real -class test_fft(ScipyTestCase): +class test_fft(NumpyTestCase): def check_definition(self): x = [1,2,3,4+1j,1,2,3,4+2j] @@ -162,7 +162,7 @@ print ' (secs for %s calls)' % (repeat) sys.stdout.flush() -class test_ifft(ScipyTestCase): +class test_ifft(NumpyTestCase): def check_definition(self): x = [1,2,3,4+1j,1,2,3,4+2j] @@ -237,7 +237,7 @@ print ' (secs for %s calls)' % (repeat) sys.stdout.flush() -class test_rfft(ScipyTestCase): +class test_rfft(NumpyTestCase): def check_definition(self): x = [1,2,3,4,1,2,3,4] @@ -292,7 +292,7 @@ print ' (secs for %s calls)' % (repeat) sys.stdout.flush() -class test_irfft(ScipyTestCase): +class test_irfft(NumpyTestCase): def check_definition(self): x = [1,2,3,4,1,2,3,4] @@ -368,7 +368,7 @@ sys.stdout.flush() -class test_fftn(ScipyTestCase): +class test_fftn(NumpyTestCase): def check_definition(self): x = [[1,2,3],[4,5,6],[7,8,9]] @@ -529,7 +529,7 @@ sys.stdout.flush() -class test_ifftn(ScipyTestCase): +class test_ifftn(NumpyTestCase): def check_definition(self): x = [[1,2,3],[4,5,6],[7,8,9]] @@ -547,4 +547,4 @@ assert_array_almost_equal (fftn(ifftn(x)),x) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/fftpack/tests/test_helper.py =================================================================== --- trunk/Lib/fftpack/tests/test_helper.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/fftpack/tests/test_helper.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -22,7 +22,7 @@ def random(size): return rand(*size) -class test_fftshift(ScipyTestCase): +class test_fftshift(NumpyTestCase): def check_definition(self): x = [0,1,2,3,4,-4,-3,-2,-1] @@ -39,7 +39,7 @@ x = random((n,)) assert_array_almost_equal(ifftshift(fftshift(x)),x) -class test_fftfreq(ScipyTestCase): +class test_fftfreq(NumpyTestCase): def check_definition(self): x = [0,1,2,3,4,-4,-3,-2,-1] @@ -49,7 +49,7 @@ assert_array_almost_equal(10*fftfreq(10),x) assert_array_almost_equal(10*pi*fftfreq(10,pi),x) -class test_rfftfreq(ScipyTestCase): +class test_rfftfreq(NumpyTestCase): def check_definition(self): x = [0,1,1,2,2,3,3,4,4] @@ -60,4 +60,4 @@ assert_array_almost_equal(10*pi*rfftfreq(10,pi),x) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/fftpack/tests/test_pseudo_diffs.py =================================================================== --- trunk/Lib/fftpack/tests/test_pseudo_diffs.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/fftpack/tests/test_pseudo_diffs.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -77,7 +77,7 @@ return ifft(fft(x)*exp(k*a)).real -class test_diff(ScipyTestCase): +class test_diff(NumpyTestCase): def check_definition(self): for n in [16,17,64,127,32]: @@ -216,7 +216,7 @@ print ' (secs for %s calls)' % (repeat) -class test_tilbert(ScipyTestCase): +class test_tilbert(NumpyTestCase): def check_definition(self): for h in [0.1,0.5,1,5.5,10]: @@ -277,7 +277,7 @@ sys.stdout.flush() print ' (secs for %s calls)' % (repeat) -class test_itilbert(ScipyTestCase): +class test_itilbert(NumpyTestCase): def check_definition(self): for h in [0.1,0.5,1,5.5,10]: @@ -291,7 +291,7 @@ assert_array_almost_equal(itilbert(sin(2*x),h), direct_itilbert(sin(2*x),h)) -class test_hilbert(ScipyTestCase): +class test_hilbert(NumpyTestCase): def check_definition(self): for n in [16,17,64,127]: @@ -360,7 +360,7 @@ sys.stdout.flush() print ' (secs for %s calls)' % (repeat) -class test_ihilbert(ScipyTestCase): +class test_ihilbert(NumpyTestCase): def check_definition(self): for n in [16,17,64,127]: @@ -381,7 +381,7 @@ y2 = itilbert(f,h=10) assert_array_almost_equal (y,y2) -class test_shift(ScipyTestCase): +class test_shift(NumpyTestCase): def check_definition(self): for n in [18,17,64,127,32,2048,256]: @@ -430,4 +430,4 @@ print ' (secs for %s calls)' % (repeat) if __name__ == "__main__": - ScipyTest('fftpack.pseudo_diffs').run() + NumpyTest('fftpack.pseudo_diffs').run() Modified: trunk/Lib/integrate/__init__.py =================================================================== --- trunk/Lib/integrate/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/integrate/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -12,5 +12,5 @@ from ode import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/integrate/tests/test_integrate.py =================================================================== --- trunk/Lib/integrate/tests/test_integrate.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/integrate/tests/test_integrate.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -14,7 +14,7 @@ from scipy.integrate import odeint restore_path() -class test_odeint(ScipyTestCase): +class test_odeint(NumpyTestCase): """ Test odeint: free vibration of a simple oscillator m \ddot{u} + k u = 0, u(0) = u_0 \dot{u}(0) \dot{u}_0 @@ -51,4 +51,4 @@ assert res < 1.0e-6 if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/integrate/tests/test_quadpack.py =================================================================== --- trunk/Lib/integrate/tests/test_quadpack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/integrate/tests/test_quadpack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -10,7 +10,7 @@ if errTol is not None: assert err < errTol, (err, errTol) -class test_quad(ScipyTestCase): +class test_quad(NumpyTestCase): def check_typical(self): # 1) Typical function with two extra arguments: def myfunc(x,n,z): # Bessel function integrand @@ -106,4 +106,4 @@ 8/3.0 * (b**4.0 - a**4.0)) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/integrate/tests/test_quadrature.py =================================================================== --- trunk/Lib/integrate/tests/test_quadrature.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/integrate/tests/test_quadrature.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -7,7 +7,7 @@ from scipy.integrate import quadrature, romberg, romb restore_path() -class test_quadrature(ScipyTestCase): +class test_quadrature(NumpyTestCase): def quad(self, x, a, b, args): raise NotImplementedError @@ -31,4 +31,4 @@ assert_equal(romb(numpy.arange(17)),128) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/interpolate/__init__.py =================================================================== --- trunk/Lib/interpolate/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/interpolate/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -11,5 +11,5 @@ from fitpack2 import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/interpolate/tests/test_fitpack.py =================================================================== --- trunk/Lib/interpolate/tests/test_fitpack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/interpolate/tests/test_fitpack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -22,7 +22,7 @@ RectBivariateSpline restore_path() -class test_UnivariateSpline(ScipyTestCase): +class test_UnivariateSpline(NumpyTestCase): def check_linear_constant(self): x = [1,2,3] y = [3,3,3] @@ -41,7 +41,7 @@ assert_almost_equal(lut.get_residual(),0.0) assert_array_almost_equal(lut([1,1.5,2]),[0,1,2]) -class test_LSQBivariateSpline(ScipyTestCase): +class test_LSQBivariateSpline(NumpyTestCase): def check_linear_constant(self): x = [1,1,1,2,2,2,3,3,3] y = [1,2,3,1,2,3,1,2,3] @@ -54,7 +54,7 @@ #print lut.get_coeffs() #print lut.get_residual() -class test_SmoothBivariateSpline(ScipyTestCase): +class test_SmoothBivariateSpline(NumpyTestCase): def check_linear_constant(self): x = [1,1,1,2,2,2,3,3,3] y = [1,2,3,1,2,3,1,2,3] @@ -75,7 +75,7 @@ assert_almost_equal(lut.get_residual(),0.0) assert_array_almost_equal(lut([1,1.5,2],[1,1.5]),[[0,0],[1,1],[2,2]]) -class test_RectBivariateSpline(ScipyTestCase): +class test_RectBivariateSpline(NumpyTestCase): def check_defaults(self): x = array([1,2,3,4,5]) y = array([1,2,3,4,5]) @@ -84,4 +84,4 @@ assert_array_almost_equal(lut(x,y),z) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/interpolate/tests/test_interpolate.py =================================================================== --- trunk/Lib/interpolate/tests/test_interpolate.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/interpolate/tests/test_interpolate.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -7,7 +7,7 @@ restore_path() -class test_interp2d(ScipyTestCase): +class test_interp2d(NumpyTestCase): def test_interp2d(self): y, x = mgrid[0:pi:20j, 0:pi:21j] z = sin(x+y) @@ -18,7 +18,7 @@ assert_almost_equal(I(u.ravel(), v.ravel()), sin(v+u), decimal=2) -class test_interp1d(ScipyTestCase): +class test_interp1d(NumpyTestCase): def setUp(self): self.x10 = np.arange(10.) @@ -195,4 +195,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/io/__init__.py =================================================================== --- trunk/Lib/io/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/io/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -16,5 +16,5 @@ from mmio import mminfo,mmread,mmwrite __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/io/tests/test_array_import.py =================================================================== --- trunk/Lib/io/tests/test_array_import.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/io/tests/test_array_import.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -16,7 +16,7 @@ import numpy.oldnumeric as N import tempfile -class test_numpyio(ScipyTestCase): +class test_numpyio(NumpyTestCase): def check_basic(self): # Generate some data a = 255*rand(20) @@ -34,7 +34,7 @@ assert(N.product(a.astype(N.Int16) == b,axis=0)) os.remove(fname) -class test_read_array(ScipyTestCase): +class test_read_array(NumpyTestCase): def check_complex(self): a = rand(13,4) + 1j*rand(13,4) fname = tempfile.mktemp('.dat') @@ -61,4 +61,4 @@ os.remove(fname) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/io/tests/test_mio.py =================================================================== --- trunk/Lib/io/tests/test_mio.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/io/tests/test_mio.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -4,7 +4,7 @@ from glob import glob from cStringIO import StringIO from tempfile import mkstemp -from numpy.testing import set_package_path, restore_path, ScipyTestCase, ScipyTest +from numpy.testing import set_package_path, restore_path, NumpyTestCase, NumpyTest from numpy.testing import assert_equal, assert_array_almost_equal from numpy import arange, array, eye, pi, cos, exp, sin, sqrt, ndarray, \ zeros, reshape, transpose, empty @@ -23,7 +23,7 @@ test_data_path = os.path.join(os.path.dirname(__file__), './data') -class test_mio_array(ScipyTestCase): +class test_mio_array(NumpyTestCase): def __init__(self, *args, **kwargs): super(test_mio_array, self).__init__(*args, **kwargs) @@ -233,5 +233,5 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/io/tests/test_mmio.py =================================================================== --- trunk/Lib/io/tests/test_mmio.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/io/tests/test_mmio.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -8,7 +8,7 @@ from io.mmio import mminfo,mmread,mmwrite restore_path() -class test_mmio_array(ScipyTestCase): +class test_mmio_array(NumpyTestCase): def check_simple(self): a = [[1,2],[3,4]] @@ -135,7 +135,7 @@ 5 5 1.200e+01 ''' -class test_mmio_coordinate(ScipyTestCase): +class test_mmio_coordinate(NumpyTestCase): def check_simple_todense(self): fn = mktemp() @@ -152,4 +152,4 @@ assert_array_almost_equal(a,b) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/io/tests/test_recaster.py =================================================================== --- trunk/Lib/io/tests/test_recaster.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/io/tests/test_recaster.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -10,7 +10,7 @@ except: pass -class test_recaster(ScipyTestCase): +class test_recaster(NumpyTestCase): def test_init(self): # Setting sctype_list Modified: trunk/Lib/lib/__init__.py =================================================================== --- trunk/Lib/lib/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/lib/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -1,5 +1,5 @@ from info import __doc__, __all__ -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/lib/blas/__init__.py =================================================================== --- trunk/Lib/lib/blas/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/lib/blas/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -57,5 +57,5 @@ funcs.append(func) return tuple(funcs) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/lib/blas/tests/test_blas.py =================================================================== --- trunk/Lib/lib/blas/tests/test_blas.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/lib/blas/tests/test_blas.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -24,7 +24,7 @@ from blas import get_blas_funcs restore_path() -class test_cblas1_simple(ScipyTestCase): +class test_cblas1_simple(NumpyTestCase): def check_axpy(self): for p in 'sd': @@ -36,7 +36,7 @@ if f is None: continue assert_array_almost_equal(f([1,2j,3],[2,-1,3],a=5),[7,10j-1,18]) -class test_fblas1_simple(ScipyTestCase): +class test_fblas1_simple(NumpyTestCase): def check_axpy(self): for p in 'sd': @@ -122,7 +122,7 @@ assert_equal(f([-5,4+3j,6]),1) #XXX: need tests for rot,rotm,rotg,rotmg -class test_fblas2_simple(ScipyTestCase): +class test_fblas2_simple(NumpyTestCase): def check_gemv(self): for p in 'sd': @@ -170,7 +170,7 @@ 2j, 3j],[3j,4j]),[[6,8],[12,16],[18,24]]) -class test_fblas3_simple(ScipyTestCase): +class test_fblas3_simple(NumpyTestCase): def check_gemm(self): for p in 'sd': @@ -195,7 +195,7 @@ assert_array_almost_equal(f(1,[[1,2]],[[3],[4]]),[[11]]) assert_array_almost_equal(f(1,[[1,2],[1,2]],[[3],[4]]),[[11],[11]]) -class test_blas(ScipyTestCase): +class test_blas(NumpyTestCase): def check_blas(self): a = array([[1,1,1]]) @@ -226,4 +226,4 @@ """ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/lib/blas/tests/test_fblas.py =================================================================== --- trunk/Lib/lib/blas/tests/test_fblas.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/lib/blas/tests/test_fblas.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -40,7 +40,7 @@ ################################################## ### Test blas ?axpy -class base_axpy(ScipyTestCase): +class base_axpy(NumpyTestCase): def check_default_a(self): x = arange(3.,dtype=self.dtype) y = arange(3.,dtype=x.dtype) @@ -114,7 +114,7 @@ ################################################## ### Test blas ?scal -class base_scal(ScipyTestCase): +class base_scal(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) real_x = x*3. @@ -159,7 +159,7 @@ ################################################## ### Test blas ?copy -class base_copy(ScipyTestCase): +class base_copy(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -228,7 +228,7 @@ ################################################## ### Test blas ?swap -class base_swap(ScipyTestCase): +class base_swap(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -304,7 +304,7 @@ ### Test blas ?gemv ### This will be a mess to test all cases. -class base_gemv(ScipyTestCase): +class base_gemv(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): mult = array(1, dtype = self.dtype) if self.dtype in [complex64, complex128]: @@ -409,7 +409,7 @@ ### Test blas ?ger ### This will be a mess to test all cases. -class base_ger(ScipyTestCase): +class base_ger(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): from numpy.random import normal alpha = array(1., dtype = self.dtype) @@ -518,4 +518,4 @@ """ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/lib/lapack/__init__.py =================================================================== --- trunk/Lib/lib/lapack/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/lib/lapack/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -89,5 +89,5 @@ func_code = %(func_name)s.func_code ''' -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/lib/lapack/tests/test_lapack.py =================================================================== --- trunk/Lib/lib/lapack/tests/test_lapack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/lib/lapack/tests/test_lapack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -27,7 +27,7 @@ #class _test_ev: pass -class _test_lapack(ScipyTestCase, +class _test_lapack(NumpyTestCase, _test_ev, _test_gev): @@ -123,4 +123,4 @@ decimal = 12 if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linalg/__init__.py =================================================================== --- trunk/Lib/linalg/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -28,5 +28,5 @@ del k, register_func -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/linalg/tests/test_basic.py =================================================================== --- trunk/Lib/linalg/tests/test_basic.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/tests/test_basic.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -39,7 +39,7 @@ data = add.outer(data,data) return data -class test_solve_banded(ScipyTestCase): +class test_solve_banded(NumpyTestCase): def check_simple(self): @@ -54,7 +54,7 @@ x = solve_banded((l,u),ab,b) assert_array_almost_equal(numpy.dot(a,x),b) -class test_solve(ScipyTestCase): +class test_solve(NumpyTestCase): def check_20Feb04_bug(self): a = [[1,1],[1.0,0]] # ok @@ -193,7 +193,7 @@ print ' (secs for %s calls)' % (repeat) -class test_inv(ScipyTestCase): +class test_inv(NumpyTestCase): def check_simple(self): a = [[1,2],[3,4]] @@ -265,7 +265,7 @@ print ' (secs for %s calls)' % (repeat) -class test_det(ScipyTestCase): +class test_det(NumpyTestCase): def check_simple(self): a = [[1,2],[3,4]] @@ -340,7 +340,7 @@ b1 = dot(at, b) return solve(a1, b1) -class test_lstsq(ScipyTestCase): +class test_lstsq(NumpyTestCase): def check_random_overdet_large(self): #bug report: Nils Wagner n = 200 @@ -510,7 +510,7 @@ y = hankel([1,2,3],[3,4,5]) assert_array_equal(y,[[1,2,3],[2,3,4],[3,4,5]]) -class test_pinv(ScipyTestCase): +class test_pinv(NumpyTestCase): def check_simple(self): a=array([[1,2,3],[4,5,6.],[7,8,10]]) @@ -538,4 +538,4 @@ assert_array_almost_equal(a_pinv,a_pinv2) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linalg/tests/test_blas.py =================================================================== --- trunk/Lib/linalg/tests/test_blas.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/tests/test_blas.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -23,7 +23,7 @@ from linalg import cblas restore_path() -class test_cblas1_simple(ScipyTestCase): +class test_cblas1_simple(NumpyTestCase): def check_axpy(self): for p in 'sd': @@ -35,7 +35,7 @@ if f is None: continue assert_array_almost_equal(f(5,[1,2j,3],[2,-1,3]),[7,10j-1,18]) -class test_fblas1_simple(ScipyTestCase): +class test_fblas1_simple(NumpyTestCase): def check_axpy(self): for p in 'sd': @@ -121,7 +121,7 @@ assert_equal(f([-5,4+3j,6]),1) #XXX: need tests for rot,rotm,rotg,rotmg -class test_fblas2_simple(ScipyTestCase): +class test_fblas2_simple(NumpyTestCase): def check_gemv(self): for p in 'sd': @@ -169,7 +169,7 @@ 2j, 3j],[3j,4j]),[[6,8],[12,16],[18,24]]) -class test_fblas3_simple(ScipyTestCase): +class test_fblas3_simple(NumpyTestCase): def check_gemm(self): for p in 'sd': @@ -183,7 +183,7 @@ assert_array_almost_equal(f(3j,[3-4j],[-4]),[[-48-36j]]) assert_array_almost_equal(f(3j,[3-4j],[-4],3,[5j]),[-48-21j]) -class test_blas(ScipyTestCase): +class test_blas(NumpyTestCase): def check_fblas(self): if hasattr(fblas,'empty_module'): @@ -208,4 +208,4 @@ """ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linalg/tests/test_decomp.py =================================================================== --- trunk/Lib/linalg/tests/test_decomp.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/tests/test_decomp.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -32,7 +32,7 @@ def random(size): return rand(*size) -class test_eigvals(ScipyTestCase): +class test_eigvals(NumpyTestCase): def check_simple(self): a = [[1,2,3],[1,2,3],[2,5,6]] @@ -78,7 +78,7 @@ print ' (secs for %s calls)' % (repeat) -class test_eig(ScipyTestCase): +class test_eig(NumpyTestCase): def check_simple(self): a = [[1,2,3],[1,2,3],[2,5,6]] @@ -111,10 +111,10 @@ -class test_eig_banded(ScipyTestCase): +class test_eig_banded(NumpyTestCase): def __init__(self, *args): - ScipyTestCase.__init__(self, *args) + NumpyTestCase.__init__(self, *args) self.create_bandmat() @@ -396,7 +396,7 @@ -class test_lu(ScipyTestCase): +class test_lu(NumpyTestCase): def check_simple(self): a = [[1,2,3],[1,2,3],[2,5,6]] @@ -414,7 +414,7 @@ #XXX: need more tests -class test_lu_solve(ScipyTestCase): +class test_lu_solve(NumpyTestCase): def check_lu(self): a = random((10,10)) b = random((10,)) @@ -426,7 +426,7 @@ assert_array_equal(x1,x2) -class test_svd(ScipyTestCase): +class test_svd(NumpyTestCase): def check_simple(self): a = [[1,2,3],[1,20,3],[2,5,6]] @@ -499,7 +499,7 @@ for i in range(len(s)): sigma[i,i] = s[i] assert_array_almost_equal(dot(dot(u,sigma),vh),a) -class test_svdvals(ScipyTestCase): +class test_svdvals(NumpyTestCase): def check_simple(self): a = [[1,2,3],[1,2,3],[2,5,6]] @@ -537,12 +537,12 @@ assert len(s)==2 assert s[0]>=s[1] -class test_diagsvd(ScipyTestCase): +class test_diagsvd(NumpyTestCase): def check_simple(self): assert_array_almost_equal(diagsvd([1,0,0],3,3),[[1,0,0],[0,0,0],[0,0,0]]) -class test_cholesky(ScipyTestCase): +class test_cholesky(NumpyTestCase): def check_simple(self): a = [[8,2,3],[2,9,3],[3,3,6]] @@ -591,7 +591,7 @@ assert_array_almost_equal(cholesky(a,lower=1),c) -class test_qr(ScipyTestCase): +class test_qr(NumpyTestCase): def check_simple(self): a = [[8,2,3],[2,9,3],[5,3,6]] @@ -677,7 +677,7 @@ transp = transpose any = sometrue -class test_schur(ScipyTestCase): +class test_schur(NumpyTestCase): def check_simple(self): a = [[8,12,3],[2,9,3],[10,3,6]] @@ -689,7 +689,7 @@ tc2,zc2 = rsf2csf(tc,zc) assert_array_almost_equal(dot(dot(zc2,tc2),transp(conj(zc2))),a) -class test_hessenberg(ScipyTestCase): +class test_hessenberg(NumpyTestCase): def check_simple(self): a = [[-149, -50,-154], @@ -737,4 +737,4 @@ assert_array_almost_equal(h1,h) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linalg/tests/test_fblas.py =================================================================== --- trunk/Lib/linalg/tests/test_fblas.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/tests/test_fblas.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -40,7 +40,7 @@ ################################################## ### Test blas ?axpy -class base_axpy(ScipyTestCase): +class base_axpy(NumpyTestCase): def check_default_a(self): x = arange(3.,dtype=self.dtype) y = arange(3.,dtype=x.dtype) @@ -114,7 +114,7 @@ ################################################## ### Test blas ?scal -class base_scal(ScipyTestCase): +class base_scal(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) real_x = x*3. @@ -159,7 +159,7 @@ ################################################## ### Test blas ?copy -class base_copy(ScipyTestCase): +class base_copy(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -228,7 +228,7 @@ ################################################## ### Test blas ?swap -class base_swap(ScipyTestCase): +class base_swap(NumpyTestCase): def check_simple(self): x = arange(3.,dtype=self.dtype) y = zeros(shape(x),x.dtype) @@ -304,7 +304,7 @@ ### Test blas ?gemv ### This will be a mess to test all cases. -class base_gemv(ScipyTestCase): +class base_gemv(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): mult = array(1, dtype = self.dtype) if self.dtype in [complex64, complex128]: @@ -409,7 +409,7 @@ ### Test blas ?ger ### This will be a mess to test all cases. -class base_ger(ScipyTestCase): +class base_ger(NumpyTestCase): def get_data(self,x_stride=1,y_stride=1): from numpy.random import normal alpha = array(1., dtype = self.dtype) @@ -518,4 +518,4 @@ """ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linalg/tests/test_lapack.py =================================================================== --- trunk/Lib/linalg/tests/test_lapack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/tests/test_lapack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -20,7 +20,7 @@ from linalg import clapack restore_path() -class test_flapack_simple(ScipyTestCase): +class test_flapack_simple(NumpyTestCase): def check_gebal(self): a = [[1,2,3],[4,5,6],[7,8,9]] @@ -52,7 +52,7 @@ ht,tau,info = f(a) assert not info,`info` -class test_lapack(ScipyTestCase): +class test_lapack(NumpyTestCase): def check_flapack(self): if hasattr(flapack,'empty_module'): @@ -77,4 +77,4 @@ """ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linalg/tests/test_matfuncs.py =================================================================== --- trunk/Lib/linalg/tests/test_matfuncs.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linalg/tests/test_matfuncs.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -25,7 +25,7 @@ from linalg import signm,logm,funm, sqrtm, expm, expm2, expm3 restore_path() -class test_signm(ScipyTestCase): +class test_signm(NumpyTestCase): def check_nils(self): a = array([[ 29.2, -24.2, 69.5, 49.8, 7. ], @@ -67,7 +67,7 @@ r = signm(a) #XXX: what would be the correct result? -class test_logm(ScipyTestCase): +class test_logm(NumpyTestCase): def check_nils(self): a = array([[ -2., 25., 0., 0., 0., 0., 0.], @@ -81,7 +81,7 @@ logm(m) -class test_sqrtm(ScipyTestCase): +class test_sqrtm(NumpyTestCase): def check_bad(self): # See http://www.maths.man.ac.uk/~nareports/narep336.ps.gz e = 2**-5 @@ -98,7 +98,7 @@ esa = sqrtm(a) assert_array_almost_equal(dot(esa,esa),a) -class test_expm(ScipyTestCase): +class test_expm(NumpyTestCase): def check_zero(self): a = array([[0.,0],[0,0]]) assert_array_almost_equal(expm(a),[[1,0],[0,1]]) @@ -106,4 +106,4 @@ assert_array_almost_equal(expm3(a),[[1,0],[0,1]]) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/linsolve/__init__.py =================================================================== --- trunk/Lib/linsolve/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linsolve/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -9,5 +9,5 @@ from linsolve import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/linsolve/umfpack/__init__.py =================================================================== --- trunk/Lib/linsolve/umfpack/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linsolve/umfpack/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -3,5 +3,5 @@ from umfpack import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/linsolve/umfpack/tests/test_umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -18,7 +18,7 @@ restore_path() -class test_solvers(ScipyTestCase): +class test_solvers(NumpyTestCase): """Tests inverting a sparse linear system""" def check_solve_complex_without_umfpack(self): @@ -72,7 +72,7 @@ -class test_factorization(ScipyTestCase): +class test_factorization(NumpyTestCase): """Tests factorizing a sparse linear system""" def check_complex_lu(self): @@ -132,4 +132,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/maxentropy/__init__.py =================================================================== --- trunk/Lib/maxentropy/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/maxentropy/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -8,5 +8,5 @@ from info import __doc__ from maxentropy import * -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/maxentropy/tests/test_maxentropy.py =================================================================== --- trunk/Lib/maxentropy/tests/test_maxentropy.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/maxentropy/tests/test_maxentropy.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -16,7 +16,7 @@ import unittest -class test_maxentropy(ScipyTestCase): +class test_maxentropy(NumpyTestCase): """Test whether logsumexp() function correctly handles large inputs. """ @@ -41,4 +41,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/misc/__init__.py =================================================================== --- trunk/Lib/misc/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/misc/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -21,5 +21,5 @@ __all__ += common.__all__ -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/misc/ppimport.py =================================================================== --- trunk/Lib/misc/ppimport.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/misc/ppimport.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -242,8 +242,8 @@ self.__dict__['_ppimport_p_frame'] = p_frame if location != 'sys.path': - from numpy.test.testing import ScipyTest - self.__dict__['test'] = ScipyTest(self).test + from numpy.test.testing import NumpyTest + self.__dict__['test'] = NumpyTest(self).test # install loader sys.modules[name] = self @@ -283,8 +283,8 @@ self.__dict__['_ppimport_module'] = module # XXX: Should we check the existence of module.test? Warn? - from numpy.test.testing import ScipyTest - module.test = ScipyTest(module).test + from numpy.test.testing import NumpyTest + module.test = NumpyTest(module).test return module Modified: trunk/Lib/ndimage/__init__.py =================================================================== --- trunk/Lib/ndimage/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/ndimage/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -36,6 +36,6 @@ from morphology import * from info import __doc__ -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/ndimage/tests/test_ndimage.py =================================================================== --- trunk/Lib/ndimage/tests/test_ndimage.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/ndimage/tests/test_ndimage.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -62,7 +62,7 @@ return math.sqrt(t) -class test_ndimage(ScipyTestCase): +class test_ndimage(NumpyTestCase): def setUp(self): # list of numarray data types @@ -5523,4 +5523,4 @@ if __name__ == "__main__": #unittest.main() - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/optimize/__init__.py =================================================================== --- trunk/Lib/optimize/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/optimize/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -13,5 +13,5 @@ from cobyla import fmin_cobyla __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/optimize/tests/test_cobyla.py =================================================================== --- trunk/Lib/optimize/tests/test_cobyla.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/optimize/tests/test_cobyla.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -6,7 +6,7 @@ restore_path() import math -class test_cobyla(ScipyTestCase): +class test_cobyla(NumpyTestCase): def check_simple(self, level=1): function = lambda x: x[0]**2 + abs(x[1])**3 @@ -20,4 +20,4 @@ assert_almost_equal(x, [x0, x1], decimal=5) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/optimize/tests/test_optimize.py =================================================================== --- trunk/Lib/optimize/tests/test_optimize.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/optimize/tests/test_optimize.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -11,7 +11,7 @@ restore_path() -class test_optimize(ScipyTestCase): +class test_optimize(NumpyTestCase): """ Test case for a simple constrained entropy maximization problem (the machine translation example of Berger et al in Computational Linguistics, vol 22, num 1, pp 39--72, 1996.) @@ -124,4 +124,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/optimize/tests/test_zeros.py =================================================================== --- trunk/Lib/optimize/tests/test_zeros.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/optimize/tests/test_zeros.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -51,7 +51,7 @@ functions = [f2,f3,f4,f5,f6] fstrings = ['f2','f3','f4','f5','f6'] -class test_basic(ScipyTestCase) : +class test_basic(NumpyTestCase) : def run_test(self, method, name): a = .5 b = sqrt(3) @@ -93,4 +93,4 @@ print '\n\n' if __name__ == '__main__' : - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/arpack/tests/test_arpack.py =================================================================== --- trunk/Lib/sandbox/arpack/tests/test_arpack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/arpack/tests/test_arpack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -19,7 +19,7 @@ import numpy from scipy.linalg import eig,eigh,norm -class test_eigen_nonsymmetric(ScipyTestCase): +class test_eigen_nonsymmetric(NumpyTestCase): def get_a1(self,typ): mat=numpy.array([[-2., -8., 1., 2., -5.], @@ -121,7 +121,7 @@ -class test_eigen_complex_nonsymmetric(ScipyTestCase): +class test_eigen_complex_nonsymmetric(NumpyTestCase): def get_a1(self,typ): mat=numpy.array([[-2., -8., 1., 2., -5.], @@ -218,7 +218,7 @@ -class test_eigen_symmetric(ScipyTestCase): +class test_eigen_symmetric(NumpyTestCase): def get_a1(self,typ): mat_a1=numpy.array([[ 2., 0., 0., -1., 0., -1.], @@ -290,7 +290,7 @@ self.end_eigenvalues(typ,k) -class test_eigen_complex_symmetric(ScipyTestCase): +class test_eigen_complex_symmetric(NumpyTestCase): def get_a1(self,typ): mat_a1=numpy.array([[ 2., 0., 0., -1., 0., -1.], @@ -352,4 +352,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/arpack/tests/test_speigs.py =================================================================== --- trunk/Lib/sandbox/arpack/tests/test_speigs.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/arpack/tests/test_speigs.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -8,7 +8,7 @@ import numpy as N -class test_eigs(ScipyTestCase): +class test_eigs(NumpyTestCase): def test(self): maxn=15 # Dimension of square matrix to be solved # Use a PDP^-1 factorisation to construct matrix with known @@ -36,7 +36,7 @@ assert_array_almost_equal(calc_vecs, N.array(vecs)[:,0:nev], decimal=7) -# class test_geneigs(ScipyTestCase): +# class test_geneigs(NumpyTestCase): # def test(self): # import pickle # import scipy.linsolve @@ -50,5 +50,5 @@ # 94.646308846854879, 95.30841709116271], decimal=11) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/arraysetops/tests/test_arraysetops.py =================================================================== --- trunk/Lib/sandbox/arraysetops/tests/test_arraysetops.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/arraysetops/tests/test_arraysetops.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -24,7 +24,7 @@ from scipy.arraysetops import * restore_path() -class test_aso( ScipyTestCase ): +class test_aso( NumpyTestCase ): def chech_all(): test_unique1d() @@ -37,4 +37,4 @@ test_manyways() if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/cdavid/tests/test_autocorr.py =================================================================== --- trunk/Lib/sandbox/cdavid/tests/test_autocorr.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/cdavid/tests/test_autocorr.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -345,7 +345,7 @@ assert_array_almost_equal(atest, aref, decimal = md) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() #class test_autocorr_2d(NumpyTestCase): # def check_double(self): Modified: trunk/Lib/sandbox/cdavid/tests/test_lpc.py =================================================================== --- trunk/Lib/sandbox/cdavid/tests/test_lpc.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/cdavid/tests/test_lpc.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -184,4 +184,4 @@ assert_array_almost_equal(k, kt) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/exmplpackage/tests/test_foo.py =================================================================== --- trunk/Lib/sandbox/exmplpackage/tests/test_foo.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/exmplpackage/tests/test_foo.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -22,15 +22,15 @@ from exmplpackage.foo import * del sys.path[0] -class test_foo_bar(ScipyTestCase): +class test_foo_bar(NumpyTestCase): def check_simple(self, level=1): assert exmplpackage_foo_bar()=='Hello from exmplpackage_foo_bar' -class test_foo_gun(ScipyTestCase): +class test_foo_gun(NumpyTestCase): def check_simple(self, level=1): assert foo_gun()=='Hello from foo_gun' if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/exmplpackage/yyy/tests/test_yyy.py =================================================================== --- trunk/Lib/sandbox/exmplpackage/yyy/tests/test_yyy.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/exmplpackage/yyy/tests/test_yyy.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -7,10 +7,10 @@ from yyy import fun del sys.path[0] -class test_fun(ScipyTestCase): +class test_fun(NumpyTestCase): def check_simple(self, level=1): assert fun()=='Hello from yyy.fun' #... if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/models/tests/test_formula.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_formula.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/models/tests/test_formula.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -6,7 +6,7 @@ import numpy as N import numpy.random as R import numpy.linalg as L -from numpy.testing import assert_almost_equal, ScipyTestCase +from numpy.testing import assert_almost_equal, NumpyTestCase import scipy from scipy.sandbox.models import utils, formula, contrast @@ -47,7 +47,7 @@ f = intercept * t1 self.assertEqual(str(f), str(formula.formula(t1))) -class test_formula(ScipyTestCase): +class test_formula(NumpyTestCase): def setUp(self): self.X = R.standard_normal((40,10)) Modified: trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py =================================================================== --- trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/montecarlo/tests/test_dictsampler.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -21,7 +21,7 @@ import unittest -class test_dictsampler(ScipyTestCase): +class test_dictsampler(NumpyTestCase): def check_simple(self): """ # Sample from this discrete distribution: @@ -76,4 +76,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py =================================================================== --- trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/montecarlo/tests/test_intsampler.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -30,7 +30,7 @@ import unittest -class test_intsampler(ScipyTestCase): +class test_intsampler(NumpyTestCase): def check_simple(self): # Sample from a Poisson distribution, P(lambda = 10.0) lam = 10.0 @@ -71,4 +71,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/spline/__init__.py =================================================================== --- trunk/Lib/sandbox/spline/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/spline/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -10,5 +10,5 @@ from spline import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/sandbox/spline/tests/test_fitpack.py =================================================================== --- trunk/Lib/sandbox/spline/tests/test_fitpack.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/spline/tests/test_fitpack.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -22,7 +22,7 @@ RectBivariateSpline restore_path() -class test_UnivariateSpline(ScipyTestCase): +class test_UnivariateSpline(NumpyTestCase): def check_linear_constant(self): x = [1,2,3] y = [3,3,3] @@ -41,7 +41,7 @@ assert_almost_equal(lut.get_residual(),0.0) assert_array_almost_equal(lut([1,1.5,2]),[0,1,2]) -class test_LSQBivariateSpline(ScipyTestCase): +class test_LSQBivariateSpline(NumpyTestCase): def check_linear_constant(self): x = [1,1,1,2,2,2,3,3,3] y = [1,2,3,1,2,3,1,2,3] @@ -54,7 +54,7 @@ #print lut.get_coeffs() #print lut.get_residual() -class test_SmoothBivariateSpline(ScipyTestCase): +class test_SmoothBivariateSpline(NumpyTestCase): def check_linear_constant(self): x = [1,1,1,2,2,2,3,3,3] y = [1,2,3,1,2,3,1,2,3] @@ -75,7 +75,7 @@ assert_almost_equal(lut.get_residual(),0.0) assert_array_almost_equal(lut([1,1.5,2],[1,1.5]),[[0,0],[1,1],[2,2]]) -class test_RectBivariateSpline(ScipyTestCase): +class test_RectBivariateSpline(NumpyTestCase): def check_defaults(self): x = array([1,2,3,4,5]) y = array([1,2,3,4,5]) @@ -84,4 +84,4 @@ assert_array_almost_equal(lut(x,y),z) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sandbox/spline/tests/test_interpolate.py =================================================================== --- trunk/Lib/sandbox/spline/tests/test_interpolate.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sandbox/spline/tests/test_interpolate.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -7,7 +7,7 @@ restore_path() -class test_interp2d(ScipyTestCase): +class test_interp2d(NumpyTestCase): def test_interp2d(self): y, x = mgrid[0:pi:20j, 0:pi:21j] z = sin(x+y) @@ -18,7 +18,7 @@ assert_almost_equal(I(u.ravel(), v.ravel()), sin(v+u), decimal=2) -class test_interp1d(ScipyTestCase): +class test_interp1d(NumpyTestCase): def setUp(self): self.x10 = np.arange(10.) @@ -195,4 +195,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/signal/__init__.py =================================================================== --- trunk/Lib/signal/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/signal/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -13,5 +13,5 @@ from wavelets import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/signal/tests/test_signaltools.py =================================================================== --- trunk/Lib/signal/tests/test_signaltools.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/signal/tests/test_signaltools.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -7,27 +7,27 @@ from numpy import array, arange -class test_convolve(ScipyTestCase): +class test_convolve(NumpyTestCase): def check_basic(self): a = [3,4,5,6,5,4] b = [1,2,3] c = signal.convolve(a,b) assert_array_equal(c,array([3,10,22,28,32,32,23,12])) -class test_medfilt(ScipyTestCase): +class test_medfilt(NumpyTestCase): def check_basic(self): f = [[3,4,5],[2,3,4],[1,2,5]] d = signal.medfilt(f) assert_array_equal(d, [[0,3,0],[2,3,3],[0,2,0]]) -class test_wiener(ScipyTestCase): +class test_wiener(NumpyTestCase): def check_basic(self): g = array([[5,6,4,3],[3,5,6,2],[2,3,5,6],[1,6,9,7]],'d') correct = array([[2.16374269,3.2222222222, 2.8888888889, 1.6666666667],[2.666666667, 4.33333333333, 4.44444444444, 2.8888888888],[2.222222222, 4.4444444444, 5.4444444444, 4.801066874837],[1.33333333333, 3.92735042735, 6.0712560386, 5.0404040404]]) h = signal.wiener(g) assert_array_almost_equal(h,correct,decimal=6) -class test_cspline1d_eval(ScipyTestCase): +class test_cspline1d_eval(NumpyTestCase): def check_basic(self): y=array([1,2,3,4,3,2,1,2,3.0]) x=arange(len(y)) @@ -42,4 +42,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/sparse/__init__.py =================================================================== --- trunk/Lib/sparse/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sparse/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -5,5 +5,5 @@ from sparse import * __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/sparse/tests/test_sparse.py =================================================================== --- trunk/Lib/sparse/tests/test_sparse.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/sparse/tests/test_sparse.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -461,7 +461,7 @@ -class test_csr(_test_cs, _test_horiz_slicing, _test_arith, ScipyTestCase): +class test_csr(_test_cs, _test_horiz_slicing, _test_arith, NumpyTestCase): spmatrix = csr_matrix def check_constructor1(self): @@ -528,7 +528,7 @@ for ic in range( asp.shape[1] ): assert_equal( asp[ir, ic], bsp[ir, ic] ) -class test_csc(_test_cs, _test_vert_slicing, _test_arith, ScipyTestCase): +class test_csc(_test_cs, _test_vert_slicing, _test_arith, NumpyTestCase): spmatrix = csc_matrix def check_constructor1(self): @@ -587,7 +587,7 @@ for ic in range( asp.shape[1] ): assert_equal( asp[ir, ic], bsp[ir, ic] ) -class test_dok(_test_cs, ScipyTestCase): +class test_dok(_test_cs, NumpyTestCase): spmatrix = dok_matrix def check_mult(self): @@ -698,7 +698,7 @@ assert caught == 6 -class test_lil(_test_cs, _test_horiz_slicing, ScipyTestCase): +class test_lil(_test_cs, _test_horiz_slicing, NumpyTestCase): spmatrix = lil_matrix def check_mult(self): A = matrix(zeros((10,10))) @@ -741,7 +741,7 @@ assert_array_equal(C.A, D.A) -class test_construct_utils(ScipyTestCase): +class test_construct_utils(NumpyTestCase): def check_identity(self): a = spidentity(3) b = array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype='d') @@ -763,7 +763,7 @@ b = array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype='d') assert_array_equal(a.toarray(), b) -class test_coo(ScipyTestCase): +class test_coo(NumpyTestCase): def check_constructor1(self): row = numpy.array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2]) col = numpy.array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1]) @@ -817,4 +817,4 @@ if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/special/__init__.py =================================================================== --- trunk/Lib/special/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/special/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -18,5 +18,5 @@ register_func('i0',i0) del register_func -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/special/tests/test_basic.py =================================================================== --- trunk/Lib/special/tests/test_basic.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/special/tests/test_basic.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -41,7 +41,7 @@ restore_path() -class test_cephes(ScipyTestCase): +class test_cephes(NumpyTestCase): def check_airy(self): cephes.airy(0) def check_airye(self): @@ -455,7 +455,7 @@ def check_wofz(self): cephes.wofz(0) -class test_airy(ScipyTestCase): +class test_airy(NumpyTestCase): def check_airy(self): #This tests the airy function to ensure 8 place accuracy in computation @@ -467,7 +467,7 @@ x = airy(-.36) assert_array_almost_equal(x,array([0.44508477,-0.23186773,0.44939534,0.48105354]),8) -class test_airye(ScipyTestCase): +class test_airye(NumpyTestCase): def check_airye(self): a = airye(0.01) @@ -479,7 +479,7 @@ b1[n] = b[n]*exp(-abs(real(2.0/3.0*0.01*sqrt(0.01)))) assert_array_almost_equal(a,b1,6) -class test_arange(ScipyTestCase): +class test_arange(NumpyTestCase): def check_arange(self): numstring = arange(0,2.21,.1) @@ -498,7 +498,7 @@ assert_array_equal(numstringc,array([3.3,7.3,11.3,15.3, 19.3,23.3])) -class test_ai_zeros(ScipyTestCase): +class test_ai_zeros(NumpyTestCase): def check_ai_zeros(self): ai = ai_zeros(1) @@ -507,7 +507,7 @@ array([ 0.5357]), array([ 0.7012])),4) -class test_array(ScipyTestCase): +class test_array(NumpyTestCase): def check_array(self): x = array([1,2,3,4]) @@ -517,7 +517,7 @@ a = arange(1,5,1) assert_array_equal(a,x) -class test_assoc_laguerre(ScipyTestCase): +class test_assoc_laguerre(NumpyTestCase): def check_assoc_laguerre(self): a1 = genlaguerre(11,1) @@ -526,36 +526,36 @@ a2 = assoc_laguerre(1,11,1) assert_array_almost_equal(a2,a1(1),8) -class test_besselpoly(ScipyTestCase): +class test_besselpoly(NumpyTestCase): def check_besselpoly(self): pass -class test_bei(ScipyTestCase): +class test_bei(NumpyTestCase): def check_bei(self): mbei = bei(2) assert_almost_equal(mbei, 0.9722916273066613,5)#this may not be exact -class test_beip(ScipyTestCase): +class test_beip(NumpyTestCase): def check_beip(self): mbeip = beip(2) assert_almost_equal(mbeip,0.91701361338403631,5)#this may not be exact -class test_ber(ScipyTestCase): +class test_ber(NumpyTestCase): def check_ber(self): mber = ber(2) assert_almost_equal(mber,0.75173418271380821,5)#this may not be exact -class test_berp(ScipyTestCase): +class test_berp(NumpyTestCase): def check_berp(self): mberp = berp(2) assert_almost_equal(mberp,-0.49306712470943909,5)#this may not be exact -class test_bei_zeros(ScipyTestCase): +class test_bei_zeros(NumpyTestCase): def check_bei_zeros(self): bi = bi_zeros(5) @@ -584,7 +584,7 @@ 0.929983638568022]),11) -class test_beip_zeros(ScipyTestCase): +class test_beip_zeros(NumpyTestCase): def check_beip_zeros(self): bip = beip_zeros(5) @@ -593,7 +593,7 @@ 12.742147523633703, 17.193431752512542, 21.641143941167325]),4) -class test_ber_zeros(ScipyTestCase): +class test_ber_zeros(NumpyTestCase): def check_ber_zeros(self): ber = ber_zeros(5) @@ -603,7 +603,7 @@ 16.11356, 20.55463]),4) -class test_bernoulli(ScipyTestCase): +class test_bernoulli(NumpyTestCase): def check_bernoulli(self): brn = bernoulli(5) @@ -614,7 +614,7 @@ -0.0333, 0.0000]),4) -class test_berp_zeros(ScipyTestCase): +class test_berp_zeros(NumpyTestCase): def check_berp_zeros(self): brp = berp_zeros(5) @@ -623,34 +623,34 @@ 14.96844, 19.41758, 23.86430]),4) -class test_beta(ScipyTestCase): +class test_beta(NumpyTestCase): def check_beta(self): bet = beta(2,4) betg = (gamma(2)*gamma(4))/gamma(6) assert_almost_equal(bet,betg,8) -class test_betaln(ScipyTestCase): +class test_betaln(NumpyTestCase): def check_betaln(self): betln = betaln(2,4) bet = log(abs(beta(2,4))) assert_almost_equal(betln,bet,8) -class test_betainc(ScipyTestCase): +class test_betainc(NumpyTestCase): def check_betainc(self): btinc = betainc(1,1,.2) assert_almost_equal(btinc,0.2,8) -class test_betaincinv(ScipyTestCase): +class test_betaincinv(NumpyTestCase): def check_betaincinv(self): y = betaincinv(2,4,.5) comp = betainc(2,4,y) assert_almost_equal(comp,.5,5) -class test_bi_zeros(ScipyTestCase): +class test_bi_zeros(NumpyTestCase): def check_bi_zeros(self): bi = bi_zeros(2) @@ -660,7 +660,7 @@ array([ 0.60195789 , -0.76031014])) assert_array_almost_equal(bi,bia,4) -class test_chebyc(ScipyTestCase): +class test_chebyc(NumpyTestCase): def check_chebyc(self): C0 = chebyc(0) @@ -677,7 +677,7 @@ assert_array_almost_equal(C4.c,[1,0,-4,0,2],13) assert_array_almost_equal(C5.c,[1,0,-5,0,5,0],13) -class test_chebys(ScipyTestCase): +class test_chebys(NumpyTestCase): def check_chebys(self): S0 = chebys(0) @@ -693,7 +693,7 @@ assert_array_almost_equal(S4.c,[1,0,-3,0,1],13) assert_array_almost_equal(S5.c,[1,0,-4,0,3,0],13) -class test_chebyt(ScipyTestCase): +class test_chebyt(NumpyTestCase): def check_chebyt(self): T0 = chebyt(0) @@ -709,7 +709,7 @@ assert_array_almost_equal(T4.c,[8,0,-8,0,1],13) assert_array_almost_equal(T5.c,[16,0,-20,0,5,0],13) -class test_chebyu(ScipyTestCase): +class test_chebyu(NumpyTestCase): def check_chebyu(self): U0 = chebyu(0) @@ -725,14 +725,14 @@ assert_array_almost_equal(U4.c,[16,0,-12,0,1],13) assert_array_almost_equal(U5.c,[32,0,-32,0,6,0],13) -class test_choose(ScipyTestCase): +class test_choose(NumpyTestCase): def check_choose(self): carray = [1,3,2,4,6,5] chose = choose([1,3,5],carray) assert_array_equal(chose,array([3,4,5])) -class test_cbrt(ScipyTestCase): +class test_cbrt(NumpyTestCase): def check_cbrt(self): cb = cbrt(27) @@ -744,7 +744,7 @@ cbrl1 = 27.9**(1.0/3.0) assert_almost_equal(cb1,cbrl1,8) -class test_cosdg(ScipyTestCase): +class test_cosdg(NumpyTestCase): def check_cosdg(self): cdg = cosdg(90) @@ -756,14 +756,14 @@ cdgmrl = cos(pi/6.0) assert_almost_equal(cdgm,cdgmrl,8) -class test_cosm1(ScipyTestCase): +class test_cosm1(NumpyTestCase): def check_cosm1(self): cs = (cosm1(0),cosm1(.3),cosm1(pi/10)) csrl = (cos(0)-1,cos(.3)-1,cos(pi/10)-1) assert_array_almost_equal(cs,csrl,8) -class test_cotdg(ScipyTestCase): +class test_cotdg(NumpyTestCase): def check_cotdg(self): ct = cotdg(30) @@ -790,20 +790,20 @@ assert_almost_equal(cotdg(-315), 1.0, 14) assert_almost_equal(cotdg(765), 1.0, 14) -class test_ellipj(ScipyTestCase): +class test_ellipj(NumpyTestCase): def check_ellipj(self): el = ellipj(0.2,0) rel = [sin(0.2),cos(0.2),1.0,0.20] assert_array_almost_equal(el,rel,13) -class test_ellipk(ScipyTestCase): +class test_ellipk(NumpyTestCase): def check_ellipk(self): elk = ellipk(.2) assert_almost_equal(elk,1.659623598610528,11) -class test_ellipkinc(ScipyTestCase): +class test_ellipkinc(NumpyTestCase): def check_ellipkinc(self): elkinc = ellipkinc(pi/2,.2) @@ -817,13 +817,13 @@ # From pg. 614 of A & S -class test_ellipe(ScipyTestCase): +class test_ellipe(NumpyTestCase): def check_ellipe(self): ele = ellipe(.2) assert_almost_equal(ele,1.4890350580958529,8) -class test_ellipeinc(ScipyTestCase): +class test_ellipeinc(NumpyTestCase): def check_ellipeinc(self): eleinc = ellipeinc(pi/2,.2) @@ -836,13 +836,13 @@ assert_almost_equal(eleinc, 0.58823065, 8) -class test_erf(ScipyTestCase): +class test_erf(NumpyTestCase): def check_erf(self): er = erf(.25) assert_almost_equal(er,0.2763263902,8) -class test_erf_zeros(ScipyTestCase): +class test_erf_zeros(NumpyTestCase): def check_erf_zeros(self): erz = erf_zeros(5) @@ -853,19 +853,19 @@ 3.76900557+4.06069723j]) assert_array_almost_equal(erz,erzr,4) -class test_erfcinv(ScipyTestCase): +class test_erfcinv(NumpyTestCase): def check_erfcinv(self): i = erfcinv(1) assert_equal(i,0) -class test_erfinv(ScipyTestCase): +class test_erfinv(NumpyTestCase): def check_erfinv(self): i = erfinv(0) assert_equal(i,0) -class test_errprint(ScipyTestCase): +class test_errprint(NumpyTestCase): def check_errprint(self): a = errprint() @@ -876,7 +876,7 @@ assert_equal(d,b) #makes sure state was returned #assert_equal(d,1-a) -class test_euler(ScipyTestCase): +class test_euler(NumpyTestCase): def check_euler(self): eu0 = euler(0) @@ -899,7 +899,7 @@ errmax = max(err) assert_almost_equal(errmax, 0.0, 14) -class test_exp2(ScipyTestCase): +class test_exp2(NumpyTestCase): def check_exp2(self): ex = exp2(2) @@ -911,7 +911,7 @@ exmrl = 2**(2.5) assert_almost_equal(exm,exmrl,8) -class test_exp10(ScipyTestCase): +class test_exp10(NumpyTestCase): def check_exp10(self): ex = exp10(2) @@ -923,7 +923,7 @@ exmrl = 10**(2.5) assert_almost_equal(exm,exmrl,8) -class test_expm1(ScipyTestCase): +class test_expm1(NumpyTestCase): def check_expm1(self): ex = (expm1(2),expm1(3),expm1(4)) @@ -935,13 +935,13 @@ exrl1 = (exp(2)-1,exp(2.1)-1,exp(2.2)-1) assert_array_almost_equal(ex1,exrl1,8) -class test_fresnel(ScipyTestCase): +class test_fresnel(NumpyTestCase): def check_fresnel(self): frs = array(fresnel(.5)) assert_array_almost_equal(frs,array([0.064732432859999287, 0.49234422587144644]),8) -class test_fresnel_zeros(ScipyTestCase): +class test_fresnel_zeros(NumpyTestCase): # values from pg 329 Table 7.11 of A & S # slightly corrected in 4th decimal place @@ -975,48 +975,48 @@ assert_array_almost_equal(frs,szo,12) -class test_gamma(ScipyTestCase): +class test_gamma(NumpyTestCase): def check_gamma(self): gam = gamma(5) assert_equal(gam,24.0) -class test_gammaln(ScipyTestCase): +class test_gammaln(NumpyTestCase): def check_gammaln(self): gamln = gammaln(3) lngam = log(gamma(3)) assert_almost_equal(gamln,lngam,8) -class test_gammainc(ScipyTestCase): +class test_gammainc(NumpyTestCase): def check_gammainc(self): gama = gammainc(.5,.5) assert_almost_equal(gama,.7,1) -class test_gammaincc(ScipyTestCase): +class test_gammaincc(NumpyTestCase): def check_gammaincc(self): gicc = gammaincc(.5,.5) greal = 1 - gammainc(.5,.5) assert_almost_equal(gicc,greal,8) -class test_gammainccinv(ScipyTestCase): +class test_gammainccinv(NumpyTestCase): def check_gammainccinv(self): gccinv = gammainccinv(.5,.5) gcinv = gammaincinv(.5,.5) assert_almost_equal(gccinv,gcinv,8) -class test_gammaincinv(ScipyTestCase): +class test_gammaincinv(NumpyTestCase): def check_gammaincinv(self): y = gammaincinv(.4,.4) x = gammainc(.4,y) assert_almost_equal(x,0.4,1) -class test_hankel1(ScipyTestCase): +class test_hankel1(NumpyTestCase): def check_negv(self): assert_almost_equal(hankel1(-3,2), -hankel1(3,2), 14) @@ -1025,7 +1025,7 @@ hankrl = (jv(1,.1)+yv(1,.1)*1j) assert_almost_equal(hank1,hankrl,8) -class test_hankel1e(ScipyTestCase): +class test_hankel1e(NumpyTestCase): def check_negv(self): assert_almost_equal(hankel1e(-3,2), -hankel1e(3,2), 14) @@ -1034,7 +1034,7 @@ hankrle = hankel1(1,.1)*exp(-.1j) assert_almost_equal(hank1e,hankrle,8) -class test_hankel2(ScipyTestCase): +class test_hankel2(NumpyTestCase): def check_negv(self): assert_almost_equal(hankel2(-3,2), -hankel2(3,2), 14) @@ -1043,7 +1043,7 @@ hankrl2 = (jv(1,.1)-yv(1,.1)*1j) assert_almost_equal(hank2,hankrl2,8) -class test_hankel2e(ScipyTestCase): +class test_hankel2e(NumpyTestCase): def check_negv(self): assert_almost_equal(hankel2e(-3,2), -hankel2e(3,2), 14) @@ -1052,7 +1052,7 @@ hankrl2e = hankel2e(1,.1) assert_almost_equal(hank2e,hankrl2e,8) -class test_hermite(ScipyTestCase): +class test_hermite(NumpyTestCase): def check_hermite(self): H0 = hermite(0) @@ -1093,7 +1093,7 @@ _gam = cephes.gamma -class test_gegenbauer(ScipyTestCase): +class test_gegenbauer(NumpyTestCase): def check_gegenbauer(self): a = 5*rand()-0.5 @@ -1116,7 +1116,7 @@ 0,15*poch(a,3),0])/15.0,11) -class test_h1vp(ScipyTestCase): +class test_h1vp(NumpyTestCase): def check_h1vp(self): @@ -1124,36 +1124,36 @@ h1real = (jvp(1,.1)+yvp(1,.1)*1j) assert_almost_equal(h1,h1real,8) -class test_h2vp(ScipyTestCase): +class test_h2vp(NumpyTestCase): def check_h2vp(self): h2 = h2vp(1,.1) h2real = (jvp(1,.1)-yvp(1,.1)*1j) assert_almost_equal(h2,h2real,8) -class test_hyp0f1(ScipyTestCase): +class test_hyp0f1(NumpyTestCase): def check_hyp0f1(self): pass -class test_hyp1f1(ScipyTestCase): +class test_hyp1f1(NumpyTestCase): def check_hyp1f1(self): hyp1 = hyp1f1(.1,.1,.3) assert_almost_equal(hyp1, 1.3498588075760032,7) -class test_hyp1f2(ScipyTestCase): +class test_hyp1f2(NumpyTestCase): def check_hyp1f2(self): pass -class test_hyp2f0(ScipyTestCase): +class test_hyp2f0(NumpyTestCase): def check_hyp2f0(self): pass -class test_hyp2f1(ScipyTestCase): +class test_hyp2f1(NumpyTestCase): def check_hyp2f1(self): # a collection of special cases taken from AMS 55 values = [[0.5, 1, 1.5, 0.2**2, 0.5/0.2*log((1+0.2)/(1-0.2))], @@ -1174,12 +1174,12 @@ cv = hyp2f1(a, b, c, x) assert_almost_equal(cv, v, 8, err_msg='test #%d' % i) -class test_hyp3f0(ScipyTestCase): +class test_hyp3f0(NumpyTestCase): def check_hyp3f0(self): pass -class test_hyperu(ScipyTestCase): +class test_hyperu(NumpyTestCase): def check_hyperu(self): val1 = hyperu(1,0.1,100) @@ -1194,7 +1194,7 @@ /(gamma(a)*gamma(2-b))) assert_array_almost_equal(hypu,hprl,12) -class test_i0(ScipyTestCase): +class test_i0(NumpyTestCase): def check_i0(self): values = [[0.0, 1.0], [1e-10, 1.0], @@ -1209,14 +1209,14 @@ cv = i0(x) * exp(-x) assert_almost_equal(cv, v, 8, err_msg='test #%d' % i) -class test_i0e(ScipyTestCase): +class test_i0e(NumpyTestCase): def check_i0e(self): oize = i0e(.1) oizer = ive(0,.1) assert_almost_equal(oize,oizer,8) -class test_i1(ScipyTestCase): +class test_i1(NumpyTestCase): def check_i1(self): values = [[0.0, 0.0], @@ -1231,38 +1231,38 @@ cv = i1(x) * exp(-x) assert_almost_equal(cv, v, 8, err_msg='test #%d' % i) -class test_i1e(ScipyTestCase): +class test_i1e(NumpyTestCase): def check_i1e(self): oi1e = i1e(.1) oi1er = ive(1,.1) assert_almost_equal(oi1e,oi1er,8) -class test_iti0k0(ScipyTestCase): +class test_iti0k0(NumpyTestCase): def check_iti0k0(self): iti0 = array(iti0k0(5)) assert_array_almost_equal(iti0,array([31.848667776169801, 1.5673873907283657]),5) -class test_it2i0k0(ScipyTestCase): +class test_it2i0k0(NumpyTestCase): def check_it2i0k0(self): it2k = it2i0k0(.1) assert_array_almost_equal(it2k,array([0.0012503906973464409, 3.3309450354686687]),6) -class test_itj0y0(ScipyTestCase): +class test_itj0y0(NumpyTestCase): def check_itj0y0(self): it0 = array(itj0y0(.2)) assert_array_almost_equal(it0,array([0.19933433254006822, -0.34570883800412566]),8) -class test_it2j0y0(ScipyTestCase): +class test_it2j0y0(NumpyTestCase): def check_it2j0y0(self): it2 = array(it2j0y0(.2)) assert_array_almost_equal(it2,array([0.0049937546274601858, -0.43423067011231614]),8) -class test_iv(ScipyTestCase): +class test_iv(NumpyTestCase): def check_negv(self): assert_equal(iv(3,2), iv(-3,2)) @@ -1270,7 +1270,7 @@ iv1 = iv(0,.1)*exp(-.1) assert_almost_equal(iv1,0.90710092578230106,10) -class test_ive(ScipyTestCase): +class test_ive(NumpyTestCase): def check_negv(self): assert_equal(ive(3,2), ive(-3,2)) @@ -1279,7 +1279,7 @@ iv1 = iv(0,.1)*exp(-.1) assert_almost_equal(ive1,iv1,10) -class test_ivp(ScipyTestCase): +class test_ivp(NumpyTestCase): def check_ivp0(self): assert_almost_equal(iv(1,2), ivp(0,2), 10) @@ -1288,21 +1288,21 @@ x = ivp(1,2) assert_almost_equal(x,y,10) -class test_j0(ScipyTestCase): +class test_j0(NumpyTestCase): def check_j0(self): oz = j0(.1) ozr = jn(0,.1) assert_almost_equal(oz,ozr,8) -class test_j1(ScipyTestCase): +class test_j1(NumpyTestCase): def check_j1(self): o1 = j1(.1) o1r = jn(1,.1) assert_almost_equal(o1,o1r,8) -class test_jacobi(ScipyTestCase): +class test_jacobi(NumpyTestCase): def check_jacobi(self): a = 5*rand() - 1 @@ -1323,13 +1323,13 @@ assert_array_almost_equal(P3.c,array(p3c)/48.0,13) -class test_jn(ScipyTestCase): +class test_jn(NumpyTestCase): def check_jn(self): jnnr = jn(1,.2) assert_almost_equal(jnnr,0.099500832639235995,8) -class test_jv(ScipyTestCase): +class test_jv(NumpyTestCase): def check_negv(self): assert_almost_equal(jv(-3,2), -jv(3,2), 14) @@ -1344,7 +1344,7 @@ yc = jv(v, x) assert_almost_equal(yc, y, 8, err_msg='test #%d' % i) -class test_jve(ScipyTestCase): +class test_jve(NumpyTestCase): def check_negv(self): assert_almost_equal(jve(-3,2), -jve(3,2), 14) @@ -1356,7 +1356,7 @@ jvexpr = jv(1,z)*exp(-abs(z.imag)) assert_almost_equal(jvexp1,jvexpr,8) -class test_jn_zeros(ScipyTestCase): +class test_jn_zeros(NumpyTestCase): def check_jn_zeros(self): jn0 = jn_zeros(0,5) @@ -1372,7 +1372,7 @@ 13.32369, 16.47063]),4) -class test_jnjnp_zeros(ScipyTestCase): +class test_jnjnp_zeros(NumpyTestCase): def check_jnjnp_zeros(self): pass @@ -1381,7 +1381,7 @@ #I don't think specfun jdzo is working properly the outputs do not seem to correlate #to the inputs -class test_jnp_zeros(ScipyTestCase): +class test_jnp_zeros(NumpyTestCase): def check_jnp_zeros(self): jnp = jnp_zeros(1,5) @@ -1391,7 +1391,7 @@ 11.70600, 14.86359]),4) -class test_jnyn_zeros(ScipyTestCase): +class test_jnyn_zeros(NumpyTestCase): def check_jnyn_zeros(self): jnz = jnyn_zeros(1,5) @@ -1416,48 +1416,48 @@ 13.28576, 16.44006])),4) -class test_jvp(ScipyTestCase): +class test_jvp(NumpyTestCase): def check_jvp(self): jvprim = jvp(2,2) jv0 = (jv(1,2)-jv(3,2))/2 assert_almost_equal(jvprim,jv0,10) -class test_k0(ScipyTestCase): +class test_k0(NumpyTestCase): def check_k0(self): ozk = k0(.1) ozkr = kv(0,.1) assert_almost_equal(ozk,ozkr,8) -class test_k0e(ScipyTestCase): +class test_k0e(NumpyTestCase): def check_k0e(self): ozke = k0e(.1) ozker = kve(0,.1) assert_almost_equal(ozke,ozker,8) -class test_k1(ScipyTestCase): +class test_k1(NumpyTestCase): def check_k1(self): o1k = k1(.1) o1kr = kv(1,.1) assert_almost_equal(o1k,o1kr,8) -class test_k1e(ScipyTestCase): +class test_k1e(NumpyTestCase): def check_k1e(self): o1ke = k1e(.1) o1ker = kve(1,.1) assert_almost_equal(o1ke,o1ker,8) -class test_kei(ScipyTestCase): +class test_kei(NumpyTestCase): def check_kei(self): mkei = kei(2) assert_almost_equal(mkei,-0.20240006776470432,5) -class test_kelvin(ScipyTestCase): +class test_kelvin(NumpyTestCase): def check_kelvin(self): mkelv = kelvin(2) @@ -1466,25 +1466,25 @@ berp(2)+beip(2)*1j, kerp(2)+keip(2)*1j),8) -class test_keip(ScipyTestCase): +class test_keip(NumpyTestCase): def check_keip(self): mkeip = keip(2) assert_almost_equal(mkeip,0.21980790991960536,5) -class test_ker(ScipyTestCase): +class test_ker(NumpyTestCase): def check_ker(self): mker = ker(2) assert_almost_equal(mker,-0.041664513991509472,5) -class test_kerp(ScipyTestCase): +class test_kerp(NumpyTestCase): def check_kerp(self): mkerp = kerp(2) assert_almost_equal(mkerp,-0.10660096588105264,5) -class test_kei_zeros(ScipyTestCase): +class test_kei_zeros(NumpyTestCase): def check_kei_zeros(self): kei = kei_zeros(5) @@ -1494,7 +1494,7 @@ 17.22314, 21.66464]),4) -class test_keip_zeros(ScipyTestCase): +class test_keip_zeros(NumpyTestCase): def check_keip_zeros(self): keip = keip_zeros(5) @@ -1506,7 +1506,7 @@ -class test_kelvin_zeros(ScipyTestCase): +class test_kelvin_zeros(NumpyTestCase): # numbers come from 9.9 of A&S pg. 381 def check_kelvin_zeros(self): @@ -1555,7 +1555,7 @@ 18.30717, 22.75379]),4) -class test_ker_zeros(ScipyTestCase): +class test_ker_zeros(NumpyTestCase): def check_ker_zeros(self): ker = ker_zeros(5) @@ -1565,7 +1565,7 @@ 15.00269, 19.44381]),4) -class test_kerp_zeros(ScipyTestCase): +class test_kerp_zeros(NumpyTestCase): def check_kerp_zeros(self): kerp = kerp_zeros(5) @@ -1575,13 +1575,13 @@ 16.08312, 20.53068]),4) -class test_kn(ScipyTestCase): +class test_kn(NumpyTestCase): def check_kn(self): kn1 = kn(0,.2) assert_almost_equal(kn1,1.7527038555281462,8) -class test_kv(ScipyTestCase): +class test_kv(NumpyTestCase): def check_negv(self): assert_equal(kv(3.0, 2.2), kv(-3.0, 2.2)) @@ -1596,7 +1596,7 @@ assert_almost_equal(kv2, 49.51242928773287, 10) -class test_kve(ScipyTestCase): +class test_kve(NumpyTestCase): def check_negv(self): assert_equal(kve(3.0, 2.2), kve(-3.0, 2.2)) @@ -1609,7 +1609,7 @@ kv2 = kv(0,z)*exp(z) assert_almost_equal(kve2,kv2,8) -class test_kvp(ScipyTestCase): +class test_kvp(NumpyTestCase): def check_kvp_v0n1(self): z = 2.2 assert_almost_equal(-kv(1,z), kvp(0,z, n=1), 10) @@ -1628,7 +1628,7 @@ x = kvp(v, z, n=2) assert_almost_equal(xc, x, 10) -class test_laguerre(ScipyTestCase): +class test_laguerre(NumpyTestCase): def check_laguerre(self): lag0 = laguerre(0) @@ -1657,7 +1657,7 @@ # Base polynomials come from Abrahmowitz and Stegan -class test_legendre(ScipyTestCase): +class test_legendre(NumpyTestCase): def check_legendre(self): leg0 = legendre(0) @@ -1674,7 +1674,7 @@ assert_almost_equal(leg5.c,array([63,0,-70,0,15,0])/8.0) -class test_lmbda(ScipyTestCase): +class test_lmbda(NumpyTestCase): def check_lmbda(self): lam = lmbda(1,.1) @@ -1682,7 +1682,7 @@ array([jvp(0,.1), -2*jv(1,.1)/.01 + 2*jvp(1,.1)/.1])) assert_array_almost_equal(lam,lamr,8) -class test_log1p(ScipyTestCase): +class test_log1p(NumpyTestCase): def check_log1p(self): l1p = (log1p(10),log1p(11),log1p(12)) @@ -1694,7 +1694,7 @@ l1pmrl = (log(2),log(2.1),log(2.2)) assert_array_almost_equal(l1pm,l1pmrl,8) -class test_lpmn(ScipyTestCase): +class test_lpmn(NumpyTestCase): def check_lpmn(self): @@ -1706,7 +1706,7 @@ 1.00000 , 1.50000]])),4) -class test_lpn(ScipyTestCase): +class test_lpn(NumpyTestCase): def check_lpn(self): lpnf = lpn(2,.5) @@ -1717,13 +1717,13 @@ 1.00000 , 1.50000])),4) -class test_lpmv(ScipyTestCase): +class test_lpmv(NumpyTestCase): def check_lpmv(self): lp = lpmv(0,2,.5) assert_almost_equal(lp,-0.125,3) -class test_lqmn(ScipyTestCase): +class test_lqmn(NumpyTestCase): def check_lqmn(self): lqmnf = lqmn(0,2,.5) @@ -1735,41 +1735,41 @@ -class test_lqn(ScipyTestCase): +class test_lqn(NumpyTestCase): def check_lqn(self): lqf = lqn(2,.5) assert_array_almost_equal(lqf,(array([ 0.5493, -0.7253, -0.8187]), array([ 1.3333, 1.216 , -0.8427])),4) -class test_mathieu_a(ScipyTestCase): +class test_mathieu_a(NumpyTestCase): def check_mathieu_a(self): pass -class test_mathieu_even_coef(ScipyTestCase): +class test_mathieu_even_coef(NumpyTestCase): def check_mathieu_even_coef(self): mc = mathieu_even_coef(2,5) #Q not defined broken and cannot figure out proper reporting order -class test_mathieu_odd_coef(ScipyTestCase): +class test_mathieu_odd_coef(NumpyTestCase): def check_mathieu_odd_coef(self): pass #same problem as above -class test_modfresnelp(ScipyTestCase): +class test_modfresnelp(NumpyTestCase): def check_modfresnelp(self): pass -class test_modfresnelm(ScipyTestCase): +class test_modfresnelm(NumpyTestCase): def check_modfresnelm(self): pass -class test_obl_cv_seq(ScipyTestCase): +class test_obl_cv_seq(NumpyTestCase): def check_obl_cv_seq(self): obl = obl_cv_seq(0,3,1) @@ -1778,7 +1778,7 @@ 5.486800, 11.492120]),5) -class test_pbdn_seq(ScipyTestCase): +class test_pbdn_seq(NumpyTestCase): def check_pbdn_seq(self): pb = pbdn_seq(1,.1) @@ -1787,25 +1787,25 @@ array([-0.0499, 0.9925])),4) -class test_pbdv(ScipyTestCase): +class test_pbdv(NumpyTestCase): def check_pbdv(self): pbv = pbdv(1,.2) derrl = 1/2*(.2)*pbdv(1,.2)[0] - pbdv(0,.2)[0] -class _test_pbdv_seq(ScipyTestCase): +class _test_pbdv_seq(NumpyTestCase): def check_pbdv_seq(self): pbn = pbdn_seq(1,.1) pbv = pbdv_seq(1,.1) assert_array_almost_equal(pbv,(real(pbn[0]),real(pbn[1])),4) -class test_pbvv_seq(ScipyTestCase): +class test_pbvv_seq(NumpyTestCase): def check_pbvv_seq(self): pass -class test_polygamma(ScipyTestCase): +class test_polygamma(NumpyTestCase): # from Table 6.2 (pg. 271) of A&S def check_polygamma(self): @@ -1814,7 +1814,7 @@ assert_almost_equal(poly2,-2.4041138063,10) assert_almost_equal(poly3,6.4939394023,10) -class test_pro_cv_seq(ScipyTestCase): +class test_pro_cv_seq(NumpyTestCase): def check_pro_cv_seq(self): prol = pro_cv_seq(0,3,1) @@ -1823,13 +1823,13 @@ 6.533471, 12.514462]),5) -class test_psi(ScipyTestCase): +class test_psi(NumpyTestCase): def check_psi(self): ps = psi(1) assert_almost_equal(ps,-0.57721566490153287,8) -class test_radian(ScipyTestCase): +class test_radian(NumpyTestCase): def check_radian(self): rad = radian(90,0,0) @@ -1839,7 +1839,7 @@ rad1 = radian(90,1,60) assert_almost_equal(rad1,pi/2+0.0005816135199345904,5) -class test_reshape(ScipyTestCase): +class test_reshape(NumpyTestCase): def check_reshape(self): a = (array([1,2,3]),array([4,5,6])) @@ -1851,28 +1851,28 @@ [3, 4], [5, 6]])) -class test_rgamma(ScipyTestCase): +class test_rgamma(NumpyTestCase): def check_rgamma(self): rgam = rgamma(8) rlgam = 1/gamma(8) assert_almost_equal(rgam,rlgam,8) -class test_riccati_jn(ScipyTestCase): +class test_riccati_jn(NumpyTestCase): def check_riccati_jn(self): jnrl = (sph_jn(1,.2)[0]*.2,sph_jn(1,.2)[0]+sph_jn(1,.2)[1]*.2) ricjn = riccati_jn(1,.2) assert_array_almost_equal(ricjn,jnrl,8) -class test_riccati_yn(ScipyTestCase): +class test_riccati_yn(NumpyTestCase): def check_riccati_yn(self): ynrl = (sph_yn(1,.2)[0]*.2,sph_yn(1,.2)[0]+sph_yn(1,.2)[1]*.2) ricyn = riccati_yn(1,.2) assert_array_almost_equal(ricyn,ynrl,8) -class test_round(ScipyTestCase): +class test_round(NumpyTestCase): def check_round(self): rnd = map(int,(round(10.1),round(10.4),round(10.5),round(10.6))) @@ -1885,7 +1885,7 @@ rndrl = (10,10,10,11) assert_array_equal(rnd,rndrl) -class _test_sh_legendre(ScipyTestCase): +class _test_sh_legendre(NumpyTestCase): def check_sh_legendre(self): # P*_n(x) = P_n(2x-1) @@ -1909,7 +1909,7 @@ assert_array_almost_equal(Ps4.c,pse4.c,12) assert_array_almost_equal(Ps5.c,pse5.c,12) -class _test_sh_chebyt(ScipyTestCase): +class _test_sh_chebyt(NumpyTestCase): def check_sh_chebyt(self): # T*_n(x) = T_n(2x-1) @@ -1934,7 +1934,7 @@ assert_array_almost_equal(Ts5.c,tse5.c,12) -class _test_sh_chebyu(ScipyTestCase): +class _test_sh_chebyu(NumpyTestCase): def check_sh_chebyu(self): # U*_n(x) = U_n(2x-1) @@ -1958,7 +1958,7 @@ assert_array_almost_equal(Us4.c,use4.c,12) assert_array_almost_equal(Us5.c,use5.c,11) -class _test_sh_jacobi(ScipyTestCase): +class _test_sh_jacobi(NumpyTestCase): def check_sh_jacobi(self): # G^(p,q)_n(x) = n! gamma(n+p)/gamma(2*n+p) * P^(p-q,q-1)_n(2*x-1) @@ -1988,7 +1988,7 @@ assert_array_almost_equal(G5.c,ge5.c,13) -class test_sinc(ScipyTestCase): +class test_sinc(NumpyTestCase): def check_sinc(self): c = arange(-2,2,.1) @@ -2000,7 +2000,7 @@ x = 0.0 assert_equal(sinc(x),1.0) -class test_sindg(ScipyTestCase): +class test_sindg(NumpyTestCase): def check_sindg(self): sn = sindg(90) @@ -2014,13 +2014,13 @@ snmrl1 = sin(pi/4.0) assert_almost_equal(snm1,snmrl1,8) -class test_sph_harm(ScipyTestCase): +class test_sph_harm(NumpyTestCase): def check_sph_harm(self): pass -class test_sph_in(ScipyTestCase): +class test_sph_in(NumpyTestCase): def check_sph_in(self): i1n = sph_in(1,.2) @@ -2030,14 +2030,14 @@ 0.066933714568029540839]),12) assert_array_almost_equal(i1n[1],[inp0,inp1],12) -class test_sph_inkn(ScipyTestCase): +class test_sph_inkn(NumpyTestCase): def check_sph_inkn(self): spikn = r_[sph_in(1,.2)+sph_kn(1,.2)] inkn = r_[sph_inkn(1,.2)] assert_array_almost_equal(inkn,spikn,10) -class test_sph_jn(ScipyTestCase): +class test_sph_jn(NumpyTestCase): def check_sph_jn(self): s1 = sph_jn(2,.2) @@ -2049,14 +2049,14 @@ 0.0026590560795273856680],12) assert_array_almost_equal(s1[1],[s10,s11,s12],12) -class test_sph_jnyn(ScipyTestCase): +class test_sph_jnyn(NumpyTestCase): def check_sph_jnyn(self): jnyn = r_[sph_jn(1,.2) + sph_yn(1,.2)] # tuple addition jnyn1 = r_[sph_jnyn(1,.2)] assert_array_almost_equal(jnyn1,jnyn,9) -class test_sph_kn(ScipyTestCase): +class test_sph_kn(NumpyTestCase): def check_sph_kn(self): kn = sph_kn(2,.2) @@ -2068,7 +2068,7 @@ 585.15696310385559829],12) assert_array_almost_equal(kn[1],[kn0,kn1,kn2],9) -class test_sph_yn(ScipyTestCase): +class test_sph_yn(NumpyTestCase): def check_sph_yn(self): sy1 = sph_yn(2,.2)[0][2] @@ -2079,14 +2079,14 @@ sy3 = sph_yn(1,.2)[1][1] assert_almost_equal(sy3,sphpy,4) #compare correct derivative val. (correct =-system val). -class test_take(ScipyTestCase): +class test_take(NumpyTestCase): def check_take(self): a = array([0,1,2,3,4,5,6,7,8]) tka = take(a,(0,4,5,8),axis=0) assert_array_equal(tka,array([0,4,5,8])) -class test_tandg(ScipyTestCase): +class test_tandg(NumpyTestCase): def check_tandg(self): tn = tandg(30) @@ -2114,21 +2114,21 @@ assert_almost_equal(tandg(315), -1.0, 14) assert_almost_equal(tandg(-315), 1.0, 14) -class test_y0(ScipyTestCase): +class test_y0(NumpyTestCase): def check_y0(self): oz = y0(.1) ozr = yn(0,.1) assert_almost_equal(oz,ozr,8) -class test_y1(ScipyTestCase): +class test_y1(NumpyTestCase): def check_y1(self): o1 = y1(.1) o1r = yn(1,.1) assert_almost_equal(o1,o1r,8) -class test_y0_zeros(ScipyTestCase): +class test_y0_zeros(NumpyTestCase): def check_y0_zeros(self): yo,ypo = y0_zeros(2) @@ -2139,37 +2139,37 @@ assert_array_almost_equal(abs(yv(1,all)-allval),0.0,11) -class test_y1_zeros(ScipyTestCase): +class test_y1_zeros(NumpyTestCase): def check_y1_zeros(self): y1 = y1_zeros(1) assert_array_almost_equal(y1,(array([2.19714]),array([0.52079])),5) -class test_y1p_zeros(ScipyTestCase): +class test_y1p_zeros(NumpyTestCase): def check_y1p_zeros(self): y1p = y1p_zeros(1,complex=1) assert_array_almost_equal(y1p,(array([ 0.5768+0.904j]), array([-0.7635+0.5892j])),3) -class test_yn_zeros(ScipyTestCase): +class test_yn_zeros(NumpyTestCase): def check_yn_zeros(self): an = yn_zeros(4,2) assert_array_almost_equal(an,array([ 5.64515, 9.36162]),5) -class test_ynp_zeros(ScipyTestCase): +class test_ynp_zeros(NumpyTestCase): def check_ynp_zeros(self): ao = ynp_zeros(0,2) assert_array_almost_equal(ao,array([ 2.19714133, 5.42968104]),6) -class test_yn(ScipyTestCase): +class test_yn(NumpyTestCase): def check_yn(self): yn2n = yn(1,.2) assert_almost_equal(yn2n,-3.3238249881118471,8) -class test_yv(ScipyTestCase): +class test_yv(NumpyTestCase): def check_negv(self): assert_almost_equal(yv(-3,2), -yv(3,2), 14) @@ -2177,7 +2177,7 @@ yv2 = yv(1,.2) assert_almost_equal(yv2,-3.3238249881118471,8) -class test_yve(ScipyTestCase): +class test_yve(NumpyTestCase): def check_negv(self): assert_almost_equal(yve(-3,2), -yve(3,2), 14) @@ -2188,14 +2188,14 @@ yve22 = yve(1,.2+1j) assert_almost_equal(yve22,yve2r,8) -class test_yvp(ScipyTestCase): +class test_yvp(NumpyTestCase): def check_yvp(self): yvpr = (yv(1,.2) - yv(3,.2))/2.0 yvp1 = yvp(2,.2) assert_array_almost_equal(yvp1,yvpr,10) -class test_zeros(ScipyTestCase): +class test_zeros(NumpyTestCase): def check_zeros(self): b = zeros((1,11)) @@ -2205,4 +2205,4 @@ [0, 0]])) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/stats/__init__.py =================================================================== --- trunk/Lib/stats/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/stats/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -11,5 +11,5 @@ from kde import gaussian_kde __all__ = filter(lambda s:not s.startswith('_'),dir()) -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/stats/tests/test_distributions.py =================================================================== --- trunk/Lib/stats/tests/test_distributions.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/stats/tests/test_distributions.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -59,7 +59,7 @@ else: args = str(tuple(1.0+rand(nargs))) exstr = r""" -class test_%s(ScipyTestCase): +class test_%s(NumpyTestCase): def check_cdf(self): D,pval = stats.kstest('%s','',args=%s,N=30) if (pval < %f): @@ -71,7 +71,7 @@ exec exstr -class test_randint(ScipyTestCase): +class test_randint(NumpyTestCase): def check_rvs(self): vals = stats.randint.rvs(5,30,size=100) assert(numpy.all(vals < 30) & numpy.all(vals >= 5)) @@ -97,7 +97,7 @@ vals = stats.randint.cdf(x,5,30) assert_array_almost_equal(vals, out, decimal=12) -class test_binom(ScipyTestCase): +class test_binom(NumpyTestCase): def check_rvs(self): vals = stats.binom.rvs(10, 0.75, size=(2, 50)) assert(numpy.all(vals >= 0) & numpy.all(vals <= 10)) @@ -108,7 +108,7 @@ assert(val.dtype.char in typecodes['AllInteger']) -class test_bernoulli(ScipyTestCase): +class test_bernoulli(NumpyTestCase): def check_rvs(self): vals = stats.bernoulli.rvs(0.75, size=(2, 50)) assert(numpy.all(vals >= 0) & numpy.all(vals <= 1)) @@ -118,7 +118,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_nbinom(ScipyTestCase): +class test_nbinom(NumpyTestCase): def check_rvs(self): vals = stats.nbinom.rvs(10, 0.75, size=(2, 50)) assert(numpy.all(vals >= 0)) @@ -128,7 +128,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_geom(ScipyTestCase): +class test_geom(NumpyTestCase): def check_rvs(self): vals = stats.geom.rvs(0.75, size=(2, 50)) assert(numpy.all(vals >= 0)) @@ -138,7 +138,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_hypergeom(ScipyTestCase): +class test_hypergeom(NumpyTestCase): def check_rvs(self): vals = stats.hypergeom.rvs(20, 10, 3, size=(2, 50)) assert(numpy.all(vals >= 0) & @@ -149,7 +149,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_logser(ScipyTestCase): +class test_logser(NumpyTestCase): def check_rvs(self): vals = stats.logser.rvs(0.75, size=(2, 50)) assert(numpy.all(vals >= 1)) @@ -159,7 +159,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_poisson(ScipyTestCase): +class test_poisson(NumpyTestCase): def check_rvs(self): vals = stats.poisson.rvs(0.5, size=(2, 50)) assert(numpy.all(vals >= 0)) @@ -169,7 +169,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_zipf(ScipyTestCase): +class test_zipf(NumpyTestCase): def check_rvs(self): vals = stats.zipf.rvs(1.5, size=(2, 50)) assert(numpy.all(vals >= 1)) @@ -179,7 +179,7 @@ assert(isinstance(val, numpy.ndarray)) assert(val.dtype.char in typecodes['AllInteger']) -class test_dlaplace(ScipyTestCase): +class test_dlaplace(NumpyTestCase): def check_rvs(self): vals = stats.dlaplace.rvs(1.5 , size=(2, 50)) assert(numpy.shape(vals) == (2, 50)) @@ -189,4 +189,4 @@ assert(val.dtype.char in typecodes['AllInteger']) if __name__ == "__main__": - ScipyTest('stats.distributions').run() + NumpyTest('stats.distributions').run() Modified: trunk/Lib/stats/tests/test_morestats.py =================================================================== --- trunk/Lib/stats/tests/test_morestats.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/stats/tests/test_morestats.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -22,7 +22,7 @@ g9 = [1.002, 0.998, 0.996, 0.995, 0.996, 1.004, 1.004, 0.998, 0.999, 0.991] g10= [0.991, 0.995, 0.984, 0.994, 0.997, 0.997, 0.991, 0.998, 1.004, 0.997] -class test_shapiro(ScipyTestCase): +class test_shapiro(NumpyTestCase): def check_basic(self): x1 = [0.11,7.87,4.61,10.14,7.95,3.14,0.46, 4.43,0.21,4.75,0.71,1.52,3.24, @@ -37,7 +37,7 @@ assert_almost_equal(w,0.9590270,6) assert_almost_equal(pw,0.52460,3) -class test_anderson(ScipyTestCase): +class test_anderson(NumpyTestCase): def check_normal(self): x1 = scipy.stats.expon.rvs(size=50) x2 = scipy.stats.norm.rvs(size=50) @@ -58,7 +58,7 @@ A,crit,sig = scipy.stats.anderson(x2,'expon') assert_array_less(crit[:-1], A) -class test_ansari(ScipyTestCase): +class test_ansari(NumpyTestCase): def check_small(self): x = [1,2,3,3,4] y = [3,2,6,1,6,1,4,1] @@ -80,7 +80,7 @@ assert_almost_equal(W,10.0,11) assert_almost_equal(pval,0.533333333333333333,7) -class test_bartlett(ScipyTestCase): +class test_bartlett(NumpyTestCase): def check_data(self): args = [] for k in range(1,11): @@ -89,7 +89,7 @@ assert_almost_equal(T,20.78587342806484,7) assert_almost_equal(pval,0.0136358632781,7) -class test_levene(ScipyTestCase): +class test_levene(NumpyTestCase): def check_data(self): args = [] for k in range(1,11): @@ -98,7 +98,7 @@ assert_almost_equal(W,1.7059176930008939,7) assert_almost_equal(pval,0.0990829755522,7) -class test_binom_test(ScipyTestCase): +class test_binom_test(NumpyTestCase): def check_data(self): pval = stats.binom_test(100,250) assert_almost_equal(pval,0.0018833009350757682,11) @@ -107,7 +107,7 @@ pval = stats.binom_test([682,243],p=3.0/4) assert_almost_equal(pval,0.38249155957481695,11) -class test_find_repeats(ScipyTestCase): +class test_find_repeats(NumpyTestCase): def check_basic(self): a = [1,2,3,4,1,2,3,4,1,2,5] res,nums = scipy.stats.find_repeats(a) @@ -115,4 +115,4 @@ assert_array_equal(nums,[3,3,2,2]) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/stats/tests/test_stats.py =================================================================== --- trunk/Lib/stats/tests/test_stats.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/stats/tests/test_stats.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -48,7 +48,7 @@ X8 = X7 * X X9 = X8 * X -class test_round(ScipyTestCase): +class test_round(NumpyTestCase): """ W.II. ROUND You should get the numbers 1 to 9. Many language compilers, @@ -98,7 +98,7 @@ y=(int(round((3-numpy.exp(numpy.log(numpy.sqrt(2.0)*numpy.sqrt(2.0))))))) assert_equal(y,1) -class test_basicstats(ScipyTestCase): +class test_basicstats(NumpyTestCase): """ W.II.C. Compute basic statistic on all the variables. The means should be the fifth value of all the variables (case FIVE). @@ -184,7 +184,7 @@ y = scipy.stats.std(ROUND) assert_approx_equal(y, 2.738612788) -class test_corr(ScipyTestCase): +class test_corr(NumpyTestCase): """ W.II.D. Compute a correlation matrix on all the variables. All the correlations, except for ZERO and MISS, shoud be exactly 1. @@ -371,7 +371,7 @@ ### I need to figure out how to do this one. -class test_regression(ScipyTestCase): +class test_regression(NumpyTestCase): def check_linregressBIGX(self): """ W.II.F. Regress BIG on X. @@ -436,7 +436,7 @@ ################################################## ### Test for sum -class test_gmean(ScipyTestCase): +class test_gmean(NumpyTestCase): def check_1D_list(self): a = (1,2,3,4) @@ -475,7 +475,7 @@ desired = array((v,v,v)) assert_array_almost_equal(desired,actual,decimal=14) -class test_hmean(ScipyTestCase): +class test_hmean(NumpyTestCase): def check_1D_list(self): a = (1,2,3,4) actual= stats.hmean(a) @@ -515,7 +515,7 @@ assert_array_almost_equal(desired1,actual1,decimal=14) -class test_mean(ScipyTestCase): +class test_mean(NumpyTestCase): def check_basic(self): a = [3,4,5,10,-3,-5,6] af = [3.,4,5,10,-3,-5,-6] @@ -552,7 +552,7 @@ A += val assert_almost_equal(stats.mean(a,axis=None),A/(5*3.0*5)) -class test_median(ScipyTestCase): +class test_median(NumpyTestCase): def check_basic(self): a1 = [3,4,5,10,-3,-5,6] a2 = [3,-6,-2,8,7,4,2,1] @@ -561,7 +561,7 @@ assert_equal(stats.median(a2),2.5) assert_equal(stats.median(a3),3.5) -class test_percentile(ScipyTestCase): +class test_percentile(NumpyTestCase): def setUp(self): self.a1 = [3,4,5,10,-3,-5,6] self.a2 = [3,-6,-2,8,7,4,2,1] @@ -578,7 +578,7 @@ assert_equal(stats.scoreatpercentile(x, 100), 3.5) assert_equal(stats.scoreatpercentile(x, 50), 1.75) -class test_std(ScipyTestCase): +class test_std(NumpyTestCase): def check_basic(self): a = [3,4,5,10,-3,-5,6] b = [3,4,5,10,-3,-5,-6] @@ -597,21 +597,21 @@ assert_array_almost_equal(stats.std(a,axis=1),b2,11) -class test_cmedian(ScipyTestCase): +class test_cmedian(NumpyTestCase): def check_basic(self): data = [1,2,3,1,5,3,6,4,3,2,4,3,5,2.0] assert_almost_equal(stats.cmedian(data,5),3.2916666666666665) assert_almost_equal(stats.cmedian(data,3),3.083333333333333) assert_almost_equal(stats.cmedian(data),3.0020020020020022) -class test_median(ScipyTestCase): +class test_median(NumpyTestCase): def check_basic(self): data1 = [1,3,5,2,3,1,19,-10,2,4.0] data2 = [3,5,1,10,23,-10,3,-2,6,8,15] assert_almost_equal(stats.median(data1),2.5) assert_almost_equal(stats.median(data2),5) -class test_mode(ScipyTestCase): +class test_mode(NumpyTestCase): def check_basic(self): data1 = [3,5,1,10,23,3,2,6,8,6,10,6] vals = stats.mode(data1) @@ -619,7 +619,7 @@ assert_almost_equal(vals[1][0],3) -class test_variability(ScipyTestCase): +class test_variability(NumpyTestCase): """ Comparison numbers are found using R v.1.5.1 note that length(testcase) = 4 """ @@ -699,7 +699,7 @@ -class test_moments(ScipyTestCase): +class test_moments(NumpyTestCase): """ Comparison numbers are found using R v.1.5.1 note that length(testcase) = 4 @@ -759,7 +759,7 @@ y = scipy.stats.kurtosis(self.testcase,0,0) assert_approx_equal(y,1.64) -class test_threshold(ScipyTestCase): +class test_threshold(NumpyTestCase): def check_basic(self): a = [-1,2,3,4,5,-1,-2] assert_array_equal(stats.threshold(a),a) @@ -771,4 +771,4 @@ [0,2,3,4,0,0,0]) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/__init__.py =================================================================== --- trunk/Lib/weave/__init__.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/__init__.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -18,5 +18,5 @@ except: pass -from numpy.testing import ScipyTest -test = ScipyTest().test +from numpy.testing import NumpyTest +test = NumpyTest().test Modified: trunk/Lib/weave/tests/test_ast_tools.py =================================================================== --- trunk/Lib/weave/tests/test_ast_tools.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_ast_tools.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -8,7 +8,7 @@ from weave_test_utils import * restore_path() -class test_harvest_variables(ScipyTestCase): +class test_harvest_variables(NumpyTestCase): """ Not much testing going on here, but at least it is a flame test. """ @@ -28,4 +28,4 @@ self.generic_test(expr,desired) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_blitz_tools.py =================================================================== --- trunk/Lib/weave/tests/test_blitz_tools.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_blitz_tools.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -14,7 +14,7 @@ restore_path() -class test_ast_to_blitz_expr(ScipyTestCase): +class test_ast_to_blitz_expr(NumpyTestCase): def generic_test(self,expr,desired): import parser @@ -57,7 +57,7 @@ '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));' self.generic_test(expr,desired) -class test_blitz(ScipyTestCase): +class test_blitz(NumpyTestCase): """* These are long running tests... I'd like to benchmark these things somehow. @@ -174,4 +174,4 @@ self.generic_2d(expr,complex128) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_build_tools.py =================================================================== --- trunk/Lib/weave/tests/test_build_tools.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_build_tools.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -12,7 +12,7 @@ def is_writable(val): return os.access(val,os.W_OK) -class test_configure_build_dir(ScipyTestCase): +class test_configure_build_dir(NumpyTestCase): def check_default(self): " default behavior is to return current directory " d = build_tools.configure_build_dir() @@ -46,7 +46,7 @@ assert(d == tempfile.gettempdir()) assert(is_writable(d)) -class test_configure_sys_argv(ScipyTestCase): +class test_configure_sys_argv(NumpyTestCase): def check_simple(self): build_dir = 'build_dir' temp_dir = 'temp_dir' @@ -63,4 +63,4 @@ assert(pre_argv == sys.argv[:]) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_c_spec.py =================================================================== --- trunk/Lib/weave/tests/test_c_spec.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_c_spec.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -48,7 +48,7 @@ # Scalar conversion test classes # int, float, complex #---------------------------------------------------------------------------- -class test_int_converter(ScipyTestCase): +class test_int_converter(NumpyTestCase): compiler = '' def check_type_match_string(self,level=5): s = c_spec.int_converter() @@ -103,7 +103,7 @@ assert( c == 3) -class test_float_converter(ScipyTestCase): +class test_float_converter(NumpyTestCase): compiler = '' def check_type_match_string(self,level=5): s = c_spec.float_converter() @@ -158,7 +158,7 @@ c = test(b) assert( c == 3.) -class test_complex_converter(ScipyTestCase): +class test_complex_converter(NumpyTestCase): compiler = '' def check_type_match_string(self,level=5): s = c_spec.complex_converter() @@ -216,7 +216,7 @@ # File conversion tests #---------------------------------------------------------------------------- -class test_file_converter(ScipyTestCase): +class test_file_converter(NumpyTestCase): compiler = '' def check_py_to_file(self,level=5): import tempfile @@ -250,14 +250,14 @@ # Instance conversion tests #---------------------------------------------------------------------------- -class test_instance_converter(ScipyTestCase): +class test_instance_converter(NumpyTestCase): pass #---------------------------------------------------------------------------- # Callable object conversion tests #---------------------------------------------------------------------------- -class test_callable_converter(ScipyTestCase): +class test_callable_converter(NumpyTestCase): compiler='' def check_call_function(self,level=5): import string @@ -277,7 +277,7 @@ desired = func(search_str,sub_str) assert(desired == actual) -class test_sequence_converter(ScipyTestCase): +class test_sequence_converter(NumpyTestCase): compiler = '' def check_convert_to_dict(self,level=5): d = {} @@ -292,7 +292,7 @@ t = () inline_tools.inline("",['t'],compiler=self.compiler,force=1) -class test_string_converter(ScipyTestCase): +class test_string_converter(NumpyTestCase): compiler = '' def check_type_match_string(self,level=5): s = c_spec.string_converter() @@ -347,7 +347,7 @@ c = test(b) assert( c == 'hello') -class test_list_converter(ScipyTestCase): +class test_list_converter(NumpyTestCase): compiler = '' def check_type_match_bad(self,level=5): s = c_spec.list_converter() @@ -458,7 +458,7 @@ print 'python:', t2 - t1 assert( sum1 == sum2 and sum1 == sum3) -class test_tuple_converter(ScipyTestCase): +class test_tuple_converter(NumpyTestCase): compiler = '' def check_type_match_bad(self,level=5): s = c_spec.tuple_converter() @@ -511,7 +511,7 @@ assert( c == ('hello',None)) -class test_dict_converter(ScipyTestCase): +class test_dict_converter(NumpyTestCase): def check_type_match_bad(self,level=5): s = c_spec.dict_converter() objs = [[],(),'',1,1.,1+1j] @@ -674,4 +674,4 @@ if _n[:9]=='test_gcc_': exec 'del '+_n if __name__ == "__main__": - ScipyTest('weave.c_spec').run() + NumpyTest('weave.c_spec').run() Modified: trunk/Lib/weave/tests/test_catalog.py =================================================================== --- trunk/Lib/weave/tests/test_catalog.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_catalog.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -11,7 +11,7 @@ restore_path() -class test_default_dir(ScipyTestCase): +class test_default_dir(NumpyTestCase): def check_is_writable(self): path = catalog.default_dir() name = os.path.join(path,'dummy_catalog') @@ -22,10 +22,10 @@ test_file.close() os.remove(name) -class test_os_dependent_catalog_name(ScipyTestCase): +class test_os_dependent_catalog_name(NumpyTestCase): pass -class test_catalog_path(ScipyTestCase): +class test_catalog_path(NumpyTestCase): def check_default(self): in_path = catalog.default_dir() path = catalog.catalog_path(in_path) @@ -64,7 +64,7 @@ path = catalog.catalog_path(in_path) assert (path is None) -class test_get_catalog(ScipyTestCase): +class test_get_catalog(NumpyTestCase): """ This only tests whether new catalogs are created correctly. And whether non-existent return None correctly with read mode. Putting catalogs in the right place is all tested with @@ -98,7 +98,7 @@ self.remove_dir(pardir) assert(cat is not None) -class test_catalog(ScipyTestCase): +class test_catalog(NumpyTestCase): def clear_environ(self): if os.environ.has_key('PYTHONCOMPILED'): @@ -331,4 +331,4 @@ if __name__ == '__main__': - ScipyTest('weave.catalog').run() + NumpyTest('weave.catalog').run() Modified: trunk/Lib/weave/tests/test_ext_tools.py =================================================================== --- trunk/Lib/weave/tests/test_ext_tools.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_ext_tools.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -17,7 +17,7 @@ build_dir = empty_temp_dir() print 'building extensions here:', build_dir -class test_ext_module(ScipyTestCase): +class test_ext_module(NumpyTestCase): #should really do some testing of where modules end up def check_simple(self,level=5): """ Simplest possible module """ @@ -94,7 +94,7 @@ c,d = ext_return_tuple.test(a) assert(c==a and d == a+1) -class test_ext_function(ScipyTestCase): +class test_ext_function(NumpyTestCase): #should really do some testing of where modules end up def check_simple(self,level=5): """ Simplest possible function """ @@ -107,7 +107,7 @@ import simple_ext_function simple_ext_function.test() -class test_assign_variable_types(ScipyTestCase): +class test_assign_variable_types(NumpyTestCase): def check_assign_variable_types(self): try: from numpy.numerix import arange, Float32, Float64 @@ -135,4 +135,4 @@ print_assert_equal(expr,actual,desired) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_inline_tools.py =================================================================== --- trunk/Lib/weave/tests/test_inline_tools.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_inline_tools.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -9,7 +9,7 @@ from test_scxx import * restore_path() -class test_inline(ScipyTestCase): +class test_inline(NumpyTestCase): """ These are long running tests... I'd like to benchmark these things somehow. @@ -43,4 +43,4 @@ pass if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_scxx.py =================================================================== --- trunk/Lib/weave/tests/test_scxx.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_scxx.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -12,4 +12,4 @@ restore_path() if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_scxx_dict.py =================================================================== --- trunk/Lib/weave/tests/test_scxx_dict.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_scxx_dict.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -9,7 +9,7 @@ restore_path() -class test_dict_construct(ScipyTestCase): +class test_dict_construct(NumpyTestCase): #------------------------------------------------------------------------ # Check that construction from basic types is allowed and have correct # reference counts @@ -25,7 +25,7 @@ assert res == {} -class test_dict_has_key(ScipyTestCase): +class test_dict_has_key(NumpyTestCase): def check_obj(self,level=5): class foo: pass @@ -89,7 +89,7 @@ res = inline_tools.inline(code,['a']) assert not res -class test_dict_get_item_op(ScipyTestCase): +class test_dict_get_item_op(NumpyTestCase): def generic_get(self,code,args=['a']): a = {} @@ -132,7 +132,7 @@ except KeyError: pass -class test_dict_set_operator(ScipyTestCase): +class test_dict_set_operator(NumpyTestCase): def generic_new(self,key,val): # test that value is set correctly and that reference counts # on dict, key, and val are being handled correctly. @@ -199,7 +199,7 @@ key,val = foo(),12345 self.generic_overwrite(key,val) -class test_dict_del(ScipyTestCase): +class test_dict_del(NumpyTestCase): def generic(self,key): # test that value is set correctly and that reference counts # on dict, key, are being handled correctly. after deletion, @@ -233,7 +233,7 @@ key = foo() self.generic(key) -class test_dict_others(ScipyTestCase): +class test_dict_others(NumpyTestCase): def check_clear(self,level=5): a = {} a["hello"] = 1 @@ -262,4 +262,4 @@ assert a == b if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_scxx_object.py =================================================================== --- trunk/Lib/weave/tests/test_scxx_object.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_scxx_object.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -8,7 +8,7 @@ from weave import inline_tools restore_path() -class test_object_construct(ScipyTestCase): +class test_object_construct(NumpyTestCase): #------------------------------------------------------------------------ # Check that construction from basic types is allowed and have correct # reference counts @@ -66,7 +66,7 @@ assert sys.getrefcount(res) == 2 assert res == "hello" -class test_object_print(ScipyTestCase): +class test_object_print(NumpyTestCase): #------------------------------------------------------------------------ # Check the object print protocol. #------------------------------------------------------------------------ @@ -101,7 +101,7 @@ ## pass -class test_object_cast(ScipyTestCase): +class test_object_cast(NumpyTestCase): def check_int_cast(self,level=5): code = """ py::object val = 1; @@ -147,7 +147,7 @@ def __str__(self): return "b" -class test_object_hasattr(ScipyTestCase): +class test_object_hasattr(NumpyTestCase): def check_string(self,level=5): a = foo() a.b = 12345 @@ -203,7 +203,7 @@ res = inline_tools.inline(code,['a']) assert res -class test_object_attr(ScipyTestCase): +class test_object_attr(NumpyTestCase): def generic_attr(self,code,args=['a']): a = foo() @@ -261,7 +261,7 @@ assert res == "bar results" assert first == second -class test_object_set_attr(ScipyTestCase): +class test_object_set_attr(NumpyTestCase): def generic_existing(self, code, desired): args = ['a'] @@ -325,7 +325,7 @@ """ self.generic_existing(code,"hello") -class test_object_del(ScipyTestCase): +class test_object_del(NumpyTestCase): def generic(self, code): args = ['a'] a = foo() @@ -348,7 +348,7 @@ """ self.generic(code) -class test_object_cmp(ScipyTestCase): +class test_object_cmp(NumpyTestCase): def check_equal(self,level=5): a,b = 1,1 res = inline_tools.inline('return_val = (a == b);',['a','b']) @@ -411,7 +411,7 @@ res = inline_tools.inline(code,['a']) assert res == (a == "hello") -class test_object_repr(ScipyTestCase): +class test_object_repr(NumpyTestCase): def check_repr(self,level=5): class foo: def __str__(self): @@ -427,7 +427,7 @@ assert first == second assert res == "repr return" -class test_object_str(ScipyTestCase): +class test_object_str(NumpyTestCase): def check_str(self,level=5): class foo: def __str__(self): @@ -444,7 +444,7 @@ print res assert res == "str return" -class test_object_unicode(ScipyTestCase): +class test_object_unicode(NumpyTestCase): # This ain't going to win awards for test of the year... def check_unicode(self,level=5): class foo: @@ -461,7 +461,7 @@ assert first == second assert res == "unicode" -class test_object_is_callable(ScipyTestCase): +class test_object_is_callable(NumpyTestCase): def check_true(self,level=5): class foo: def __call__(self): @@ -476,7 +476,7 @@ res = inline_tools.inline('return_val = a.is_callable();',['a']) assert not res -class test_object_call(ScipyTestCase): +class test_object_call(NumpyTestCase): def check_noargs(self,level=5): def foo(): return (1,2,3) @@ -532,7 +532,7 @@ # first should == second, but the weird refcount error assert second == third -class test_object_mcall(ScipyTestCase): +class test_object_mcall(NumpyTestCase): def check_noargs(self,level=5): a = foo() res = inline_tools.inline('return_val = a.mcall("bar");',['a']) @@ -626,7 +626,7 @@ # first should == second, but the weird refcount error assert second == third -class test_object_hash(ScipyTestCase): +class test_object_hash(NumpyTestCase): def check_hash(self,level=5): class foo: def __hash__(self): @@ -636,7 +636,7 @@ print 'hash:', res assert res == 123 -class test_object_is_true(ScipyTestCase): +class test_object_is_true(NumpyTestCase): def check_true(self,level=5): class foo: pass @@ -648,7 +648,7 @@ res = inline_tools.inline('return_val = a.is_true();',['a']) assert res == 0 -class test_object_is_true(ScipyTestCase): +class test_object_is_true(NumpyTestCase): def check_false(self,level=5): class foo: pass @@ -660,7 +660,7 @@ res = inline_tools.inline('return_val = a.not();',['a']) assert res == 1 -class test_object_type(ScipyTestCase): +class test_object_type(NumpyTestCase): def check_type(self,level=5): class foo: pass @@ -668,7 +668,7 @@ res = inline_tools.inline('return_val = a.type();',['a']) assert res == type(a) -class test_object_size(ScipyTestCase): +class test_object_size(NumpyTestCase): def check_size(self,level=5): class foo: def __len__(self): @@ -692,7 +692,7 @@ assert res == len(a) from UserList import UserList -class test_object_set_item_op_index(ScipyTestCase): +class test_object_set_item_op_index(NumpyTestCase): def check_list_refcount(self,level=5): a = UserList([1,2,3]) # temporary refcount fix until I understand why it incs by one. @@ -727,7 +727,7 @@ assert a[1] == 1+1j from UserDict import UserDict -class test_object_set_item_op_key(ScipyTestCase): +class test_object_set_item_op_key(NumpyTestCase): def check_key_refcount(self,level=5): a = UserDict() code = """ @@ -818,4 +818,4 @@ assert a['first'] == a['second'] if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_scxx_sequence.py =================================================================== --- trunk/Lib/weave/tests/test_scxx_sequence.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_scxx_sequence.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -20,7 +20,7 @@ from UserList import UserList -class _test_sequence_base(ScipyTestCase): +class _test_sequence_base(NumpyTestCase): seq_type = None def check_conversion(self,level=5): @@ -435,4 +435,4 @@ assert b == desired if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_size_check.py =================================================================== --- trunk/Lib/weave/tests/test_size_check.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_size_check.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -11,7 +11,7 @@ empty = array(()) -class test_make_same_length(ScipyTestCase): +class test_make_same_length(NumpyTestCase): def generic_test(self,x,y,desired): actual = size_check.make_same_length(x,y) @@ -39,7 +39,7 @@ desired = array((1,2,3)),array((1,1,2)) self.generic_test(x,y,desired) -class test_binary_op_size(ScipyTestCase): +class test_binary_op_size(NumpyTestCase): def generic_test(self,x,y,desired): actual = size_check.binary_op_size(x,y) desired = desired @@ -115,7 +115,7 @@ def desired_type(self,val): return size_check.dummy_array(array(val),1) -class test_dummy_array_indexing(ScipyTestCase): +class test_dummy_array_indexing(NumpyTestCase): def generic_test(self,ary,expr,desired): a = size_check.dummy_array(ary) actual = eval(expr).shape @@ -269,7 +269,7 @@ except IndexError: pass -class test_reduction(ScipyTestCase): +class test_reduction(NumpyTestCase): def check_1d_0(self): a = ones((5,)) actual = size_check.reduction(a,0) @@ -303,7 +303,7 @@ except ValueError: pass -class test_expressions(ScipyTestCase): +class test_expressions(NumpyTestCase): def generic_test(self,expr,desired,**kw): import parser ast_list = parser.expr(expr).tolist() @@ -372,4 +372,4 @@ if __name__ == "__main__": - ScipyTest('weave.size_check').run() + NumpyTest('weave.size_check').run() Modified: trunk/Lib/weave/tests/test_slice_handler.py =================================================================== --- trunk/Lib/weave/tests/test_slice_handler.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_slice_handler.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -22,7 +22,7 @@ pprint.pprint(desired,msg) raise AssertionError, msg.getvalue() -class test_build_slice_atom(ScipyTestCase): +class test_build_slice_atom(NumpyTestCase): def generic_test(self,slice_vars,desired): pos = slice_vars['pos'] ast_list = slice_handler.build_slice_atom(slice_vars,pos) @@ -34,7 +34,7 @@ desired = 'slice(1,2-1)' self.generic_test(slice_vars,desired) -class test_slice(ScipyTestCase): +class test_slice(NumpyTestCase): def generic_test(self,suite_string,desired): import parser @@ -135,7 +135,7 @@ out = string.replace(out,"\n","") return out -class test_transform_slices(ScipyTestCase): +class test_transform_slices(NumpyTestCase): def generic_test(self,suite_string,desired): import parser ast_list = parser.suite(suite_string).tolist() @@ -164,4 +164,4 @@ if __name__ == "__main__": - ScipyTest('weave.slice_handler').run() + NumpyTest('weave.slice_handler').run() Modified: trunk/Lib/weave/tests/test_standard_array_spec.py =================================================================== --- trunk/Lib/weave/tests/test_standard_array_spec.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_standard_array_spec.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -28,7 +28,7 @@ pprint.pprint(desired,msg) raise AssertionError, msg.getvalue() -class test_array_converter(ScipyTestCase): +class test_array_converter(NumpyTestCase): def check_type_match_string(self): s = standard_array_spec.array_converter() assert( not s.type_match('string') ) @@ -40,4 +40,4 @@ assert(s.type_match(arange(4))) if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() Modified: trunk/Lib/weave/tests/test_wx_spec.py =================================================================== --- trunk/Lib/weave/tests/test_wx_spec.py 2007-01-11 01:03:26 UTC (rev 2528) +++ trunk/Lib/weave/tests/test_wx_spec.py 2007-01-11 04:22:41 UTC (rev 2529) @@ -16,7 +16,7 @@ import wxPython import wxPython.wx -class test_wx_converter(ScipyTestCase): +class test_wx_converter(NumpyTestCase): def check_type_match_string(self,level=5): s = wx_spec.wx_converter() assert(not s.type_match('string') ) @@ -91,4 +91,4 @@ assert( c == 'hello') if __name__ == "__main__": - ScipyTest().run() + NumpyTest().run() From scipy-svn at scipy.org Thu Jan 11 01:19:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 00:19:34 -0600 (CST) Subject: [Scipy-svn] r2530 - in trunk/Lib/sandbox/newoptimize: . tnc Message-ID: <20070111061934.A0C5F39C0D3@new.scipy.org> Author: jarrod.millman Date: 2007-01-11 00:19:21 -0600 (Thu, 11 Jan 2007) New Revision: 2530 Added: trunk/Lib/sandbox/newoptimize/tnc.py trunk/Lib/sandbox/newoptimize/tnc/ trunk/Lib/sandbox/newoptimize/tnc/HISTORY trunk/Lib/sandbox/newoptimize/tnc/LICENSE trunk/Lib/sandbox/newoptimize/tnc/README trunk/Lib/sandbox/newoptimize/tnc/example.c trunk/Lib/sandbox/newoptimize/tnc/example.py trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c trunk/Lib/sandbox/newoptimize/tnc/tnc.c trunk/Lib/sandbox/newoptimize/tnc/tnc.h Log: initial check-in of tnc version 1.3 Added: trunk/Lib/sandbox/newoptimize/tnc/HISTORY =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/HISTORY 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/HISTORY 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,26 @@ +# TNC Release History +# $Jeannot: HISTORY,v 1.15 2005/01/28 18:27:31 js Exp $ + +01/28/2005, V1.3 : Fix a bug in the anti-zigzaging mechanism (many thanks + to S.G. NASH). + Warning: API changes: refined stopping criterions (xtol, + pgtol). ftol is no more relative to the value of f. + new parameter offset to translate the coordinates +04/18/2004, V1.2.5 : n==0 is now valid +04/14/2004, V1.2.4 : Fix a potential bug in the Python interface (infinity==0) +04/14/2004, V1.2.3 : Fix a bug in the Python interface (reference counting) +04/13/2004, V1.2.2 : Fix a bug in the Python interface (memory allocation) +04/13/2004, V1.2.1 : Fix a bug in the Python interface (scaling ignored) +04/03/2004, V1.2 : Memory allocation checks +04/02/2004, V1.1 : Setup script for the python module + Ability to abort the minimization at any time + Warning: API changes: the user supplied function must now + return an int. +03/22/2004, V1.0.5 : Python Module +10/15/2003, V1.0.4 : Warning: API changes: TNC now returns the number of + function evaluations. + Return code messages strings. +01/25/2003, V1.0.3 : Default values to remove Visual C++ complaint. +10/02/2002, V1.0.2 : Make g a facultative parameter. +09/26/2002, V1.0.1 : Fix bug when |g| is exactly zero at the initial point. +09/21/2002, V1.0 : First release. Added: trunk/Lib/sandbox/newoptimize/tnc/LICENSE =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/LICENSE 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/LICENSE 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,20 @@ +Copyright (c) 2002-2005, Jean-Sebastien Roy (js at jeannot.org) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Added: trunk/Lib/sandbox/newoptimize/tnc/README =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/README 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/README 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,77 @@ +# TNC : truncated newton bound contrained minimization in C +# Version 1.3 +# Copyright J.S. Roy (js at jeannot.org), 2002-2005 +# See the LICENSE file for copyright information. +# $Jeannot: README,v 1.32 2005/01/28 15:12:09 js Exp $ + +This software is a C implementation of TNBC, a truncated newton minimization +package originally developed by Stephen G. Nash in Fortran. + +The original source code can be found at : +http://iris.gmu.edu/~snash/nash/software/software.html + +Copyright for the original TNBC Fortran routines: + + TRUNCATED-NEWTON METHOD: SUBROUTINES + WRITTEN BY: STEPHEN G. NASH + SCHOOL OF INFORMATION TECHNOLOGY & ENGINEERING + GEORGE MASON UNIVERSITY + FAIRFAX, VA 22030 + +This software aims at minimizing the value a of nonlinear function whose +variables are subject to bound constraints. It requires to be able to evaluate +the function and its gradient and is especially useful for solving large scale +problems. + +This software has been rewritten from the Fortran into C and provides the +following modifications : +- reentrancy (no global variables) ; +- ability to pass a pointer to the function to be optimized (to provide + access to constants) ; +- ability to rescale the function and variables ; +- better handling of constant (low == up) variables ; +- a simpler convergence test ; +- ability to end the minimization at any time ; +And many other small changes. + +This software has been tested on a large number of platforms and should run +on any POSIX platform with an ANSI C compiler. + +The last version (and other software) is avalaible at the URL : +http://www.jeannot.org/~js/code/index.en.html + +A Python interface module is also provided. + +Contents : +- tnc.c : Source +- tnc.h : Header, and API documentation +- LICENSE : License and copyright information +- HISTORY : Release history +- README : This file +- example.c : A simple example +- Makefile : Make file used to build the examples +- moduleTNC.c : the source of the python module +- tnc.py : the python module wrapper +- example.py : an example for the python module +- setup.py : the python installer + +Use is described in tnc.h. For more information, see the example. +The example can be built and executed by doing : + make test + +You may need to adjust the Makefile before building tnc. + +To install the module in the current directory, use: + python setup.py build_ext --inplace +To test it, execute: + python tnc.py +To install it globaly, use: + python setup.py install + +Thanks to eric jones for providing the setup script. + +If you make use of this software and observe incorrect behavior on some +problems, or if you make modifications to it (for a specific platform for +example), you are encouraged to send the sources involved to the author at +the following email : js at jeannot.org +Thanks ! Added: trunk/Lib/sandbox/newoptimize/tnc/example.c =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/example.c 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/example.c 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,49 @@ +/* TNC : Minimization example */ +/* $Jeannot: example.c,v 1.19 2005/01/28 18:27:31 js Exp $ */ + +#include +#include +#include + +#include "tnc.h" + +static tnc_function function; + +static int function(double x[], double *f, double g[], void *state) +{ + *f = pow(x[0],2.0)+pow(fabs(x[1]),3.0); + g[0] = 2.0*x[0]; + g[1] = 3.0*pow(fabs(x[1]),2.0); + if(x[1]<0) g[1] = -g[1]; + return 0; +} + +int main(int argc, char **argv) +{ + int i, rc, maxCGit = 2, maxnfeval = 20, nfeval; + double fopt = 1.0, f, g[2], + x[2] = {-7.0, 3.0}, + xopt[2] = {0.0, 1.0}, + low[2], up[2], + eta = -1.0, stepmx = -1.0, + accuracy = -1.0, fmin = 0.0, ftol = -1.0, xtol = -1.0, pgtol = -1.0, + rescale = -1.0; + + low[0] = - HUGE_VAL; low[1] = 1.0; + up[0] = HUGE_VAL; up[1] = HUGE_VAL; + + rc = tnc(2, x, &f, g, function, NULL, low, up, NULL, NULL, TNC_MSG_ALL, + maxCGit, maxnfeval, eta, stepmx, accuracy, fmin, ftol, xtol, pgtol, + rescale, &nfeval); + + printf("After %d function evaluations, TNC returned:\n%s\n", nfeval, + tnc_rc_string[rc - TNC_MINRC]); + + for (i = 0; i < 2; i++) + printf("x[%d] = %.15f / xopt[%d] = %.15f\n", i, x[i], i, xopt[i]); + + printf("\n"); + printf("f = %.15f / fopt = %.15f\n", f, fopt); + + return 0; +} Added: trunk/Lib/sandbox/newoptimize/tnc/example.py =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/example.py 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/example.py 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# Python TNC example +# @(#) $Jeannot: example.py,v 1.4 2004/04/02 18:51:04 js Exp $ + +import tnc + +# A function to minimize +# Must return a tuple with the function value and the gradient (as a list) +# or None to abort the minimization +def function(x): + f = pow(x[0],2.0)+pow(abs(x[1]),3.0) + g = [0,0] + g[0] = 2.0*x[0] + g[1] = 3.0*pow(abs(x[1]),2.0) + if x[1]<0: + g[1] = -g[1] + return f, g + +# Optimizer call +rc, nf, x = tnc.minimize(function, [-7, 3], [-10, 1], [10, 10]) + +print "After", nf, "function evaluations, TNC returned:", tnc.RCSTRINGS[rc] +print "x =", x +print "exact value = [0, 1]" Added: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,310 @@ +/* Python TNC module */ + +/* + * Copyright (c) 2004-2005, Jean-Sebastien Roy (js at jeannot.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +static char const rcsid[] = + "@(#) $Jeannot: moduleTNC.c,v 1.12 2005/01/28 18:27:31 js Exp $"; + +#include +#include +#include +#include "Python.h" + +#include "tnc.h" + +typedef struct _pytnc_state +{ + PyObject *py_function; + int n; + int failed; +} pytnc_state; + +static tnc_function function; +static PyObject *moduleTNC_minimize(PyObject *self, PyObject *args); +static int PyObject_AsDouble(PyObject *py_obj, double *x); +static double *PyList_AsDoubleArray(PyObject *py_list, int *size); +static PyObject *PyDoubleArray_AsList(int size, double *x); +static int PyList_IntoDoubleArray(PyObject *py_list, double *x, int size); + +int PyObject_AsDouble(PyObject *py_obj, double *x) +{ + PyObject *py_float; + + py_float = PyNumber_Float(py_obj); + + if (py_float == NULL) return -1; + + *x = PyFloat_AsDouble(py_float); + + Py_DECREF(py_float); + return 0; +} + +double *PyList_AsDoubleArray(PyObject *py_list, int *size) +{ + int i; + double *x; + + if (!PyList_Check(py_list)) + { + *size = -1; + return NULL; + } + + *size = PyList_Size(py_list); + if (*size <= 0) return NULL; + x = malloc((*size)*sizeof(*x)); + if (x == NULL) return NULL; + + for (i=0; i<(*size); i++) + { + PyObject *py_float = PyList_GetItem(py_list, i); + if (py_float == NULL || PyObject_AsDouble(py_float, &(x[i]))) + { + free(x); + return NULL; + } + } + + return x; +} + +int PyList_IntoDoubleArray(PyObject *py_list, double *x, int size) +{ + int i; + + if (py_list == NULL) return 1; + + if (!PyList_Check(py_list)) return 1; + + if (size != PyList_Size(py_list)) return 1; + + for (i=0; in, x); + if (py_list == NULL) + { + PyErr_SetString(PyExc_MemoryError, "tnc: memory allocation failed."); + goto failure; + } + + arglist = Py_BuildValue("(N)", py_list); + result = PyEval_CallObject(py_state->py_function, arglist); + Py_DECREF(arglist); + + if (result == NULL) + goto failure; + + if (result == Py_None) + { + Py_DECREF(result); + return 1; + } + + if (!PyArg_ParseTuple(result, "dO!", f, &PyList_Type, &py_grad)) + { + PyErr_SetString(PyExc_ValueError, + "tnc: invalid return value from minimized function."); + goto failure; + } + + if (PyList_IntoDoubleArray(py_grad, g, py_state->n)) + goto failure; + + Py_DECREF(result); + + return 0; + +failure: + py_state->failed = 1; + Py_XDECREF(result); + return 1; +} + +PyObject *moduleTNC_minimize(PyObject *self, PyObject *args) +{ + PyObject *py_x0, *py_low, *py_up, *py_list, *py_scale, *py_offset; + PyObject *py_function = NULL; + pytnc_state py_state; + int n, n1, n2, n3, n4; + + int rc, msg, maxCGit, maxnfeval, nfeval = 0; + double *x, *low, *up, *scale = NULL, *offset = NULL; + double f, eta, stepmx, accuracy, fmin, ftol, xtol, pgtol, rescale; + + if (!PyArg_ParseTuple(args, "OO!O!O!O!O!iiidddddddd", + &py_function, + &PyList_Type, &py_x0, + &PyList_Type, &py_low, + &PyList_Type, &py_up, + &PyList_Type, &py_scale, + &PyList_Type, &py_offset, + &msg, &maxCGit, &maxnfeval, &eta, &stepmx, &accuracy, &fmin, &ftol, + &xtol, &pgtol, + &rescale + )) + return NULL; + + if (!PyCallable_Check(py_function)) + { + PyErr_SetString(PyExc_TypeError, "tnc: function must be callable"); + return NULL; + } + + scale = PyList_AsDoubleArray(py_scale, &n3); + if (n3 != 0 && scale == NULL) + { + PyErr_SetString(PyExc_ValueError, "tnc: invalid scaling parameters."); + return NULL; + } + + offset = PyList_AsDoubleArray(py_offset, &n4); + if (n4 != 0 && offset == NULL) + { + PyErr_SetString(PyExc_ValueError, "tnc: invalid offset parameters."); + return NULL; + } + + x = PyList_AsDoubleArray(py_x0, &n); + if (n != 0 && x == NULL) + { + if (scale) free(scale); + + PyErr_SetString(PyExc_ValueError, "tnc: invalid initial vector."); + return NULL; + } + + low = PyList_AsDoubleArray(py_low, &n1); + up = PyList_AsDoubleArray(py_up, &n2); + + if ((n1 != 0 && low == NULL) || (n2 != 0 && up == NULL)) + { + if (scale) free(scale); + if (x) free(x); + if (low) free(low); + if (up) free(up); + + PyErr_SetString(PyExc_ValueError, "tnc: invalid bounds."); + return NULL; + } + + if (n1 != n2 || n != n1 || (scale != NULL && n != n3) + || (offset != NULL && n != n4)) + { + if (scale) free(scale); + if (offset) free(offset); + if (x) free(x); + if (low) free(low); + if (up) free(up); + + PyErr_SetString(PyExc_ValueError, "tnc: vector sizes must be equal."); + return NULL; + } + + py_state.py_function = py_function; + py_state.n = n; + py_state.failed = 0; + + Py_INCREF(py_function); + + rc = tnc(n, x, &f, NULL, function, &py_state, low, up, scale, offset, msg, + maxCGit, maxnfeval, eta, stepmx, accuracy, fmin, ftol, xtol, pgtol, rescale, + &nfeval); + + Py_DECREF(py_function); + + if (low) free(low); + if (up) free(up); + if (scale) free(scale); + if (offset) free(offset); + + if (py_state.failed) + { + if (x) free(x); + return NULL; + } + + if (rc == TNC_ENOMEM) + { + PyErr_SetString(PyExc_MemoryError, "tnc: memory allocation failed."); + if (x) free(x); + return NULL; + } + + py_list = PyDoubleArray_AsList(n, x); + if (x) free(x); + if (py_list == NULL) + { + PyErr_SetString(PyExc_MemoryError, "tnc: memory allocation failed."); + return NULL; + } + + return Py_BuildValue("(iiN)", rc, nfeval, py_list);; +} + +static PyMethodDef moduleTNC_methods[] = +{ + {"minimize", moduleTNC_minimize, METH_VARARGS}, + {NULL, NULL} +}; + +void initmoduleTNC(void) +{ + (void) Py_InitModule("moduleTNC", moduleTNC_methods); +} Added: trunk/Lib/sandbox/newoptimize/tnc/tnc.c =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/tnc.c 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc/tnc.c 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,1928 @@ +/* tnc : truncated newton bound constrained minimization + using gradient information, in C */ + +/* + * Copyright (c) 2002-2005, Jean-Sebastien Roy (js at jeannot.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * This software is a C implementation of TNBC, a truncated newton minimization + * package originally developed by Stephen G. Nash in Fortran. + * + * The original source code can be found at : + * http://iris.gmu.edu/~snash/nash/software/software.html + * + * Copyright for the original TNBC fortran routines: + * + * TRUNCATED-NEWTON METHOD: SUBROUTINES + * WRITTEN BY: STEPHEN G. NASH + * SCHOOL OF INFORMATION TECHNOLOGY & ENGINEERING + * GEORGE MASON UNIVERSITY + * FAIRFAX, VA 22030 + */ + +/* + * Conversion into C by Elisabeth Nguyen & Jean-Sebastien Roy + * Modifications by Jean-Sebastien Roy, 2001-2002 + */ + +static char const rcsid[] = + "@(#) $Jeannot: tnc.c,v 1.205 2005/01/28 18:27:31 js Exp $"; + +static char const copyright[] = + "(c) 2002-2003, Jean-Sebastien Roy (js at jeannot.org)"; + +#include +#include +#include + +#include "tnc.h" + +typedef enum +{ + TNC_FALSE = 0, + TNC_TRUE +} logical; + +/* + * Return code strings + */ + +char *tnc_rc_string[11] = +{ + "Memory allocation failed", + "Invalid parameters (n<0)", + "Infeasible (low bound > up bound)", + "Local minima reach (|pg| ~= 0)", + "Converged (|f_n-f_(n-1)| ~= 0)", + "Converged (|x_n-x_(n-1)| ~= 0)", + "Maximum number of function evaluations reached", + "Linear search failed", + "All lower bounds are equal to the upper bounds", + "Unable to progress", + "User requested end of minimization" +}; + +/* + * getptc return codes + */ +typedef enum +{ + GETPTC_OK = 0, /* Suitable point found */ + GETPTC_EVAL = 1, /* Function evaluation required */ + GETPTC_EINVAL = 2, /* Bad input values */ + GETPTC_FAIL = 3 /* No suitable point found */ +} getptc_rc; + +/* + * linearSearch return codes + */ +typedef enum +{ + LS_OK = 0, /* Suitable point found */ + LS_MAXFUN = 1, /* Max. number of function evaluations reach */ + LS_FAIL = 2, /* No suitable point found */ + LS_USERABORT = 3, /* User requested end of minimization */ + LS_ENOMEM = 4 /* Memory allocation failed */ +} ls_rc; + +/* + * Prototypes + */ +static tnc_rc tnc_minimize(int n, double x[], double *f, double g[], + tnc_function *function, void *state, + double xscale[], double xoffset[], double *fscale, + double low[], double up[], tnc_message messages, + int maxCGit, int maxnfeval, int *nfeval, + double eta, double stepmx, double accuracy, + double fmin, double ftol, double xtol, double pgtol, double rescale); + +static getptc_rc getptcInit(double *reltol, double *abstol, double tnytol, + double eta, double rmu, double xbnd, + double *u, double *fu, double *gu, double *xmin, + double *fmin, double *gmin, double *xw, double *fw, + double *gw, double *a, double *b, double *oldf, + double *b1, double *scxbnd, double *e, double *step, + double *factor, logical *braktd, double *gtest1, + double *gtest2, double *tol); + +static getptc_rc getptcIter(double big, double + rtsmll, double *reltol, double *abstol, double tnytol, + double fpresn, double xbnd, + double *u, double *fu, double *gu, double *xmin, + double *fmin, double *gmin, double *xw, double *fw, + double *gw, double *a, double *b, double *oldf, + double *b1, double *scxbnd, double *e, double *step, + double *factor, logical *braktd, double *gtest1, + double *gtest2, double *tol); + +static void printCurrentIteration(int n, double f, double g[], int niter, + int nfeval, int pivot[]); + +static double initialStep(double fnew, double fmin, double gtp, double smax); + +static ls_rc linearSearch(int n, tnc_function *function, void *state, + double low[], double up[], + double xscale[], double xoffset[], double fscale, int pivot[], + double eta, double ftol, double xbnd, + double p[], double x[], double *f, + double *alpha, double gfull[], int maxnfeval, int *nfeval); + +static int tnc_direction(double *zsol, double *diagb, + double *x, double *g, int n, + int maxCGit, int maxnfeval, int *nfeval, + logical upd1, double yksk, double yrsr, + double *sk, double *yk, double *sr, double *yr, + logical lreset, tnc_function *function, void *state, + double xscale[], double xoffset[], double fscale, + int *pivot, double accuracy, + double gnorm, double xnorm, double *low, double *up); + +static double stepMax(double step, int n, double x[], double p[], int pivot[], + double low[], double up[], double xscale[], double xoffset[]); + +/* Active set of constraints */ +static void setConstraints(int n, double x[], int pivot[], double xscale[], + double xoffset[], double low[], double up[]); + +static logical addConstraint(int n, double x[], double p[], int pivot[], + double low[], double up[], double xscale[], double xoffset[]); + +static logical removeConstraint(double gtpnew, double gnorm, double pgtolfs, + double f, double fLastConstraint, double g[], int pivot[], int n); + +static void project(int n, double x[], int pivot[]); + +static int hessianTimesVector(double v[], double gv[], int n, + double x[], double g[], tnc_function *function, void *state, + double xscale[], double xoffset[], double fscale, + double accuracy, double xnorm, double low[], double up[]); + +static int msolve(double g[], double *y, int n, + double sk[], double yk[], double diagb[], double sr[], + double yr[], logical upd1, double yksk, double yrsr, + logical lreset); + +static void diagonalScaling(int n, double e[], double v[], double gv[], + double r[]); + +static void ssbfgs(int n, double gamma, double sj[], double *hjv, + double hjyj[], double yjsj, + double yjhyj, double vsj, double vhyj, double hjp1v[]); + +static int initPreconditioner(double diagb[], double emat[], int n, + logical lreset, double yksk, double yrsr, + double sk[], double yk[], double sr[], double yr[], + logical upd1); + +/* Scaling */ +static void coercex(int n, double x[], double low[], double up[]); +static void unscalex(int n, double x[], double xscale[], double xoffset[]); +static void scaleg(int n, double g[], double xscale[], double fscale); +static void scalex(int n, double x[], double xscale[], double xoffset[]); +static void projectConstants(int n, double x[], double xscale[]); + +/* Machine precision */ +static double mchpr1(void); + +/* Special blas for incx=incy=1 */ +static double ddot1(int n, double dx[], double dy[]); +static void dxpy1(int n, double dx[], double dy[]); +static void daxpy1(int n, double da, double dx[], double dy[]); +static void dcopy1(int n, double dx[], double dy[]); +static double dnrm21(int n, double dx[]); + +/* additionnal blas-like functions */ +static void dneg1(int n, double v[]); + +/* + * This routine solves the optimization problem + * + * minimize f(x) + * x + * subject to low <= x <= up + * + * where x is a vector of n real variables. The method used is + * a truncated-newton algorithm (see "newton-type minimization via + * the lanczos algorithm" by s.g. nash (technical report 378, math. + * the lanczos method" by s.g. nash (siam j. numer. anal. 21 (1984), + * pp. 770-778). this algorithm finds a local minimum of f(x). It does + * not assume that the function f is convex (and so cannot guarantee a + * global solution), but does assume that the function is bounded below. + * it can solve problems having any number of variables, but it is + * especially useful when the number of variables (n) is large. + * + */ +extern int tnc(int n, double x[], double *f, double g[], tnc_function *function, + void *state, double low[], double up[], double scale[], double offset[], + int messages, int maxCGit, int maxnfeval, double eta, double stepmx, + double accuracy, double fmin, double ftol, double xtol, double pgtol, + double rescale, int *nfeval) +{ + int rc, frc, i, nc, nfeval_local, + free_low = TNC_FALSE, free_up = TNC_FALSE, + free_g = TNC_FALSE; + double *xscale = NULL, fscale, epsmch, rteps, *xoffset = NULL; + + if(nfeval==NULL) + { + /* Ignore nfeval */ + nfeval = &nfeval_local; + } + *nfeval = 0; + + /* Version info */ + if (messages & TNC_MSG_VERS) + { + fprintf(stderr, "tnc: Version %s, %s\n",TNC_VERSION,copyright); + fprintf(stderr, "tnc: RCS ID: %s\n",rcsid); + } + + /* Check for errors in the input parameters */ + if (n == 0) + { + rc = TNC_CONSTANT; + goto cleanup; + } + + if (n < 0) + { + rc = TNC_EINVAL; + goto cleanup; + } + + /* Check bounds arrays */ + if (low == NULL) + { + low = malloc(n*sizeof(*low)); + if (low == NULL) + { + rc = TNC_ENOMEM; + goto cleanup; + } + free_low = TNC_TRUE; + for (i = 0 ; i < n ; i++) low[i] = -HUGE_VAL; + } + if (up == NULL) + { + up = malloc(n*sizeof(*up)); + if (up == NULL) + { + rc = TNC_ENOMEM; + goto cleanup; + } + free_up = TNC_TRUE; + for (i = 0 ; i < n ; i++) up[i] = HUGE_VAL; + } + + /* Coherency check */ + for (i = 0 ; i < n ; i++) + { + if (low[i] > up [i]) + { + rc = TNC_INFEASIBLE; + goto cleanup; + } + } + + /* Coerce x into bounds */ + coercex(n, x, low, up); + + if (maxnfeval < 1) + { + rc = TNC_MAXFUN; + goto cleanup; + } + + /* Allocate g if necessary */ + if(g == NULL) + { + g = malloc(n*sizeof(*g)); + if (g == NULL) + { + rc = TNC_ENOMEM; + goto cleanup; + } + free_g = TNC_TRUE; + } + + /* Initial function evaluation */ + frc = function(x, f, g, state); + (*nfeval) ++; + if (frc) + { + rc = TNC_USERABORT; + goto cleanup; + } + + /* Constant problem ? */ + for (nc = 0, i = 0 ; i < n ; i++) + if ((low[i] == up[i]) || (scale != NULL && scale[i] == 0.0)) + nc ++; + + if (nc == n) + { + rc = TNC_CONSTANT; + goto cleanup; + } + + /* Scaling parameters */ + xscale = malloc(sizeof(*xscale)*n); + if (xscale == NULL) + { + rc = TNC_ENOMEM; + goto cleanup; + } + xoffset = malloc(sizeof(*xoffset)*n); + if (xoffset == NULL) + { + rc = TNC_ENOMEM; + goto cleanup; + } + fscale = 1.0; + + for (i = 0 ; i < n ; i++) + { + if (scale != NULL) + { + xscale[i] = fabs(scale[i]); + if (xscale[i] == 0.0) + xoffset[i] = low[i] = up[i] = x[i]; + } + else if (low[i] != -HUGE_VAL && up[i] != HUGE_VAL) + { + xscale[i] = up[i] - low[i]; + xoffset[i] = (up[i]+low[i])*0.5; + } + else + { + xscale[i] = 1.0+fabs(x[i]); + xoffset[i] = x[i]; + } + if (offset != NULL) + xoffset[i] = offset[i]; + } + + /* Default values for parameters */ + epsmch = mchpr1(); + rteps = sqrt(epsmch); + + if (stepmx < rteps * 10.0) stepmx = 1.0e1; + if (eta < 0.0 || eta >= 1.0) eta = 0.25; + if (rescale < 0) rescale = 1.3; + if (maxCGit < 0) /* maxCGit == 0 is valid */ + { + maxCGit = n / 2; + if (maxCGit < 1) maxCGit = 1; + else if (maxCGit > 50) maxCGit = 50; + } + if (maxCGit > n) maxCGit = n; + if (accuracy <= epsmch) accuracy = rteps; + if (ftol < 0.0) ftol = accuracy; + if (pgtol < 0.0) pgtol = 1e-2 * sqrt(accuracy); + if (xtol < 0.0) xtol = rteps; + + /* Optimisation */ + rc = tnc_minimize(n, x, f, g, function, state, + xscale, xoffset, &fscale, low, up, messages, + maxCGit, maxnfeval, nfeval, eta, stepmx, accuracy, fmin, ftol, xtol, pgtol, + rescale); + +cleanup: + if (messages & TNC_MSG_EXIT) + fprintf(stderr, "tnc: %s\n", tnc_rc_string[rc - TNC_MINRC]); + + if (xscale) free(xscale); + if (free_low) free(low); + if (free_up) free(up); + if (free_g) free(g); + if (xoffset) free(xoffset); + + return rc; +} + +/* Coerce x into bounds */ +static void coercex(int n, double x[], double low[], double up[]) +{ + int i; + + for (i = 0 ; i < n ; i++) + { + if (x[i]up[i]) x[i] = up[i]; + } +} + +/* Unscale x */ +static void unscalex(int n, double x[], double xscale[], double xoffset[]) +{ + int i; + for (i = 0 ; i < n ; i++) + x[i] = x[i]*xscale[i]+xoffset[i]; +} + +/* Scale x */ +static void scalex(int n, double x[], double xscale[], double xoffset[]) +{ + int i; + for (i = 0 ; i < n ; i++) + if (xscale[i]>0.0) + x[i] = (x[i]-xoffset[i])/xscale[i]; +} + +/* Scale g */ +static void scaleg(int n, double g[], double xscale[], double fscale) +{ + int i; + for (i = 0 ; i < n ; i++) + g[i] *= xscale[i]*fscale; +} + +/* Caculate the pivot vector */ +static void setConstraints(int n, double x[], int pivot[], double xscale[], + double xoffset[], double low[], double up[]) +{ + int i; + double epsmch; + + epsmch = mchpr1(); + + for (i = 0; i < n; i++) + { + /* tolerances should be better ajusted */ + if (xscale[i] == 0.0) + { + pivot[i] = 2; + } + else + { + if (low[i] != - HUGE_VAL && + (x[i]*xscale[i]+xoffset[i] - low[i] <= epsmch * 10.0 * (fabs(low[i]) + 1.0))) + pivot[i] = -1; + else + { + if (up[i] != HUGE_VAL && + (x[i]*xscale[i]+xoffset[i] - up[i] >= epsmch * 10.0 * (fabs(up[i]) + 1.0))) + pivot[i] = 1; + else + pivot[i] = 0; + } + } + } +} + +/* + * This routine is a bounds-constrained truncated-newton method. + * the truncated-newton method is preconditioned by a limited-memory + * quasi-newton method (this preconditioning strategy is developed + * in this routine) with a further diagonal scaling + * (see routine diagonalscaling). + */ +static tnc_rc tnc_minimize(int n, double x[], + double *f, double gfull[], tnc_function *function, void *state, + double xscale[], double xoffset[], double *fscale, + double low[], double up[], tnc_message messages, + int maxCGit, int maxnfeval, int *nfeval, double eta, double stepmx, + double accuracy, double fmin, double ftol, double xtol, double pgtol, + double rescale) +{ + double fLastReset, difnew, epsmch, epsred, oldgtp, + difold, oldf, xnorm, newscale, + gnorm, ustpmax, fLastConstraint, spe, yrsr, yksk, + *temp = NULL, *sk = NULL, *yk = NULL, *diagb = NULL, *sr = NULL, + *yr = NULL, *oldg = NULL, *pk = NULL, *g = NULL; + double alpha = 0.0; /* Default unused value */ + int i, icycle, niter = 0, oldnfeval, *pivot = NULL, frc; + logical lreset, newcon, upd1, remcon; + tnc_rc rc = TNC_ENOMEM; /* Default error */ + + /* Allocate temporary vectors */ + oldg = malloc(sizeof(*oldg)*n); + if (oldg == NULL) goto cleanup; + g = malloc(sizeof(*g)*n); + if (g == NULL) goto cleanup; + temp = malloc(sizeof(*temp)*n); + if (temp == NULL) goto cleanup; + diagb = malloc(sizeof(*diagb)*n); + if (diagb == NULL) goto cleanup; + pk = malloc(sizeof(*pk)*n); + if (pk == NULL) goto cleanup; + + sk = malloc(sizeof(*sk)*n); + if (sk == NULL) goto cleanup; + yk = malloc(sizeof(*yk)*n); + if (yk == NULL) goto cleanup; + sr = malloc(sizeof(*sr)*n); + if (sr == NULL) goto cleanup; + yr = malloc(sizeof(*yr)*n); + if (yr == NULL) goto cleanup; + + pivot = malloc(sizeof(*pivot)*n); + if (pivot == NULL) goto cleanup; + + /* Initialize variables */ + epsmch = mchpr1(); + + difnew = 0.0; + epsred = 0.05; + upd1 = TNC_TRUE; + icycle = n - 1; + newcon = TNC_TRUE; + + /* Uneeded initialisations */ + lreset = TNC_FALSE; + yrsr = 0.0; + yksk = 0.0; + + /* Initial scaling */ + scalex(n, x, xscale, xoffset); + (*f) *= *fscale; + + /* initial pivot calculation */ + setConstraints(n, x, pivot, xscale, xoffset, low, up); + + dcopy1(n, gfull, g); + scaleg(n, g, xscale, *fscale); + + /* Test the lagrange multipliers to see if they are non-negative. */ + for (i = 0; i < n; i++) + if (-pivot[i] * g[i] < 0.0) + pivot[i] = 0; + + project(n, g, pivot); + + /* Set initial values to other parameters */ + gnorm = dnrm21(n, g); + + fLastConstraint = *f; /* Value at last constraint */ + fLastReset = *f; /* Value at last reset */ + + if (messages & TNC_MSG_ITER) fprintf(stderr, + " NIT NF F GTG\n"); + if (messages & TNC_MSG_ITER) printCurrentIteration(n, *f / *fscale, gfull, + niter, *nfeval, pivot); + + /* Set the diagonal of the approximate hessian to unity. */ + for (i = 0; i < n; i++) diagb[i] = 1.0; + + /* Start of main iterative loop */ + while(TNC_TRUE) + { + /* Local minimum test */ + if (dnrm21(n, g) <= pgtol * (*fscale)) + { + /* |PG| == 0.0 => local minimum */ + dcopy1(n, gfull, g); + project(n, g, pivot); + if (messages & TNC_MSG_INFO) fprintf(stderr, + "tnc: |pg| = %g -> local minimum\n", dnrm21(n, g) / (*fscale)); + rc = TNC_LOCALMINIMUM; + break; + } + + /* Terminate if more than maxnfeval evaluations have been made */ + if (*nfeval >= maxnfeval) + { + rc = TNC_MAXFUN; + break; + } + + /* Rescale function if necessary */ + newscale = dnrm21(n, g); + if ((newscale > epsmch) && (fabs(log10(newscale)) > rescale)) + { + newscale = 1.0/newscale; + + *f *= newscale; + *fscale *= newscale; + gnorm *= newscale; + fLastConstraint *= newscale; + fLastReset *= newscale; + difnew *= newscale; + + for (i = 0; i < n; i++) g[i] *= newscale; + for (i = 0; i < n; i++) diagb[i] = 1.0; + + upd1 = TNC_TRUE; + icycle = n - 1; + newcon = TNC_TRUE; + + if (messages & TNC_MSG_INFO) fprintf(stderr, + "tnc: fscale = %g\n", *fscale); + } + + dcopy1(n, x, temp); + project(n, temp, pivot); + xnorm = dnrm21(n, temp); + oldnfeval = *nfeval; + + /* Compute the new search direction */ + frc = tnc_direction(pk, diagb, x, g, n, maxCGit, maxnfeval, nfeval, + upd1, yksk, yrsr, sk, yk, sr, yr, + lreset, function, state, xscale, xoffset, *fscale, + pivot, accuracy, gnorm, xnorm, low, up); + + if (frc == -1) + { + rc = TNC_ENOMEM; + break; + } + + if (frc) + { + rc = TNC_USERABORT; + break; + } + + if (!newcon) + { + if (!lreset) + { + /* Compute the accumulated step and its corresponding gradient + difference. */ + dxpy1(n, sk, sr); + dxpy1(n, yk, yr); + icycle++; + } + else + { + /* Initialize the sum of all the changes */ + dcopy1(n, sk, sr); + dcopy1(n, yk, yr); + fLastReset = *f; + icycle = 1; + } + } + + dcopy1(n, g, oldg); + oldf = *f; + oldgtp = ddot1(n, pk, g); + + /* Maximum unconstrained step length */ + ustpmax = stepmx / (dnrm21(n, pk) + epsmch); + + /* Maximum constrained step length */ + spe = stepMax(ustpmax, n, x, pk, pivot, low, up, xscale, xoffset); + + if (spe > 0.0) + { + ls_rc lsrc; + /* Set the initial step length */ + alpha = initialStep(*f, fmin / (*fscale), oldgtp, spe); + + /* Perform the linear search */ + lsrc = linearSearch(n, function, state, low, up, + xscale, xoffset, *fscale, pivot, + eta, ftol, spe, pk, x, f, &alpha, gfull, maxnfeval, nfeval); + + if (lsrc == LS_ENOMEM) + { + rc = TNC_ENOMEM; + break; + } + + if (lsrc == LS_USERABORT) + { + rc = TNC_USERABORT; + break; + } + + if (lsrc == LS_FAIL) + { + rc = TNC_LSFAIL; + break; + } + + /* If we went up to the maximum unconstrained step, increase it */ + if (alpha >= 0.9 * ustpmax) + { + stepmx *= 1e2; + if (messages & TNC_MSG_INFO) fprintf(stderr, + "tnc: stepmx = %g\n", stepmx); + } + + /* If we went up to the maximum constrained step, + a new constraint was encountered */ + if (alpha - spe >= -epsmch * 10.0) + { + newcon = TNC_TRUE; + } + else + { + /* Break if the linear search has failed to find a lower point */ + if (lsrc != LS_OK) + { + if (lsrc == LS_MAXFUN) rc = TNC_MAXFUN; + else rc = TNC_LSFAIL; + break; + } + newcon = TNC_FALSE; + } + } + else + { + /* Maximum constrained step == 0.0 => new constraint */ + newcon = TNC_TRUE; + } + + if (newcon) + { + if(!addConstraint(n, x, pk, pivot, low, up, xscale, xoffset)) + { + if(*nfeval == oldnfeval) + { + rc = TNC_NOPROGRESS; + break; + } + } + + fLastConstraint = *f; + } + + niter++; + + /* Set up parameters used in convergence and resetting tests */ + difold = difnew; + difnew = oldf - *f; + + /* If this is the first iteration of a new cycle, compute the + percentage reduction factor for the resetting test */ + if (icycle == 1) + { + if (difnew > difold * 2.0) epsred += epsred; + if (difnew < difold * 0.5) epsred *= 0.5; + } + + dcopy1(n, gfull, g); + scaleg(n, g, xscale, *fscale); + + dcopy1(n, g, temp); + project(n, temp, pivot); + gnorm = dnrm21(n, temp); + + /* Reset pivot */ + remcon = removeConstraint(oldgtp, gnorm, pgtol * (*fscale), *f, + fLastConstraint, g, pivot, n); + + /* If a constraint is removed */ + if (remcon) + { + /* Recalculate gnorm and reset fLastConstraint */ + dcopy1(n, g, temp); + project(n, temp, pivot); + gnorm = dnrm21(n, temp); + fLastConstraint = *f; + } + + if (!remcon && !newcon) + { + /* No constraint removed & no new constraint : tests for convergence */ + if (fabs(difnew) <= ftol * (*fscale)) + { + if (messages & TNC_MSG_INFO) fprintf(stderr, + "tnc: |fn-fn-1] = %g -> convergence\n", fabs(difnew) / (*fscale)); + rc = TNC_FCONVERGED; + break; + } + if (alpha * dnrm21(n, pk) <= xtol) + { + if (messages & TNC_MSG_INFO) fprintf(stderr, + "tnc: |xn-xn-1] = %g -> convergence\n", alpha * dnrm21(n, pk)); + rc = TNC_XCONVERGED; + break; + } + } + + project(n, g, pivot); + + if (messages & TNC_MSG_ITER) printCurrentIteration(n, *f / *fscale, gfull, + niter, *nfeval, pivot); + + /* Compute the change in the iterates and the corresponding change in the + gradients */ + if (!newcon) + { + for (i = 0; i < n; i++) + { + yk[i] = g[i] - oldg[i]; + sk[i] = alpha * pk[i]; + } + + /* Set up parameters used in updating the preconditioning strategy */ + yksk = ddot1(n, yk, sk); + + if (icycle == (n - 1) || difnew < epsred * (fLastReset - *f)) + lreset = TNC_TRUE; + else + { + yrsr = ddot1(n, yr, sr); + if (yrsr <= 0.0) lreset = TNC_TRUE; + else lreset = TNC_FALSE; + } + upd1 = TNC_FALSE; + } + } + + if (messages & TNC_MSG_ITER) printCurrentIteration(n, *f / *fscale, gfull, + niter, *nfeval, pivot); + + /* Unscaling */ + unscalex(n, x, xscale, xoffset); + coercex(n, x, low, up); + (*f) /= *fscale; + +cleanup: + if (oldg) free(oldg); + if (g) free(g); + if (temp) free(temp); + if (diagb) free(diagb); + if (pk) free(pk); + + if (sk) free(sk); + if (yk) free(yk); + if (sr) free(sr); + if (yr) free(yr); + + if (pivot) free(pivot); + + return rc; +} + +/* Print the results of the current iteration */ +static void printCurrentIteration(int n, double f, double g[], int niter, + int nfeval, int pivot[]) +{ + int i; + double gtg; + + gtg = 0.0; + for (i = 0; i < n; i++) + if (pivot[i] == 0) + gtg += g[i] * g[i]; + + fprintf(stderr, " %4d %4d %22.15E %15.8E\n", niter, nfeval, f, gtg); +} + +/* + * Set x[i] = 0.0 if direction i is currently constrained + */ +static void project(int n, double x[], int pivot[]) +{ + int i; + for (i = 0; i < n; i++) + if (pivot[i] != 0) + x[i] = 0.0; +} + +/* + * Set x[i] = 0.0 if direction i is constant + */ +static void projectConstants(int n, double x[], double xscale[]) +{ + int i; + for (i = 0; i < n; i++) + if (xscale[i] == 0.0) + x[i] = 0.0; +} + +/* + * Compute the maximum allowable step length + */ +static double stepMax(double step, int n, double x[], double dir[], + int pivot[], double low[], double up[], double xscale[], double xoffset[]) +{ + int i; + double t; + + /* Constrained maximum step */ + for (i = 0; i < n; i++) + { + if ((pivot[i] == 0) && (dir[i] != 0.0)) + { + if (dir[i] < 0.0) + { + t = (low[i]-xoffset[i])/xscale[i] - x[i]; + if (t > step * dir[i]) step = t / dir[i]; + } + else + { + t = (up[i]-xoffset[i])/xscale[i] - x[i]; + if (t < step * dir[i]) step = t / dir[i]; + } + } + } + + return step; +} + +/* + * Update the constraint vector pivot if a new constraint is encountered + */ +static logical addConstraint(int n, double x[], double p[], int pivot[], + double low[], double up[], double xscale[], double xoffset[]) +{ + int i, newcon = TNC_FALSE; + double tol, epsmch; + + epsmch = mchpr1(); + + for (i = 0; i < n; i++) + { + if ((pivot[i] == 0) && (p[i] != 0.0)) + { + if (p[i] < 0.0 && low[i] != - HUGE_VAL) + { + tol = epsmch * 10.0 * (fabs(low[i]) + 1.0); + if (x[i]*xscale[i]+xoffset[i] - low[i] <= tol) + { + pivot[i] = -1; + x[i] = (low[i]-xoffset[i])/xscale[i]; + newcon = TNC_TRUE; + } + } + else if (up[i] != HUGE_VAL) + { + tol = epsmch * 10.0 * (fabs(up[i]) + 1.0); + if (up[i] - (x[i]*xscale[i]+xoffset[i]) <= tol) + { + pivot[i] = 1; + x[i] = (up[i]-xoffset[i])/xscale[i]; + newcon = TNC_TRUE; + } + } + } + } + return newcon; +} + +/* + * Check if a constraint is no more active + */ +static logical removeConstraint(double gtpnew, double gnorm, double pgtolfs, + double f, double fLastConstraint, double g[], int pivot[], int n) +{ + double cmax, t; + int imax, i; + + if (((fLastConstraint - f) <= (gtpnew * -0.5)) && (gnorm > pgtolfs)) + return TNC_FALSE; + + imax = -1; + cmax = 0.0; + + for (i = 0; i < n; i++) + { + if (pivot[i] == 2) + continue; + t = -pivot[i] * g[i]; + if (t < cmax) + { + cmax = t; + imax = i; + } + } + + if (imax != -1) + { + pivot[imax] = 0; + return TNC_TRUE; + } + else + return TNC_FALSE; + +/* + * For details, see gill, murray, and wright (1981, p. 308) and + * fletcher (1981, p. 116). The multiplier tests (here, testing + * the sign of the components of the gradient) may still need to + * modified to incorporate tolerances for zero. + */ +} + +/* + * This routine performs a preconditioned conjugate-gradient + * iteration in order to solve the newton equations for a search + * direction for a truncated-newton algorithm. + * When the value of the quadratic model is sufficiently reduced, + * the iteration is terminated. + */ +static int tnc_direction(double *zsol, double *diagb, + double *x, double g[], int n, + int maxCGit, int maxnfeval, int *nfeval, + logical upd1, double yksk, double yrsr, + double *sk, double *yk, double *sr, double *yr, + logical lreset, tnc_function *function, void *state, + double xscale[], double xoffset[], double fscale, + int *pivot, double accuracy, + double gnorm, double xnorm, double low[], double up[]) +{ + double alpha, beta, qold, qnew, rhsnrm, tol, vgv, rz, rzold, qtest, pr, gtp; + int i, k, frc; + /* Temporary vectors */ + double *r = NULL, *zk = NULL, *v = NULL, *emat = NULL, *gv = NULL; + + /* No CG it. => dir = -grad */ + if (maxCGit == 0) + { + dcopy1(n, g, zsol); + dneg1(n, zsol); + project(n, zsol, pivot); + return 0; + } + + /* General initialization */ + rhsnrm = gnorm; + tol = 1e-12; + qold = 0.0; + rzold = 0.0; /* Uneeded */ + + frc = -1; /* ENOMEM here */ + r = malloc(sizeof(*r)*n); /* Residual */ + if (r == NULL) goto cleanup; + v = malloc(sizeof(*v)*n); + if (v == NULL) goto cleanup; + zk = malloc(sizeof(*zk)*n); + if (zk == NULL) goto cleanup; + emat = malloc(sizeof(*emat)*n); /* Diagonal preconditoning matrix */ + if (emat == NULL) goto cleanup; + gv = malloc(sizeof(*gv)*n); /* hessian times v */ + if (gv == NULL) goto cleanup; + + /* Initialization for preconditioned conjugate-gradient algorithm */ + frc = initPreconditioner(diagb, emat, n, lreset, yksk, yrsr, sk, yk, sr, yr, + upd1); + if (frc) goto cleanup; + + for (i = 0; i < n; i++) + { + r[i] = -g[i]; + v[i] = 0.0; + zsol[i] = 0.0; /* Computed search direction */ + } + + /* Main iteration */ + for (k = 0; k < maxCGit; k++) + { + /* CG iteration to solve system of equations */ + project(n, r, pivot); + frc = msolve(r, zk, n, sk, yk, diagb, sr, yr, upd1, yksk, yrsr, lreset); + if (frc) goto cleanup; + project(n, zk, pivot); + rz = ddot1(n, r, zk); + + if ((rz / rhsnrm < tol) || ((*nfeval) >= (maxnfeval-1))) + { + /* Truncate algorithm in case of an emergency + or too many function evaluations */ + if (k == 0) + { + dcopy1(n, g, zsol); + dneg1(n, zsol); + project(n, zsol, pivot); + } + break; + } + if (k == 0) beta = 0.0; + else beta = rz / rzold; + + for (i = 0; i < n; i++) + v[i] = zk[i] + beta * v[i]; + + project(n, v, pivot); + frc = hessianTimesVector(v, gv, n, x, g, function, state, + xscale, xoffset, fscale, accuracy, xnorm, low, up); + ++(*nfeval); + if (frc) goto cleanup; + project(n, gv, pivot); + + vgv = ddot1(n, v, gv); + if (vgv / rhsnrm < tol) + { + /* Truncate algorithm in case of an emergency */ + if (k == 0) + { + frc = msolve(g, zsol, n, sk, yk, diagb, sr, yr, upd1, yksk, yrsr, + lreset); + if (frc) goto cleanup; + dneg1(n, zsol); + project(n, zsol, pivot); + } + break; + } + diagonalScaling(n, emat, v, gv, r); + + /* Compute linear step length */ + alpha = rz / vgv; + + /* Compute current solution and related vectors */ + daxpy1(n, alpha, v, zsol); + daxpy1(n, -alpha, gv, r); + + /* Test for convergence */ + gtp = ddot1(n, zsol, g); + pr = ddot1(n, r, zsol); + qnew = (gtp + pr) * 0.5; + qtest = (k + 1) * (1.0 - qold / qnew); + if (qtest <= 0.5) break; + + /* Perform cautionary test */ + if (gtp > 0.0) + { + /* Truncate algorithm in case of an emergency */ + daxpy1(n, -alpha, v, zsol); + break; + } + + qold = qnew; + rzold = rz; + } + + /* Terminate algorithm */ + /* Store (or restore) diagonal preconditioning */ + dcopy1(n, emat, diagb); + +cleanup: + if (r) free(r); + if (v) free(v); + if (zk) free(zk); + if (emat) free(emat); + if (gv) free(gv); + return frc; +} + +/* + * Update the preconditioning matrix based on a diagonal version + * of the bfgs quasi-newton update. + */ +static void diagonalScaling(int n, double e[], double v[], double gv[], + double r[]) +{ + int i; + double vr, vgv; + + vr = 1.0/ddot1(n, v, r); + vgv = 1.0/ddot1(n, v, gv); + for (i = 0; i < n; i++) + { + e[i] += - r[i]*r[i]*vr + gv[i]*gv[i]*vgv; + if (e[i] <= 1e-6) e[i] = 1.0; + } +} + +/* + * Returns the length of the initial step to be taken along the + * vector p in the next linear search. + */ +static double initialStep(double fnew, double fmin, double gtp, double smax) +{ + double d, alpha; + + d = fabs(fnew - fmin); + alpha = 1.0; + if (d * 2.0 <= -(gtp) && d >= mchpr1()) alpha = d * -2.0 / gtp; + if (alpha >= smax) alpha = smax; + + return alpha; +} + +/* + * Hessian vector product through finite differences + */ +static int hessianTimesVector(double v[], double gv[], int n, + double x[], double g[], tnc_function *function, void *state, + double xscale[], double xoffset[], double fscale, + double accuracy, double xnorm, double low[], double up[]) +{ + double dinv, f, delta, *xv; + int i, frc; + + xv = malloc(sizeof(*xv)*n); + if (xv == NULL) return -1; + + delta = accuracy * (xnorm + 1.0); + for (i = 0; i < n; i++) + xv[i] = x[i] + delta * v[i]; + + unscalex(n, xv, xscale, xoffset); + coercex(n, xv, low, up); + frc = function(xv, &f, gv, state); + free(xv); + if (frc) return 1; + scaleg(n, gv, xscale, fscale); + + dinv = 1.0 / delta; + for (i = 0; i < n; i++) + gv[i] = (gv[i] - g[i]) * dinv; + + projectConstants(n, gv, xscale); + + return 0; +} + +/* + * This routine acts as a preconditioning step for the + * linear conjugate-gradient routine. It is also the + * method of computing the search direction from the + * gradient for the non-linear conjugate-gradient code. + * It represents a two-step self-scaled bfgs formula. + */ +static int msolve(double g[], double y[], int n, + double sk[], double yk[], double diagb[], double sr[], + double yr[], logical upd1, double yksk, double yrsr, + logical lreset) +{ + double ghyk, ghyr, yksr, ykhyk, ykhyr, yrhyr, rdiagb, gsr, gsk; + int i, frc; + double *hg = NULL, *hyk = NULL, *hyr = NULL; + + if (upd1) + { + for (i = 0; i < n; i++) y[i] = g[i] / diagb[i]; + return 0; + } + + frc = -1; + gsk = ddot1(n, g, sk); + hg = malloc(sizeof(*hg)*n); + if (hg == NULL) goto cleanup; + hyr = malloc(sizeof(*hyr)*n); + if (hyr == NULL) goto cleanup; + hyk = malloc(sizeof(*hyk)*n); + if (hyk == NULL) goto cleanup; + frc = 0; + + /* Compute gh and hy where h is the inverse of the diagonals */ + if (lreset) + { + for (i = 0; i < n; i++) + { + rdiagb = 1.0 / diagb[i]; + hg[i] = g[i] * rdiagb; + hyk[i] = yk[i] * rdiagb; + } + ykhyk = ddot1(n, yk, hyk); + ghyk = ddot1(n, g, hyk); + ssbfgs(n, 1.0, sk, hg, hyk, yksk, ykhyk, gsk, ghyk, y); + } + else + { + for (i = 0; i < n; i++) + { + rdiagb = 1.0 / diagb[i]; + hg[i] = g[i] * rdiagb; + hyk[i] = yk[i] * rdiagb; + hyr[i] = yr[i] * rdiagb; + } + gsr = ddot1(n, g, sr); + ghyr = ddot1(n, g, hyr); + yrhyr = ddot1(n, yr, hyr); + ssbfgs(n, 1.0, sr, hg, hyr, yrsr, yrhyr, gsr, ghyr, hg); + yksr = ddot1(n, yk, sr); + ykhyr = ddot1(n, yk, hyr); + ssbfgs(n, 1.0, sr, hyk, hyr, yrsr, yrhyr, yksr, ykhyr, hyk); + ykhyk = ddot1(n, hyk, yk); + ghyk = ddot1(n, hyk, g); + ssbfgs(n, 1.0, sk, hg, hyk, yksk, ykhyk, gsk, ghyk, y); + } + +cleanup: + if (hg) free(hg); + if (hyk) free(hyk); + if (hyr) free(hyr); + + return frc; +} + +/* + * Self-scaled BFGS + */ +static void ssbfgs(int n, double gamma, double sj[], double hjv[], + double hjyj[], double yjsj, + double yjhyj, double vsj, double vhyj, double hjp1v[]) +{ + double beta, delta; + int i; + + if (yjsj == 0.0) + { + delta = 0.0; + beta = 0.0; + } + else + { + delta = (gamma * yjhyj / yjsj + 1.0) * vsj / yjsj - gamma * vhyj / yjsj; + beta = -gamma * vsj / yjsj; + } + + for (i = 0; i < n; i++) + hjp1v[i] = gamma * hjv[i] + delta * sj[i] + beta * hjyj[i]; +} + +/* + * Initialize the preconditioner + */ +static int initPreconditioner(double diagb[], double emat[], int n, + logical lreset, double yksk, double yrsr, + double sk[], double yk[], double sr[], double yr[], + logical upd1) +{ + double srds, yrsk, td, sds; + int i; + double *bsk; + + if (upd1) + { + dcopy1(n, diagb, emat); + return 0; + } + + bsk = malloc(sizeof(*bsk)*n); + if (bsk == NULL) return -1; + + if (lreset) + { + for (i = 0; i < n; i++) bsk[i] = diagb[i] * sk[i]; + sds = ddot1(n, sk, bsk); + if (yksk == 0.0) yksk = 1.0; + if (sds == 0.0) sds = 1.0; + for (i = 0; i < n; i++) + { + td = diagb[i]; + emat[i] = td - td * td * sk[i] * sk[i] / sds + yk[i] * yk[i] / yksk; + } + } + else + { + for (i = 0; i < n; i++) bsk[i] = diagb[i] * sr[i]; + sds = ddot1(n, sr, bsk); + srds = ddot1(n, sk, bsk); + yrsk = ddot1(n, yr, sk); + if (yrsr == 0.0) yrsr = 1.0; + if (sds == 0.0) sds = 1.0; + for (i = 0; i < n; i++) + { + td = diagb[i]; + bsk[i] = td * sk[i] - bsk[i] * srds / sds + yr[i] * yrsk / yrsr; + emat[i] = td - td * td * sr[i] * sr[i] / sds + yr[i] * yr[i] / yrsr; + } + sds = ddot1(n, sk, bsk); + if (yksk == 0.0) yksk = 1.0; + if (sds == 0.0) sds = 1.0; + for (i = 0; i < n; i++) + emat[i] = emat[i] - bsk[i] * bsk[i] / sds + yk[i] * yk[i] / yksk; + } + + free(bsk); + return 0; +} + + +/* + * Line search algorithm of gill and murray + */ +static ls_rc linearSearch(int n, tnc_function *function, void *state, + double low[], double up[], + double xscale[], double xoffset[], double fscale, int pivot[], + double eta, double ftol, double xbnd, + double p[], double x[], double *f, + double *alpha, double gfull[], int maxnfeval, int *nfeval) +{ + double b1, big, tol, rmu, fpresn, fu, gu, fw, gw, gtest1, gtest2, + oldf, fmin, gmin, rtsmll, step, a, b, e, u, ualpha, factor, scxbnd, xw, + epsmch, reltol, abstol, tnytol, pe, xnorm, rteps; + double *temp = NULL, *tempgfull = NULL, *newgfull = NULL; + int maxlsit = 64, i, itcnt, frc; + ls_rc rc; + getptc_rc itest; + logical braktd; + + rc = LS_ENOMEM; + temp = malloc(sizeof(*temp)*n); + if (temp == NULL) goto cleanup; + tempgfull = malloc(sizeof(*tempgfull)*n); + if (tempgfull == NULL) goto cleanup; + newgfull = malloc(sizeof(*newgfull)*n); + if (newgfull == NULL) goto cleanup; + + dcopy1(n, gfull, temp); + scaleg(n, temp, xscale, fscale); + gu = ddot1(n, temp, p); + + dcopy1(n, x, temp); + project(n, temp, pivot); + xnorm = dnrm21(n, temp); + + /* Compute the absolute and relative tolerances for the linear search */ + epsmch = mchpr1(); + rteps = sqrt(epsmch); + pe = dnrm21(n, p) + epsmch; + reltol = rteps * (xnorm + 1.0) / pe; + abstol = -epsmch * (1.0 + fabs(*f)) / (gu - epsmch); + + /* Compute the smallest allowable spacing between points in the linear + search */ + tnytol = epsmch * (xnorm + 1.0) / pe; + + rtsmll = epsmch; + big = 1.0 / (epsmch * epsmch); + itcnt = 0; + + /* Set the estimated relative precision in f(x). */ + fpresn = ftol; + + u = *alpha; + fu = *f; + fmin = *f; + rmu = 1e-4; + + /* Setup */ + itest = getptcInit(&reltol, &abstol, tnytol, eta, rmu, + xbnd, &u, &fu, &gu, alpha, &fmin, &gmin, &xw, &fw, &gw, &a, &b, + &oldf, &b1, &scxbnd, &e, &step, &factor, &braktd, >est1, >est2, &tol); + + /* If itest == GETPTC_EVAL, the algorithm requires the function value to be + calculated */ + while(itest == GETPTC_EVAL) + { + /* Test for too many iterations or too many function evals */ + if ((++itcnt > maxlsit) || ((*nfeval) >= maxnfeval)) break; + + ualpha = *alpha + u; + for (i = 0; i < n; i++) + temp[i] = x[i] + ualpha * p[i]; + + /* Function evaluation */ + unscalex(n, temp, xscale, xoffset); + coercex(n, temp, low, up); + + frc = function(temp, &fu, tempgfull, state); + ++(*nfeval); + if (frc) + { + rc = LS_USERABORT; + goto cleanup; + } + + fu *= fscale; + + dcopy1(n, tempgfull, temp); + scaleg(n, temp, xscale, fscale); + gu = ddot1(n, temp, p); + + itest = getptcIter(big, rtsmll, &reltol, &abstol, tnytol, fpresn, + xbnd, &u, &fu, &gu, alpha, &fmin, &gmin, &xw, &fw, &gw, &a, &b, + &oldf, &b1, &scxbnd, &e, &step, &factor, &braktd, >est1, >est2, &tol); + + /* New best point ? */ + if (*alpha == ualpha) + dcopy1(n, tempgfull, newgfull); + } + + if (itest == GETPTC_OK) + { + /* A successful search has been made */ + *f = fmin; + daxpy1(n, *alpha, p, x); + dcopy1(n, newgfull, gfull); + rc = LS_OK; + } + /* Too many iterations ? */ + else if (itcnt > maxlsit) rc = LS_FAIL; + /* If itest=GETPTC_FAIL or GETPTC_EINVAL a lower point could not be found */ + else if (itest != GETPTC_EVAL) rc = LS_FAIL; + /* Too many function evaluations */ + else rc = LS_MAXFUN; + +cleanup: + if (temp) free(temp); + if (tempgfull) free(tempgfull); + if (newgfull) free(newgfull); + + return rc; +} + +/* + * getptc, an algorithm for finding a steplength, called repeatedly by + * routines which require a step length to be computed using cubic + * interpolation. The parameters contain information about the interval + * in which a lower point is to be found and from this getptc computes a + * point at which the function can be evaluated by the calling program. + */ +static getptc_rc getptcInit(double *reltol, double *abstol, double tnytol, + double eta, double rmu, double xbnd, + double *u, double *fu, double *gu, double *xmin, + double *fmin, double *gmin, double *xw, double *fw, + double *gw, double *a, double *b, double *oldf, + double *b1, double *scxbnd, double *e, double *step, + double *factor, logical *braktd, double *gtest1, + double *gtest2, double *tol) +{ + /* Check input parameters */ + if (*u <= 0.0 || xbnd <= tnytol || *gu > 0.0) + return GETPTC_EINVAL; + if (xbnd < *abstol) *abstol = xbnd; + *tol = *abstol; + + /* a and b define the interval of uncertainty, x and xw are points */ + /* with lowest and second lowest function values so far obtained. */ + /* initialize a,smin,xw at origin and corresponding values of */ + /* function and projection of the gradient along direction of search */ + /* at values for latest estimate at minimum. */ + + *a = 0.0; + *xw = 0.0; + *xmin = 0.0; + *oldf = *fu; + *fmin = *fu; + *fw = *fu; + *gw = *gu; + *gmin = *gu; + *step = *u; + *factor = 5.0; + + /* The minimum has not yet been bracketed. */ + *braktd = TNC_FALSE; + + /* Set up xbnd as a bound on the step to be taken. (xbnd is not computed */ + /* explicitly but scxbnd is its scaled value.) Set the upper bound */ + /* on the interval of uncertainty initially to xbnd + tol(xbnd). */ + *scxbnd = xbnd; + *b = *scxbnd + *reltol * fabs(*scxbnd) + *abstol; + *e = *b + *b; + *b1 = *b; + + /* Compute the constants required for the two convergence criteria. */ + *gtest1 = -rmu * *gu; + *gtest2 = -eta * *gu; + + /* If the step is too large, replace by the scaled bound (so as to */ + /* compute the new point on the boundary). */ + if (*step >= *scxbnd) + { + *step = *scxbnd; + /* Move sxbd to the left so that sbnd + tol(xbnd) = xbnd. */ + *scxbnd -= (*reltol * fabs(xbnd) + *abstol) / (1.0 + *reltol); + } + *u = *step; + if (fabs(*step) < *tol && *step < 0.0) *u = -(*tol); + if (fabs(*step) < *tol && *step >= 0.0) *u = *tol; + return GETPTC_EVAL; +} + +static getptc_rc getptcIter(double big, double + rtsmll, double *reltol, double *abstol, double tnytol, + double fpresn, double xbnd, + double *u, double *fu, double *gu, double *xmin, + double *fmin, double *gmin, double *xw, double *fw, + double *gw, double *a, double *b, double *oldf, + double *b1, double *scxbnd, double *e, double *step, + double *factor, logical *braktd, double *gtest1, + double *gtest2, double *tol) +{ + double abgw, absr, p, q, r, s, scale, denom, + a1, d1, d2, sumsq, abgmin, chordm, chordu, + xmidpt, twotol; + logical convrg; + + /* Update a,b,xw, and xmin */ + if (*fu <= *fmin) + { + /* If function value not increased, new point becomes next */ + /* origin and other points are scaled accordingly. */ + chordu = *oldf - (*xmin + *u) * *gtest1; + if (*fu > chordu) + { + /* The new function value does not satisfy the sufficient decrease */ + /* criterion. prepare to move the upper bound to this point and */ + /* force the interpolation scheme to either bisect the interval of */ + /* uncertainty or take the linear interpolation step which estimates */ + /* the root of f(alpha)=chord(alpha). */ + + chordm = *oldf - *xmin * *gtest1; + *gu = -(*gmin); + denom = chordm - *fmin; + if (fabs(denom) < 1e-15) + { + denom = 1e-15; + if (chordm - *fmin < 0.0) denom = -denom; + } + if (*xmin != 0.0) *gu = *gmin * (chordu - *fu) / denom; + *fu = 0.5 * *u * (*gmin + *gu) + *fmin; + if (*fu < *fmin) *fu = *fmin; + } + else + { + *fw = *fmin; + *fmin = *fu; + *gw = *gmin; + *gmin = *gu; + *xmin += *u; + *a -= *u; + *b -= *u; + *xw = -(*u); + *scxbnd -= *u; + if (*gu <= 0.0) + { + *a = 0.0; + } + else + { + *b = 0.0; + *braktd = TNC_TRUE; + } + *tol = fabs(*xmin) * *reltol + *abstol; + goto ConvergenceCheck; + } + } + + /* If function value increased, origin remains unchanged */ + /* but new point may now qualify as w. */ + if (*u < 0.0) + *a = *u; + else + { + *b = *u; + *braktd = TNC_TRUE; + } + *xw = *u; + *fw = *fu; + *gw = *gu; + +ConvergenceCheck: + twotol = *tol + *tol; + xmidpt = 0.5 * (*a + *b); + + /* Check termination criteria */ + convrg = (fabs(xmidpt) <= twotol - 0.5 * (*b - *a)) || + (fabs(*gmin) <= *gtest2 && *fmin < *oldf && ((fabs(*xmin - xbnd) > *tol) || + (! (*braktd)))); + if (convrg) + { + if (*xmin != 0.0) return GETPTC_OK; + + /* + * If the function has not been reduced, check to see that the relative + * change in f(x) is consistent with the estimate of the delta- + * unimodality constant, tol. If the change in f(x) is larger than + * expected, reduce the value of tol. + */ + if (fabs(*oldf - *fw) <= fpresn) + return GETPTC_FAIL; + *tol = 0.1 * *tol; + if (*tol < tnytol) return GETPTC_FAIL; + *reltol = 0.1 * *reltol; + *abstol = 0.1 * *abstol; + twotol = 0.1 * twotol; + } + + /* Continue with the computation of a trial step length */ + r = 0.0; + q = 0.0; + s = 0.0; + if (fabs(*e) > *tol) + { + /* Fit cubic through xmin and xw */ + r = 3.0 * (*fmin - *fw) / *xw + *gmin + *gw; + absr = fabs(r); + q = absr; + if (*gw != 0.0 && *gmin != 0.0) + { + /* Compute the square root of (r*r - gmin*gw) in a way + which avoids underflow and overflow. */ + abgw = fabs(*gw); + abgmin = fabs(*gmin); + s = sqrt(abgmin) * sqrt(abgw); + if (*gw / abgw * *gmin > 0.0) + { + if (r >= s || r <= -s) + { + /* Compute the square root of r*r - s*s */ + q = sqrt(fabs(r + s)) * sqrt(fabs(r - s)); + } + else + { + r = 0.0; + q = 0.0; + goto MinimumFound; + } + } + else + { + /* Compute the square root of r*r + s*s. */ + sumsq = 1.0; + p = 0.0; + if (absr >= s) + { + /* There is a possibility of underflow. */ + if (absr > rtsmll) p = absr * rtsmll; + if (s >= p) + { + double value = s / absr; + sumsq = 1.0 + value * value; + } + scale = absr; + } + else + { + /* There is a possibility of overflow. */ + if (s > rtsmll) p = s * rtsmll; + if (absr >= p) + { + double value = absr / s; + sumsq = 1.0 + value * value; + } + scale = s; + } + sumsq = sqrt(sumsq); + q = big; + if (scale < big / sumsq) q = scale * sumsq; + } + } + + /* Compute the minimum of fitted cubic */ + if (*xw < 0.0) q = -q; + s = *xw * (*gmin - r - q); + q = *gw - *gmin + q + q; + if (q > 0.0) s = -s; + if (q <= 0.0) q = -q; + r = *e; + if (*b1 != *step || *braktd) *e = *step; + } + +MinimumFound: + /* Construct an artificial bound on the estimated steplength */ + a1 = *a; + *b1 = *b; + *step = xmidpt; + if ( (! *braktd) || ((*a == 0.0 && *xw < 0.0) || (*b == 0.0 && *xw > 0.0)) ) + { + if (*braktd) + { + /* If the minimum is not bracketed by 0 and xw the step must lie + within (a1,b1). */ + d1 = *xw; + d2 = *a; + if (*a == 0.0) d2 = *b; + /* This line might be : */ + /* if (*a == 0.0) d2 = *e */ + *u = -d1 / d2; + *step = 5.0 * d2 * (0.1 + 1.0 / *u) / 11.0; + if (*u < 1.0) *step = 0.5 * d2 * sqrt(*u); + } + else + { + *step = -(*factor) * *xw; + if (*step > *scxbnd) *step = *scxbnd; + if (*step != *scxbnd) *factor = 5.0 * *factor; + } + /* If the minimum is bracketed by 0 and xw the step must lie within (a,b) */ + if (*step <= 0.0) a1 = *step; + if (*step > 0.0) *b1 = *step; + } + +/* + * Reject the step obtained by interpolation if it lies outside the + * required interval or it is greater than half the step obtained + * during the last-but-one iteration. + */ + if (fabs(s) <= fabs(0.5 * q * r) || s <= q * a1 || s >= q * *b1) + *e = *b - *a; + else + { + /* A cubic interpolation step */ + *step = s / q; + + /* The function must not be evaluated too close to a or b. */ + if (*step - *a < twotol || *b - *step < twotol) + { + if (xmidpt <= 0.0) + *step = -(*tol); + else + *step = *tol; + } + } + + /* If the step is too large, replace by the scaled bound (so as to */ + /* compute the new point on the boundary). */ + if (*step >= *scxbnd) + { + *step = *scxbnd; + /* Move sxbd to the left so that sbnd + tol(xbnd) = xbnd. */ + *scxbnd -= (*reltol * fabs(xbnd) + *abstol) / (1.0 + *reltol); + } + *u = *step; + if (fabs(*step) < *tol && *step < 0.0) *u = -(*tol); + if (fabs(*step) < *tol && *step >= 0.0) *u = *tol; + return GETPTC_EVAL; +} + +/* + * Return epsmch, where epsmch is the smallest possible + * power of 2 such that 1.0 + epsmch > 1.0 + */ +static double mchpr1(void) +{ + static double epsmch = 0.0; + + if (epsmch == 0.0) + { + double eps = 1.0; + while((1.0 + (eps*0.5)) > 1.0) + eps *= 0.5; + epsmch = eps; + } + + return epsmch; +} + +/* Blas like routines */ + +/* dy+=dx */ +static void dxpy1(int n, double dx[], double dy[]) +{ + int i; + for (i = 0; i < n; i++) + dy[i] += dx[i]; +} + +/* dy+=da*dx */ +static void daxpy1(int n, double da, double dx[], double dy[]) +{ + int i; + for (i = 0; i < n; i++) + dy[i] += da*dx[i]; +} + +/* Copy dx -> dy */ +/* Could use memcpy */ +static void dcopy1(int n, double dx[], double dy[]) +{ + int i; + for (i = 0; i < n; i++) + dy[i] = dx[i]; +} + +/* Negate */ +static void dneg1(int n, double v[]) +{ + int i; + for (i = 0; i < n; i++) + v[i] = -v[i]; +} + +/* Dot product */ +static double ddot1(int n, double dx[], double dy[]) +{ + int i; + double dtemp = 0.0; + for (i = 0; i < n; i++) + dtemp += dy[i]*dx[i]; + return dtemp; +} + +/* Euclidian norm */ +static double dnrm21(int n, double dx[]) +{ + int i; + double dssq = 1.0, dscale = 0.0; + + for (i = 0; i < n; i++) + { + if (dx[i] != 0.0) + { + double dabsxi = fabs(dx[i]); + if (dscale up bound) */ + TNC_LOCALMINIMUM = 0, /* Local minima reach (|pg| ~= 0) */ + TNC_FCONVERGED = 1, /* Converged (|f_n-f_(n-1)| ~= 0) */ + TNC_XCONVERGED = 2, /* Converged (|x_n-x_(n-1)| ~= 0) */ + TNC_MAXFUN = 3, /* Max. number of function evaluations reach */ + TNC_LSFAIL = 4, /* Linear search failed */ + TNC_CONSTANT = 5, /* All lower bounds are equal to the upper bounds */ + TNC_NOPROGRESS = 6, /* Unable to progress */ + TNC_USERABORT = 7 /* User requested end of minization */ +} tnc_rc; + +/* + * Return code strings + * use tnc_rc_string[rc - TNC_MINRC] to get the message associated with + * return code rc. + */ + +extern char *tnc_rc_string[11]; + +/* + * A function as required by tnc + * state is a void pointer provided to the function at each call + * + * x : on input, then vector of variables (should not be modified) + * f : on output, the value of the function + * g : on output, the value of the gradient + * state : on input, the value of the state variable as provided to tnc + * + * must returns 0 if no error occurs or 1 to immediately end the minimization. + * + */ +typedef int tnc_function(double x[], double *f, double g[], void *state); + +/* + * tnc : minimize a function with variables subject to bounds, using + * gradient information. + * + * n : number of variables (must be >= 0) + * x : on input, initial estimate ; on output, the solution + * f : on output, the function value at the solution + * g : on output, the gradient value at the solution + * g should be an allocated vector of size n or NULL, + * in which case the gradient value is not returned. + * function : the function to minimize (see tnc_function) + * state : used by function (see tnc_function) + * low, up : the bounds + * set low[i] to -HUGE_VAL to remove the lower bound + * set up[i] to HUGE_VAL to remove the upper bound + * if low == NULL, the lower bounds are removed. + * if up == NULL, the upper bounds are removed. + * scale : scaling factors to apply to each variable + * if NULL, the factors are up-low for interval bounded variables + * and 1+|x] for the others. + * offset : constant to substract to each variable + * if NULL, the constant are (up+low)/2 for interval bounded + * variables and x for the others. + * messages : see the tnc_message enum + * maxCGit : max. number of hessian*vector evaluation per main iteration + * if maxCGit == 0, the direction chosen is -gradient + * if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)) + * maxnfeval : max. number of function evaluation + * eta : severity of the line search. if < 0 or > 1, set to 0.25 + * stepmx : maximum step for the line search. may be increased during call + * if too small, will be set to 10.0 + * accuracy : relative precision for finite difference calculations + * if <= machine_precision, set to sqrt(machine_precision) + * fmin : minimum function value estimate + * ftol : precision goal for the value of f in the stoping criterion + * if ftol < 0.0, ftol is set to accuracy + * xtol : precision goal for the value of x in the stopping criterion + * (after applying x scaling factors) + * if xtol < 0.0, xtol is set to sqrt(machine_precision) + * pgtol : precision goal for the value of the projected gradient in the + * stopping criterion (after applying x scaling factors) + * if pgtol < 0.0, pgtol is set to 1e-2 * sqrt(accuracy) + * setting it to 0.0 is not recommended + * rescale : f scaling factor (in log10) used to trigger f value rescaling + * if 0, rescale at each iteration + * if a big value, never rescale + * if < 0, rescale is set to 1.3 + * nfeval : on output, the number of function evaluations. + * ignored if nfeval==NULL. + * + * The tnc function returns a code defined in the tnc_rc enum. + * On output, x, f and g may be very slightly out of sync because of scaling. + * + */ +extern int tnc(int n, double x[], double *f, double g[], + tnc_function *function, void *state, + double low[], double up[], double scale[], double offset[], + int messages, int maxCGit, int maxnfeval, double eta, double stepmx, + double accuracy, double fmin, double ftol, double xtol, double pgtol, + double rescale, int *nfeval); + +#ifdef __cplusplus +} +#endif + +#endif /* _TNC_ */ Added: trunk/Lib/sandbox/newoptimize/tnc.py =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc.py 2007-01-11 04:22:41 UTC (rev 2529) +++ trunk/Lib/sandbox/newoptimize/tnc.py 2007-01-11 06:19:21 UTC (rev 2530) @@ -0,0 +1,285 @@ +# TNC Python interface +# @(#) $Jeannot: tnc.py,v 1.11 2005/01/28 18:27:31 js Exp $ + +# Copyright (c) 2004-2005, Jean-Sebastien Roy (js at jeannot.org) + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +TNC: A python interface to the TNC non-linear optimizer + +TNC is a non-linear optimizer. To use it, you must provide a function to +minimize. The function must take one argument: the list of coordinates where to +evaluate the function; and it must return either a tuple, whose first element is the +value of the function, and whose second argument is the gradient of the function +(as a list of values); or None, to abort the minimization. +""" + +import moduleTNC + +MSG_NONE = 0 # No messages +MSG_ITER = 1 # One line per iteration +MSG_INFO = 2 # Informational messages +MSG_VERS = 4 # Version info +MSG_EXIT = 8 # Exit reasons +MSG_ALL = MSG_ITER + MSG_INFO + MSG_VERS + MSG_EXIT + +MSGS = { + MSG_NONE : "No messages", + MSG_ITER : "One line per iteration", + MSG_INFO : "Informational messages", + MSG_VERS : "Version info", + MSG_EXIT : "Exit reasons", + MSG_ALL : "All messages" +} + +HUGE_VAL=1e200*1e200 # No standard representation of Infinity in Python 2.3.3 + +INFEASIBLE = -1 # Infeasible (low > up) +LOCALMINIMUM = 0 # Local minima reach (|pg| ~= 0) +FCONVERGED = 1 # Converged (|f_n-f_(n-1)| ~= 0) +XCONVERGED = 2 # Converged (|x_n-x_(n-1)| ~= 0) +MAXFUN = 3 # Max. number of function evaluations reach +LSFAIL = 4 # Linear search failed +CONSTANT = 5 # All lower bounds are equal to the upper bounds +NOPROGRESS = 6 # Unable to progress +USERABORT = 7 # User requested end of minimization + +RCSTRINGS = { + INFEASIBLE : "Infeasible (low > up)", + LOCALMINIMUM : "Local minima reach (|pg| ~= 0)", + FCONVERGED : "Converged (|f_n-f_(n-1)| ~= 0)", + XCONVERGED : "Converged (|x_n-x_(n-1)| ~= 0)", + MAXFUN : "Max. number of function evaluations reach", + LSFAIL : "Linear search failed", + CONSTANT : "All lower bounds are equal to the upper bounds", + NOPROGRESS : "Unable to progress", + USERABORT : "User requested end of minimization" +} + +def minimize(function, x, low = None, up = None, scale = None, offset = None, + messages = MSG_ALL, maxCGit = -1, maxnfeval = None, eta = -1, stepmx = 0, + accuracy = 0, fmin = 0, ftol = -1, xtol = -1, pgtol = -1, rescale = -1): + """Minimize a function with variables subject to bounds, using gradient + information. + + returns (rc, nfeval, x). + + Inputs: + x : initial estimate (a list of floats) + function : the function to minimize. Must take one argument, x and return + f and g, where f is the value of the function and g its + gradient (a list of floats). + if the function returns None, the minimization is aborted. + low, up : the bounds (lists of floats) + set low[i] to -HUGE_VAL to remove the lower bound + set up[i] to HUGE_VAL to remove the upper bound + if low == None, the lower bounds are removed. + if up == None, the upper bounds are removed. + low and up defaults to None + scale : scaling factors to apply to each variable (a list of floats) + if None, the factors are up-low for interval bounded variables + and 1+|x] fo the others. + defaults to None + offset : constant to substract to each variable + if None, the constant are (up+low)/2 for interval bounded + variables and x for the others. + messages : bit mask used to select messages display during minimization + values defined in the MSGS dict. + defaults to MGS_ALL + maxCGit : max. number of hessian*vector evaluation per main iteration + if maxCGit == 0, the direction chosen is -gradient + if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)) + defaults to -1 + maxnfeval : max. number of function evaluation + if None, maxnfeval is set to max(100, 10*len(x0)) + defaults to None + eta : severity of the line search. if < 0 or > 1, set to 0.25 + defaults to -1 + stepmx : maximum step for the line search. may be increased during call + if too small, will be set to 10.0 + defaults to 0 + accuracy : relative precision for finite difference calculations + if <= machine_precision, set to sqrt(machine_precision) + defaults to 0 + fmin : minimum function value estimate + defaults to 0 + ftol : precision goal for the value of f in the stoping criterion + if ftol < 0.0, ftol is set to 0.0 + defaults to -1 + xtol : precision goal for the value of x in the stopping criterion + (after applying x scaling factors) + if xtol < 0.0, xtol is set to sqrt(machine_precision) + defaults to -1 + pgtol : precision goal for the value of the projected gradient in the + stopping criterion (after applying x scaling factors) + if pgtol < 0.0, pgtol is set to 1e-2 * sqrt(accuracy) + setting it to 0.0 is not recommended. + defaults to -1 + rescale : f scaling factor (in log10) used to trigger f value rescaling + if 0, rescale at each iteration + if a large value, never rescale + if < 0, rescale is set to 1.3 + + Outputs: + x : the solution (a list of floats) + nfeval : the number of function evaluations + rc : return code as defined in the RCSTRINGS dict""" + + if low == None: + low = [-HUGE_VAL]*len(x) + + if up == None: + up = [HUGE_VAL]*len(x) + + if scale == None: + scale = [] + + if offset == None: + offset = [] + + if maxnfeval == None: + maxnfeval = max(100, 10*len(x)) + + return moduleTNC.minimize(function, x, low, up, scale, offset, + messages, maxCGit, maxnfeval, eta, stepmx, accuracy, + fmin, ftol, xtol, pgtol, rescale) + +if __name__ == '__main__': + # Examples for TNC + + def example(): + print "Example" + # A function to minimize + def function(x): + f = pow(x[0],2.0)+pow(abs(x[1]),3.0) + g = [0,0] + g[0] = 2.0*x[0] + g[1] = 3.0*pow(abs(x[1]),2.0) + if x[1]<0: + g[1] = -g[1] + return f, g + + # Optimizer call + rc, nf, x = minimize(function, [-7, 3], [-10, 1], [10, 10]) + + print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] + print "x =", x + print "exact value = [0, 1]" + print + + example() + + # Tests + # These tests are taken from Prof. K. Schittkowski test examples for + # constrained nonlinear programming. + # http://www.uni-bayreuth.de/departments/math/~kschittkowski/home.htm + tests = [] + def test1fg(x): + f = 100.0*pow((x[1]-pow(x[0],2)),2)+pow(1.0-x[0],2) + dif = [0,0] + dif[1] = 200.0*(x[1]-pow(x[0],2)) + dif[0] = -2.0*(x[0]*(dif[1]-1.0)+1.0) + return f, dif + tests.append ((test1fg, [-2,1], [-HUGE_VAL, -1.5], None, [1,1])) + + def test2fg(x): + f = 100.0*pow((x[1]-pow(x[0],2)),2)+pow(1.0-x[0],2) + dif = [0,0] + dif[1] = 200.0*(x[1]-pow(x[0],2)) + dif[0] = -2.0*(x[0]*(dif[1]-1.0)+1.0) + return f, dif + tests.append ((test2fg, [-2,1], [-HUGE_VAL, 1.5], None, [-1.2210262419616387,1.5])) + + def test3fg(x): + f = x[1]+pow(x[1]-x[0],2)*1.0e-5 + dif = [0,0] + dif[0] = -2.0*(x[1]-x[0])*1.0e-5 + dif[1] = 1.0-dif[0] + return f, dif + tests.append ((test3fg, [10,1], [-HUGE_VAL, 0.0], None, [0,0])) + + def test4fg(x): + f = pow(x[0]+1.0,3)/3.0+x[1] + dif = [0,0] + dif[0] = pow(x[0]+1.0,2) + dif[1] = 1.0 + return f, dif + tests.append ((test4fg, [1.125,0.125], [1, 0], None, [1,0])) + + from math import * + + def test5fg(x): + f = sin(x[0]+x[1])+pow(x[0]-x[1],2)-1.5*x[0]+2.5*x[1]+1.0 + dif = [0,0] + v1 = cos(x[0]+x[1]); + v2 = 2.0*(x[0]-x[1]); + + dif[0] = v1+v2-1.5; + dif[1] = v1-v2+2.5; + return f, dif + tests.append ((test5fg, [0,0], [-1.5, -3], [4,3], [-0.54719755119659763, -1.5471975511965976])) + + def test38fg(x): + f = (100.0*pow(x[1]-pow(x[0],2),2)+pow(1.0-x[0],2)+90.0*pow(x[3]-pow(x[2],2),2) \ + +pow(1.0-x[2],2)+10.1*(pow(x[1]-1.0,2)+pow(x[3]-1.0,2)) \ + +19.8*(x[1]-1.0)*(x[3]-1.0))*1.0e-5 + dif = [0,0,0,0] + dif[0] = (-400.0*x[0]*(x[1]-pow(x[0],2))-2.0*(1.0-x[0]))*1.0e-5 + dif[1] = (200.0*(x[1]-pow(x[0],2))+20.2*(x[1]-1.0)+19.8*(x[3]-1.0))*1.0e-5 + dif[2] = (-360.0*x[2]*(x[3]-pow(x[2],2))-2.0*(1.0-x[2]))*1.0e-5 + dif[3] = (180.0*(x[3]-pow(x[2],2))+20.2*(x[3]-1.0)+19.8*(x[1]-1.0))*1.0e-5 + return f, dif + tests.append ((test38fg, [-3,-1,-3,-1], [-10]*4, [10]*4, [1]*4)) + + def test45fg(x): + f = 2.0-x[0]*x[1]*x[2]*x[3]*x[4]/120.0 + dif = [0]*5 + dif[0] = -x[1]*x[2]*x[3]*x[4]/120.0 + dif[1] = -x[0]*x[2]*x[3]*x[4]/120.0 + dif[2] = -x[0]*x[1]*x[3]*x[4]/120.0 + dif[3] = -x[0]*x[1]*x[2]*x[4]/120.0 + dif[4] = -x[0]*x[1]*x[2]*x[3]/120.0 + return f, dif + tests.append ((test45fg, [2]*5, [0]*5, [1,2,3,4,5], [1,2,3,4,5])) + + def test(fg, x, low, up, xopt): + print "** Test", fg.__name__ + rc, nf, x = minimize(fg, x, low, up, messages = MSG_NONE, maxnfeval = 200) + print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] + print "x =", x + print "exact value =", xopt + enorm = 0.0 + norm = 1.0 + for y,yo in zip(x, xopt): + enorm += (y-yo)*(y-yo) + norm += yo*yo + ex = pow(enorm/norm, 0.5) + print "X Error =", ex + ef = abs(fg(xopt)[0] - fg(x)[0]) + print "F Error =", ef + if ef > 1e-8: + raise "Test "+fg.__name__+" failed" + + for fg, x, low, up, xopt in tests: + test(fg, x, low, up, xopt) + + print + print "** All TNC tests passed." From scipy-svn at scipy.org Thu Jan 11 02:34:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 01:34:15 -0600 (CST) Subject: [Scipy-svn] r2531 - in trunk/Lib/sandbox/newoptimize: . tnc Message-ID: <20070111073415.B439B39C031@new.scipy.org> Author: jarrod.millman Date: 2007-01-11 01:34:00 -0600 (Thu, 11 Jan 2007) New Revision: 2531 Modified: trunk/Lib/sandbox/newoptimize/tnc.py trunk/Lib/sandbox/newoptimize/tnc/example.py Log: convert tabs to spaces Modified: trunk/Lib/sandbox/newoptimize/tnc/example.py =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/example.py 2007-01-11 06:19:21 UTC (rev 2530) +++ trunk/Lib/sandbox/newoptimize/tnc/example.py 2007-01-11 07:34:00 UTC (rev 2531) @@ -8,13 +8,13 @@ # Must return a tuple with the function value and the gradient (as a list) # or None to abort the minimization def function(x): - f = pow(x[0],2.0)+pow(abs(x[1]),3.0) - g = [0,0] - g[0] = 2.0*x[0] - g[1] = 3.0*pow(abs(x[1]),2.0) - if x[1]<0: - g[1] = -g[1] - return f, g + f = pow(x[0],2.0)+pow(abs(x[1]),3.0) + g = [0,0] + g[0] = 2.0*x[0] + g[1] = 3.0*pow(abs(x[1]),2.0) + if x[1]<0: + g[1] = -g[1] + return f, g # Optimizer call rc, nf, x = tnc.minimize(function, [-7, 3], [-10, 1], [10, 10]) Modified: trunk/Lib/sandbox/newoptimize/tnc.py =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc.py 2007-01-11 06:19:21 UTC (rev 2530) +++ trunk/Lib/sandbox/newoptimize/tnc.py 2007-01-11 07:34:00 UTC (rev 2531) @@ -42,12 +42,12 @@ MSG_ALL = MSG_ITER + MSG_INFO + MSG_VERS + MSG_EXIT MSGS = { - MSG_NONE : "No messages", - MSG_ITER : "One line per iteration", - MSG_INFO : "Informational messages", - MSG_VERS : "Version info", - MSG_EXIT : "Exit reasons", - MSG_ALL : "All messages" + MSG_NONE : "No messages", + MSG_ITER : "One line per iteration", + MSG_INFO : "Informational messages", + MSG_VERS : "Version info", + MSG_EXIT : "Exit reasons", + MSG_ALL : "All messages" } HUGE_VAL=1e200*1e200 # No standard representation of Infinity in Python 2.3.3 @@ -63,223 +63,223 @@ USERABORT = 7 # User requested end of minimization RCSTRINGS = { - INFEASIBLE : "Infeasible (low > up)", - LOCALMINIMUM : "Local minima reach (|pg| ~= 0)", - FCONVERGED : "Converged (|f_n-f_(n-1)| ~= 0)", - XCONVERGED : "Converged (|x_n-x_(n-1)| ~= 0)", - MAXFUN : "Max. number of function evaluations reach", - LSFAIL : "Linear search failed", - CONSTANT : "All lower bounds are equal to the upper bounds", - NOPROGRESS : "Unable to progress", - USERABORT : "User requested end of minimization" + INFEASIBLE : "Infeasible (low > up)", + LOCALMINIMUM : "Local minima reach (|pg| ~= 0)", + FCONVERGED : "Converged (|f_n-f_(n-1)| ~= 0)", + XCONVERGED : "Converged (|x_n-x_(n-1)| ~= 0)", + MAXFUN : "Max. number of function evaluations reach", + LSFAIL : "Linear search failed", + CONSTANT : "All lower bounds are equal to the upper bounds", + NOPROGRESS : "Unable to progress", + USERABORT : "User requested end of minimization" } def minimize(function, x, low = None, up = None, scale = None, offset = None, - messages = MSG_ALL, maxCGit = -1, maxnfeval = None, eta = -1, stepmx = 0, - accuracy = 0, fmin = 0, ftol = -1, xtol = -1, pgtol = -1, rescale = -1): - """Minimize a function with variables subject to bounds, using gradient - information. - - returns (rc, nfeval, x). + messages = MSG_ALL, maxCGit = -1, maxnfeval = None, eta = -1, stepmx = 0, + accuracy = 0, fmin = 0, ftol = -1, xtol = -1, pgtol = -1, rescale = -1): + """Minimize a function with variables subject to bounds, using gradient + information. - Inputs: - x : initial estimate (a list of floats) - function : the function to minimize. Must take one argument, x and return - f and g, where f is the value of the function and g its - gradient (a list of floats). - if the function returns None, the minimization is aborted. - low, up : the bounds (lists of floats) - set low[i] to -HUGE_VAL to remove the lower bound - set up[i] to HUGE_VAL to remove the upper bound - if low == None, the lower bounds are removed. - if up == None, the upper bounds are removed. - low and up defaults to None - scale : scaling factors to apply to each variable (a list of floats) - if None, the factors are up-low for interval bounded variables - and 1+|x] fo the others. - defaults to None - offset : constant to substract to each variable - if None, the constant are (up+low)/2 for interval bounded - variables and x for the others. - messages : bit mask used to select messages display during minimization - values defined in the MSGS dict. - defaults to MGS_ALL - maxCGit : max. number of hessian*vector evaluation per main iteration - if maxCGit == 0, the direction chosen is -gradient - if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)) - defaults to -1 - maxnfeval : max. number of function evaluation - if None, maxnfeval is set to max(100, 10*len(x0)) - defaults to None - eta : severity of the line search. if < 0 or > 1, set to 0.25 - defaults to -1 - stepmx : maximum step for the line search. may be increased during call - if too small, will be set to 10.0 - defaults to 0 - accuracy : relative precision for finite difference calculations - if <= machine_precision, set to sqrt(machine_precision) - defaults to 0 - fmin : minimum function value estimate - defaults to 0 - ftol : precision goal for the value of f in the stoping criterion - if ftol < 0.0, ftol is set to 0.0 - defaults to -1 - xtol : precision goal for the value of x in the stopping criterion - (after applying x scaling factors) - if xtol < 0.0, xtol is set to sqrt(machine_precision) - defaults to -1 - pgtol : precision goal for the value of the projected gradient in the - stopping criterion (after applying x scaling factors) - if pgtol < 0.0, pgtol is set to 1e-2 * sqrt(accuracy) - setting it to 0.0 is not recommended. - defaults to -1 - rescale : f scaling factor (in log10) used to trigger f value rescaling - if 0, rescale at each iteration - if a large value, never rescale - if < 0, rescale is set to 1.3 + returns (rc, nfeval, x). - Outputs: - x : the solution (a list of floats) - nfeval : the number of function evaluations - rc : return code as defined in the RCSTRINGS dict""" - - if low == None: - low = [-HUGE_VAL]*len(x) - - if up == None: - up = [HUGE_VAL]*len(x) - - if scale == None: - scale = [] + Inputs: + x : initial estimate (a list of floats) + function : the function to minimize. Must take one argument, x and return + f and g, where f is the value of the function and g its + gradient (a list of floats). + if the function returns None, the minimization is aborted. + low, up : the bounds (lists of floats) + set low[i] to -HUGE_VAL to remove the lower bound + set up[i] to HUGE_VAL to remove the upper bound + if low == None, the lower bounds are removed. + if up == None, the upper bounds are removed. + low and up defaults to None + scale : scaling factors to apply to each variable (a list of floats) + if None, the factors are up-low for interval bounded variables + and 1+|x] fo the others. + defaults to None + offset : constant to substract to each variable + if None, the constant are (up+low)/2 for interval bounded + variables and x for the others. + messages : bit mask used to select messages display during minimization + values defined in the MSGS dict. + defaults to MGS_ALL + maxCGit : max. number of hessian*vector evaluation per main iteration + if maxCGit == 0, the direction chosen is -gradient + if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)) + defaults to -1 + maxnfeval : max. number of function evaluation + if None, maxnfeval is set to max(100, 10*len(x0)) + defaults to None + eta : severity of the line search. if < 0 or > 1, set to 0.25 + defaults to -1 + stepmx : maximum step for the line search. may be increased during call + if too small, will be set to 10.0 + defaults to 0 + accuracy : relative precision for finite difference calculations + if <= machine_precision, set to sqrt(machine_precision) + defaults to 0 + fmin : minimum function value estimate + defaults to 0 + ftol : precision goal for the value of f in the stoping criterion + if ftol < 0.0, ftol is set to 0.0 + defaults to -1 + xtol : precision goal for the value of x in the stopping criterion + (after applying x scaling factors) + if xtol < 0.0, xtol is set to sqrt(machine_precision) + defaults to -1 + pgtol : precision goal for the value of the projected gradient in the + stopping criterion (after applying x scaling factors) + if pgtol < 0.0, pgtol is set to 1e-2 * sqrt(accuracy) + setting it to 0.0 is not recommended. + defaults to -1 + rescale : f scaling factor (in log10) used to trigger f value rescaling + if 0, rescale at each iteration + if a large value, never rescale + if < 0, rescale is set to 1.3 - if offset == None: - offset = [] + Outputs: + x : the solution (a list of floats) + nfeval : the number of function evaluations + rc : return code as defined in the RCSTRINGS dict""" - if maxnfeval == None: - maxnfeval = max(100, 10*len(x)) - - return moduleTNC.minimize(function, x, low, up, scale, offset, - messages, maxCGit, maxnfeval, eta, stepmx, accuracy, - fmin, ftol, xtol, pgtol, rescale) + if low == None: + low = [-HUGE_VAL]*len(x) + if up == None: + up = [HUGE_VAL]*len(x) + + if scale == None: + scale = [] + + if offset == None: + offset = [] + + if maxnfeval == None: + maxnfeval = max(100, 10*len(x)) + + return moduleTNC.minimize(function, x, low, up, scale, offset, + messages, maxCGit, maxnfeval, eta, stepmx, accuracy, + fmin, ftol, xtol, pgtol, rescale) + if __name__ == '__main__': - # Examples for TNC + # Examples for TNC - def example(): - print "Example" - # A function to minimize - def function(x): - f = pow(x[0],2.0)+pow(abs(x[1]),3.0) - g = [0,0] - g[0] = 2.0*x[0] - g[1] = 3.0*pow(abs(x[1]),2.0) - if x[1]<0: - g[1] = -g[1] - return f, g + def example(): + print "Example" + # A function to minimize + def function(x): + f = pow(x[0],2.0)+pow(abs(x[1]),3.0) + g = [0,0] + g[0] = 2.0*x[0] + g[1] = 3.0*pow(abs(x[1]),2.0) + if x[1]<0: + g[1] = -g[1] + return f, g - # Optimizer call - rc, nf, x = minimize(function, [-7, 3], [-10, 1], [10, 10]) + # Optimizer call + rc, nf, x = minimize(function, [-7, 3], [-10, 1], [10, 10]) - print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] - print "x =", x - print "exact value = [0, 1]" - print + print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] + print "x =", x + print "exact value = [0, 1]" + print - example() + example() - # Tests - # These tests are taken from Prof. K. Schittkowski test examples for - # constrained nonlinear programming. - # http://www.uni-bayreuth.de/departments/math/~kschittkowski/home.htm - tests = [] - def test1fg(x): - f = 100.0*pow((x[1]-pow(x[0],2)),2)+pow(1.0-x[0],2) - dif = [0,0] - dif[1] = 200.0*(x[1]-pow(x[0],2)) - dif[0] = -2.0*(x[0]*(dif[1]-1.0)+1.0) - return f, dif - tests.append ((test1fg, [-2,1], [-HUGE_VAL, -1.5], None, [1,1])) + # Tests + # These tests are taken from Prof. K. Schittkowski test examples for + # constrained nonlinear programming. + # http://www.uni-bayreuth.de/departments/math/~kschittkowski/home.htm + tests = [] + def test1fg(x): + f = 100.0*pow((x[1]-pow(x[0],2)),2)+pow(1.0-x[0],2) + dif = [0,0] + dif[1] = 200.0*(x[1]-pow(x[0],2)) + dif[0] = -2.0*(x[0]*(dif[1]-1.0)+1.0) + return f, dif + tests.append ((test1fg, [-2,1], [-HUGE_VAL, -1.5], None, [1,1])) - def test2fg(x): - f = 100.0*pow((x[1]-pow(x[0],2)),2)+pow(1.0-x[0],2) - dif = [0,0] - dif[1] = 200.0*(x[1]-pow(x[0],2)) - dif[0] = -2.0*(x[0]*(dif[1]-1.0)+1.0) - return f, dif - tests.append ((test2fg, [-2,1], [-HUGE_VAL, 1.5], None, [-1.2210262419616387,1.5])) + def test2fg(x): + f = 100.0*pow((x[1]-pow(x[0],2)),2)+pow(1.0-x[0],2) + dif = [0,0] + dif[1] = 200.0*(x[1]-pow(x[0],2)) + dif[0] = -2.0*(x[0]*(dif[1]-1.0)+1.0) + return f, dif + tests.append ((test2fg, [-2,1], [-HUGE_VAL, 1.5], None, [-1.2210262419616387,1.5])) - def test3fg(x): - f = x[1]+pow(x[1]-x[0],2)*1.0e-5 - dif = [0,0] - dif[0] = -2.0*(x[1]-x[0])*1.0e-5 - dif[1] = 1.0-dif[0] - return f, dif - tests.append ((test3fg, [10,1], [-HUGE_VAL, 0.0], None, [0,0])) + def test3fg(x): + f = x[1]+pow(x[1]-x[0],2)*1.0e-5 + dif = [0,0] + dif[0] = -2.0*(x[1]-x[0])*1.0e-5 + dif[1] = 1.0-dif[0] + return f, dif + tests.append ((test3fg, [10,1], [-HUGE_VAL, 0.0], None, [0,0])) - def test4fg(x): - f = pow(x[0]+1.0,3)/3.0+x[1] - dif = [0,0] - dif[0] = pow(x[0]+1.0,2) - dif[1] = 1.0 - return f, dif - tests.append ((test4fg, [1.125,0.125], [1, 0], None, [1,0])) + def test4fg(x): + f = pow(x[0]+1.0,3)/3.0+x[1] + dif = [0,0] + dif[0] = pow(x[0]+1.0,2) + dif[1] = 1.0 + return f, dif + tests.append ((test4fg, [1.125,0.125], [1, 0], None, [1,0])) - from math import * + from math import * - def test5fg(x): - f = sin(x[0]+x[1])+pow(x[0]-x[1],2)-1.5*x[0]+2.5*x[1]+1.0 - dif = [0,0] - v1 = cos(x[0]+x[1]); - v2 = 2.0*(x[0]-x[1]); + def test5fg(x): + f = sin(x[0]+x[1])+pow(x[0]-x[1],2)-1.5*x[0]+2.5*x[1]+1.0 + dif = [0,0] + v1 = cos(x[0]+x[1]); + v2 = 2.0*(x[0]-x[1]); - dif[0] = v1+v2-1.5; - dif[1] = v1-v2+2.5; - return f, dif - tests.append ((test5fg, [0,0], [-1.5, -3], [4,3], [-0.54719755119659763, -1.5471975511965976])) + dif[0] = v1+v2-1.5; + dif[1] = v1-v2+2.5; + return f, dif + tests.append ((test5fg, [0,0], [-1.5, -3], [4,3], [-0.54719755119659763, -1.5471975511965976])) - def test38fg(x): - f = (100.0*pow(x[1]-pow(x[0],2),2)+pow(1.0-x[0],2)+90.0*pow(x[3]-pow(x[2],2),2) \ - +pow(1.0-x[2],2)+10.1*(pow(x[1]-1.0,2)+pow(x[3]-1.0,2)) \ - +19.8*(x[1]-1.0)*(x[3]-1.0))*1.0e-5 - dif = [0,0,0,0] - dif[0] = (-400.0*x[0]*(x[1]-pow(x[0],2))-2.0*(1.0-x[0]))*1.0e-5 - dif[1] = (200.0*(x[1]-pow(x[0],2))+20.2*(x[1]-1.0)+19.8*(x[3]-1.0))*1.0e-5 - dif[2] = (-360.0*x[2]*(x[3]-pow(x[2],2))-2.0*(1.0-x[2]))*1.0e-5 - dif[3] = (180.0*(x[3]-pow(x[2],2))+20.2*(x[3]-1.0)+19.8*(x[1]-1.0))*1.0e-5 - return f, dif - tests.append ((test38fg, [-3,-1,-3,-1], [-10]*4, [10]*4, [1]*4)) + def test38fg(x): + f = (100.0*pow(x[1]-pow(x[0],2),2)+pow(1.0-x[0],2)+90.0*pow(x[3]-pow(x[2],2),2) \ + +pow(1.0-x[2],2)+10.1*(pow(x[1]-1.0,2)+pow(x[3]-1.0,2)) \ + +19.8*(x[1]-1.0)*(x[3]-1.0))*1.0e-5 + dif = [0,0,0,0] + dif[0] = (-400.0*x[0]*(x[1]-pow(x[0],2))-2.0*(1.0-x[0]))*1.0e-5 + dif[1] = (200.0*(x[1]-pow(x[0],2))+20.2*(x[1]-1.0)+19.8*(x[3]-1.0))*1.0e-5 + dif[2] = (-360.0*x[2]*(x[3]-pow(x[2],2))-2.0*(1.0-x[2]))*1.0e-5 + dif[3] = (180.0*(x[3]-pow(x[2],2))+20.2*(x[3]-1.0)+19.8*(x[1]-1.0))*1.0e-5 + return f, dif + tests.append ((test38fg, [-3,-1,-3,-1], [-10]*4, [10]*4, [1]*4)) - def test45fg(x): - f = 2.0-x[0]*x[1]*x[2]*x[3]*x[4]/120.0 - dif = [0]*5 - dif[0] = -x[1]*x[2]*x[3]*x[4]/120.0 - dif[1] = -x[0]*x[2]*x[3]*x[4]/120.0 - dif[2] = -x[0]*x[1]*x[3]*x[4]/120.0 - dif[3] = -x[0]*x[1]*x[2]*x[4]/120.0 - dif[4] = -x[0]*x[1]*x[2]*x[3]/120.0 - return f, dif - tests.append ((test45fg, [2]*5, [0]*5, [1,2,3,4,5], [1,2,3,4,5])) + def test45fg(x): + f = 2.0-x[0]*x[1]*x[2]*x[3]*x[4]/120.0 + dif = [0]*5 + dif[0] = -x[1]*x[2]*x[3]*x[4]/120.0 + dif[1] = -x[0]*x[2]*x[3]*x[4]/120.0 + dif[2] = -x[0]*x[1]*x[3]*x[4]/120.0 + dif[3] = -x[0]*x[1]*x[2]*x[4]/120.0 + dif[4] = -x[0]*x[1]*x[2]*x[3]/120.0 + return f, dif + tests.append ((test45fg, [2]*5, [0]*5, [1,2,3,4,5], [1,2,3,4,5])) - def test(fg, x, low, up, xopt): - print "** Test", fg.__name__ - rc, nf, x = minimize(fg, x, low, up, messages = MSG_NONE, maxnfeval = 200) - print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] - print "x =", x - print "exact value =", xopt - enorm = 0.0 - norm = 1.0 - for y,yo in zip(x, xopt): - enorm += (y-yo)*(y-yo) - norm += yo*yo - ex = pow(enorm/norm, 0.5) - print "X Error =", ex - ef = abs(fg(xopt)[0] - fg(x)[0]) - print "F Error =", ef - if ef > 1e-8: - raise "Test "+fg.__name__+" failed" + def test(fg, x, low, up, xopt): + print "** Test", fg.__name__ + rc, nf, x = minimize(fg, x, low, up, messages = MSG_NONE, maxnfeval = 200) + print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] + print "x =", x + print "exact value =", xopt + enorm = 0.0 + norm = 1.0 + for y,yo in zip(x, xopt): + enorm += (y-yo)*(y-yo) + norm += yo*yo + ex = pow(enorm/norm, 0.5) + print "X Error =", ex + ef = abs(fg(xopt)[0] - fg(x)[0]) + print "F Error =", ef + if ef > 1e-8: + raise "Test "+fg.__name__+" failed" - for fg, x, low, up, xopt in tests: - test(fg, x, low, up, xopt) - - print - print "** All TNC tests passed." + for fg, x, low, up, xopt in tests: + test(fg, x, low, up, xopt) + + print + print "** All TNC tests passed." From scipy-svn at scipy.org Thu Jan 11 02:40:48 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 01:40:48 -0600 (CST) Subject: [Scipy-svn] r2532 - trunk/Lib/sandbox/newoptimize/tnc Message-ID: <20070111074048.3020539C031@new.scipy.org> Author: jarrod.millman Date: 2007-01-11 01:40:30 -0600 (Thu, 11 Jan 2007) New Revision: 2532 Modified: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c Log: fix compiler warnings, mostly due to #include "Python.h" after a system header. see [1575] Modified: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 07:34:00 UTC (rev 2531) +++ trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 07:40:30 UTC (rev 2532) @@ -26,10 +26,10 @@ static char const rcsid[] = "@(#) $Jeannot: moduleTNC.c,v 1.12 2005/01/28 18:27:31 js Exp $"; +#include "Python.h" #include #include #include -#include "Python.h" #include "tnc.h" From scipy-svn at scipy.org Thu Jan 11 02:45:29 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 01:45:29 -0600 (CST) Subject: [Scipy-svn] r2533 - trunk/Lib/sandbox/newoptimize/tnc Message-ID: <20070111074529.8A3DE39C031@new.scipy.org> Author: jarrod.millman Date: 2007-01-11 01:45:15 -0600 (Thu, 11 Jan 2007) New Revision: 2533 Modified: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c Log: Fixed extension modules typespecs for mingw32 env. see [1874] Modified: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 07:40:30 UTC (rev 2532) +++ trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 07:45:15 UTC (rev 2533) @@ -304,7 +304,7 @@ {NULL, NULL} }; -void initmoduleTNC(void) +DL_EXPORT(void) initmoduleTNC(void) { (void) Py_InitModule("moduleTNC", moduleTNC_methods); } From scipy-svn at scipy.org Thu Jan 11 02:48:25 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 01:48:25 -0600 (CST) Subject: [Scipy-svn] r2534 - trunk/Lib/sandbox/newoptimize/tnc Message-ID: <20070111074825.623B539C031@new.scipy.org> Author: jarrod.millman Date: 2007-01-11 01:48:11 -0600 (Thu, 11 Jan 2007) New Revision: 2534 Modified: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c Log: Make ext module typespecs to use PyMODINIT_FUNC that is essential for mingw32 and c++ code combination to work correctly. see [1882] Modified: trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 07:45:15 UTC (rev 2533) +++ trunk/Lib/sandbox/newoptimize/tnc/moduleTNC.c 2007-01-11 07:48:11 UTC (rev 2534) @@ -304,7 +304,7 @@ {NULL, NULL} }; -DL_EXPORT(void) initmoduleTNC(void) +PyMODINIT_FUNC initmoduleTNC(void) { (void) Py_InitModule("moduleTNC", moduleTNC_methods); } From scipy-svn at scipy.org Thu Jan 11 04:43:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 03:43:20 -0600 (CST) Subject: [Scipy-svn] r2535 - trunk/Lib/sandbox/newoptimize Message-ID: <20070111094320.5D6DC39C03E@new.scipy.org> Author: jarrod.millman Date: 2007-01-11 03:43:18 -0600 (Thu, 11 Jan 2007) New Revision: 2535 Modified: trunk/Lib/sandbox/newoptimize/tnc.py Log: 1st attempt to replicate the changes to interface made by Travis Oliphant for inclusion in scipy Modified: trunk/Lib/sandbox/newoptimize/tnc.py =================================================================== --- trunk/Lib/sandbox/newoptimize/tnc.py 2007-01-11 07:48:11 UTC (rev 2534) +++ trunk/Lib/sandbox/newoptimize/tnc.py 2007-01-11 09:43:18 UTC (rev 2535) @@ -33,6 +33,7 @@ """ import moduleTNC +from numpy import asarray MSG_NONE = 0 # No messages MSG_ITER = 1 # One line per iteration @@ -51,6 +52,7 @@ } HUGE_VAL=1e200*1e200 # No standard representation of Infinity in Python 2.3.3 + # FIXME: can we use inf now that we have numpy and IEEE floats? INFEASIBLE = -1 # Infeasible (low > up) LOCALMINIMUM = 0 # Local minima reach (|pg| ~= 0) @@ -74,26 +76,34 @@ USERABORT : "User requested end of minimization" } -def minimize(function, x, low = None, up = None, scale = None, offset = None, - messages = MSG_ALL, maxCGit = -1, maxnfeval = None, eta = -1, stepmx = 0, - accuracy = 0, fmin = 0, ftol = -1, xtol = -1, pgtol = -1, rescale = -1): +# Changes to interface made by Travis Oliphant, Apr. 2004 for inclusion in +# SciPy + +import optimize +approx_fprime = optimize.approx_fprime + +def fmin_tnc(func, x0, fprime=None, args=(), approx_grad=0, bounds=None, epsilon=1e-8, + scale=None, offset=None, messages=MSG_ALL, maxCGit=-1, maxfun=None, eta=-1, + stepmx=0, accuracy=0, fmin=0, ftol=-1, xtol=-1, pgtol=-1, rescale=-1): """Minimize a function with variables subject to bounds, using gradient information. returns (rc, nfeval, x). Inputs: - x : initial estimate (a list of floats) - function : the function to minimize. Must take one argument, x and return + func : the function to minimize. Must take one argument, x and return f and g, where f is the value of the function and g its gradient (a list of floats). if the function returns None, the minimization is aborted. - low, up : the bounds (lists of floats) - set low[i] to -HUGE_VAL to remove the lower bound - set up[i] to HUGE_VAL to remove the upper bound - if low == None, the lower bounds are removed. - if up == None, the upper bounds are removed. - low and up defaults to None + x0 : initial estimate (a list of floats) + fprime : gradient of func. If None, then func returns the function + value and the gradient ( f, g = func(x, *args) ). + Called as fprime(x, *args) + args : arguments to pass to function + approx_grad : if true, approximate the gradient numerically + bounds : a list of (min, max) pairs for each element in x, defining + the bounds on that parameter. Use None for one of min or max + when there is no bound in that direction scale : scaling factors to apply to each variable (a list of floats) if None, the factors are up-low for interval bounded variables and 1+|x] fo the others. @@ -108,8 +118,8 @@ if maxCGit == 0, the direction chosen is -gradient if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)) defaults to -1 - maxnfeval : max. number of function evaluation - if None, maxnfeval is set to max(100, 10*len(x0)) + maxfun : max. number of function evaluation + if None, maxfun is set to max(100, 10*len(x0)) defaults to None eta : severity of the line search. if < 0 or > 1, set to 0.25 defaults to -1 @@ -141,25 +151,85 @@ Outputs: x : the solution (a list of floats) nfeval : the number of function evaluations - rc : return code as defined in the RCSTRINGS dict""" + rc : return code as defined in the RCSTRINGS dict - if low == None: - low = [-HUGE_VAL]*len(x) +See also: - if up == None: - up = [HUGE_VAL]*len(x) + fmin, fmin_powell, fmin_cg, + fmin_bfgs, fmin_ncg -- multivariate local optimizers + leastsq -- nonlinear least squares minimizer + fmin_l_bfgs_b, fmin_tnc, + fmin_cobyla -- constrained multivariate optimizers + + anneal, brute -- global optimizers + + fminbound, brent, golden, bracket -- local scalar minimizers + + fsolve -- n-dimenstional root-finding + + brentq, brenth, ridder, bisect, newton -- one-dimensional root-finding + + fixed_point -- scalar fixed-point finder +""" + + n = len(x0) + + if bounds is None: + bounds = [(None,None)] * n + if len(bounds) != n: + raise ValueError('length of x0 != length of bounds') + + if approx_grad: + def func_and_grad(x): + x = asarray(x) + f = func(x, *args) + g = approx_fprime(x, func, epsilon, *args) + return f, list(g) + elif fprime is None: + def func_and_grad(x): + x = asarray(x) + f, g = func(x, *args) + return f, list(g) + else: + def func_and_grad(x): + x = asarray(x) + f = func(x, *args) + g = fprime(x, *args) + return f, list(g) + + """ + low, up : the bounds (lists of floats) + set low[i] to -HUGE_VAL to remove the lower bound + set up[i] to HUGE_VAL to remove the upper bound + if low == None, the lower bounds are removed. + if up == None, the upper bounds are removed. + low and up defaults to None + """ + low = [0]*n + up = [0]*n + for i in range(n): + l,u = bounds[i] + if l is None: + low[i] = -HUGE_VAL + else: + low[i] = l + if u is None: + up[i] = HUGE_VAL + else: + up[i] = u + if scale == None: scale = [] if offset == None: offset = [] - if maxnfeval == None: - maxnfeval = max(100, 10*len(x)) + if maxfun == None: + maxfun = max(100, 10*len(x0)) - return moduleTNC.minimize(function, x, low, up, scale, offset, - messages, maxCGit, maxnfeval, eta, stepmx, accuracy, + return moduleTNC.minimize(func_and_grad, x0, low, up, scale, offset, + messages, maxCGit, maxfun, eta, stepmx, accuracy, fmin, ftol, xtol, pgtol, rescale) if __name__ == '__main__': @@ -178,7 +248,7 @@ return f, g # Optimizer call - rc, nf, x = minimize(function, [-7, 3], [-10, 1], [10, 10]) + rc, nf, x = fmin_tnc(function, [-7, 3], bounds=([-10, 1], [10, 10])) print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] print "x =", x @@ -260,9 +330,9 @@ return f, dif tests.append ((test45fg, [2]*5, [0]*5, [1,2,3,4,5], [1,2,3,4,5])) - def test(fg, x, low, up, xopt): + def test(fg, x, bounds, xopt): print "** Test", fg.__name__ - rc, nf, x = minimize(fg, x, low, up, messages = MSG_NONE, maxnfeval = 200) + rc, nf, x = fmin_tnc(fg, x, bounds=bounds, messages = MSG_NONE, maxnfeval = 200) print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] print "x =", x print "exact value =", xopt @@ -278,8 +348,8 @@ if ef > 1e-8: raise "Test "+fg.__name__+" failed" - for fg, x, low, up, xopt in tests: - test(fg, x, low, up, xopt) + for fg, x, bounds, xopt in tests: + test(fg, x, bounds, xopt) print print "** All TNC tests passed." From scipy-svn at scipy.org Thu Jan 11 10:53:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 09:53:23 -0600 (CST) Subject: [Scipy-svn] r2536 - trunk/Lib/sparse Message-ID: <20070111155323.8DC8C39C037@new.scipy.org> Author: wnbell Date: 2007-01-11 09:53:21 -0600 (Thu, 11 Jan 2007) New Revision: 2536 Modified: trunk/Lib/sparse/sparse.py Log: coo_matrix._check() now checks for valid row/column indices Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-11 09:43:18 UTC (rev 2535) +++ trunk/Lib/sparse/sparse.py 2007-01-11 15:53:21 UTC (rev 2536) @@ -6,7 +6,7 @@ """ from numpy import zeros, isscalar, real, imag, asarray, asmatrix, matrix, \ - ndarray, amax, rank, conj, searchsorted, ndarray, \ + ndarray, amax, amin, rank, conj, searchsorted, ndarray, \ less, where, greater, array, transpose, empty, ones, \ arange, shape, intc import numpy @@ -2088,6 +2088,8 @@ raise TypeError, "invalid input format" if dims is None: + if len(ij[0]) == 0 or len(ij[1]) == 0: + raise ValueError, "cannot infer dimensions from zero sized index arrays" M = int(amax(ij[0])) + 1 N = int(amax(ij[1])) + 1 self.shape = (M, N) @@ -2095,6 +2097,7 @@ # Use 2 steps to ensure dims has length 2. M, N = dims self.shape = (M, N) + self.row = asarray(ij[0], dtype=numpy.intc) self.col = asarray(ij[1], dtype=numpy.intc) self.data = asarray(obj, dtype=self.dtype) @@ -2113,6 +2116,16 @@ if (self.col.dtype != numpy.intc): self.col = self.col.astype(numpy.intc) + if nnz > 0: + if(amax(self.row) >= self.shape[0]): + raise ValueError, "row index exceedes matrix dimensions" + if(amax(self.col) >= self.shape[1]): + raise ValueError, "column index exceedes matrix dimensions" + if(amin(self.row) < 0): + raise ValueError, "negative row index found" + if(amin(self.col) < 0): + raise ValueError, "negative column index found" + # some functions pass floats self.shape = tuple([int(x) for x in self.shape]) self.nnz = nnz From scipy-svn at scipy.org Thu Jan 11 13:26:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 12:26:05 -0600 (CST) Subject: [Scipy-svn] r2537 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070111182605.2A23639C00A@new.scipy.org> Author: mattknox_ca Date: 2007-01-11 12:26:01 -0600 (Thu, 11 Jan 2007) New Revision: 2537 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added support for additional frequencies. Fixed some bugs Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-11 15:53:21 UTC (rev 2536) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-11 18:26:01 UTC (rev 2537) @@ -7,6 +7,13 @@ static char cseries_doc[] = "Speed sensitive time series operations"; +/* +these are the earliest values at each frequency that can be converted +to frequencies higher than daily (ie. Hourly, Minutely, Secondly) +*/ + +static long minval_D_toHighFreq = 719163; + /////////////////////////////////////////////////////////////////////// // helpers for frequency conversion routines // @@ -83,137 +90,6 @@ // frequency specifc conversion routines // each function must take an integer fromDate and a char relation ('B' or 'A' for 'BEFORE' or 'AFTER') -//************ FROM ANNUAL *************** - -static long asfreq_AtoQ(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 4 + 1; } - else { return (fromDate + 1) * 4; } -} - -static long asfreq_AtoM(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 12 + 1; } - else { return (fromDate + 1) * 12; } -} - -static long asfreq_AtoW(long fromDate, char relation) { return 0; } - -static long asfreq_AtoB(long fromDate, char relation) { - if (relation == 'B') { return busday_before(fromDate,1,1); } - else { return busday_after(fromDate+1,1,1); } -} - -static long asfreq_AtoD(long fromDate, char relation) { - if (relation == 'B') { return absdate_from_ymd(fromDate,1,1); } - else { return absdate_from_ymd(fromDate+1,1,1) - 1; } -} - -static long asfreq_AtoH(long fromDate, char relation) { return 0; } -static long asfreq_AtoT(long fromDate, char relation) { return 0; } -static long asfreq_AtoS(long fromDate, char relation) { return 0; } - - -//************ FROM QUARTERLY *************** - -static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1) / 4; } - -static long asfreq_QtoM(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 3 - 2; } - else { return fromDate * 3; } -} - -static long asfreq_QtoW(long fromDate, char relation) { return 0; } - -static void QtoD_ym(long fromDate, long *y, long *m) { - *y = (fromDate - 1) / 4; - *m = fromDate * 3 - 12 * (*y) - 2; -} - -static long asfreq_QtoB(long fromDate, char relation) { - - long y, m; - - if (relation == 'B') { - QtoD_ym(fromDate, &y, &m); - return busday_before(y,m,1); - } else { - QtoD_ym(fromDate+1, &y, &m); - return busday_after(y, m, 1); - } -} - -static long asfreq_QtoD(long fromDate, char relation) { - - long y, m; - - if (relation == 'B') { - QtoD_ym(fromDate, &y, &m); - return absdate_from_ymd(y, m, 1); - } else { - QtoD_ym(fromDate+1, &y, &m); - return absdate_from_ymd(y, m, 1) - 1; - } -} - -static long asfreq_QtoH(long fromDate, char relation) { return 0; } -static long asfreq_QtoT(long fromDate, char relation) { return 0; } -static long asfreq_QtoS(long fromDate, char relation) { return 0; } - - -//************ FROM MONTHLY *************** - -static long asfreq_MtoA(long fromDate, char relation) { return (fromDate - 1) / 12; } -static long asfreq_MtoQ(long fromDate, char relation) { return (fromDate - 1) / 3 + 1; } - -static long asfreq_MtoW(long fromDate, char relation) { return 0; } - -static void MtoD_ym(long fromDate, long *y, long *m) { - *y = (fromDate - 1) / 12; - *m = fromDate - 12 * (*y); -} - -static long asfreq_MtoB(long fromDate, char relation) { - - long y, m; - - if (relation == 'B') { - MtoD_ym(fromDate, &y, &m); - return busday_before(y,m,1); - } else { - MtoD_ym(fromDate+1, &y, &m); - return busday_after(y, m, 1); - } -} - -static long asfreq_MtoD(long fromDate, char relation) { - - long y, m; - - if (relation == 'B') { - MtoD_ym(fromDate, &y, &m); - return absdate_from_ymd(y, m, 1); - } else { - MtoD_ym(fromDate+1, &y, &m); - return absdate_from_ymd(y, m, 1) - 1; - } -} - -static long asfreq_MtoH(long fromDate, char relation) { return 0; } -static long asfreq_MtoT(long fromDate, char relation) { return 0; } -static long asfreq_MtoS(long fromDate, char relation) { return 0; } - - -//************ FROM WEEKLY *************** - -static long asfreq_WtoA(long fromDate, char relation) { return 0; } -static long asfreq_WtoQ(long fromDate, char relation) { return 0; } -static long asfreq_WtoM(long fromDate, char relation) { return 0; } -static long asfreq_WtoB(long fromDate, char relation) { return 0; } -static long asfreq_WtoD(long fromDate, char relation) { return 0; } -static long asfreq_WtoH(long fromDate, char relation) { return 0; } -static long asfreq_WtoT(long fromDate, char relation) { return 0; } -static long asfreq_WtoS(long fromDate, char relation) { return 0; } - - //************ FROM DAILY *************** static long asfreq_DtoA(long fromDate, char relation) { @@ -248,7 +124,7 @@ } -static long asfreq_DtoW(long fromDate, char relation) { return 0; } +static long asfreq_DtoW(long fromDate, char relation) { return -1; } static long asfreq_DtoB(long fromDate, char relation) { mxDateTimeObject *mxDate; @@ -281,11 +157,67 @@ return result; } +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); } + } else { return -1; } +} -static long asfreq_DtoH(long fromDate, char relation) { return 0; } -static long asfreq_DtoT(long fromDate, char relation) { return 0; } -static long asfreq_DtoS(long fromDate, char relation) { return 0; } +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); } +//************ FROM SECONDLY *************** + +static long asfreq_StoD(long fromDate, char relation) { 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; } + +//************ FROM MINUTELY *************** + +static long asfreq_TtoD(long fromDate, char relation) { 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_TtoB_forConvert(long fromDate, char relation) + { return asfreq_DtoB_forConvert(asfreq_TtoD(fromDate, relation), relation); } + +static long asfreq_TtoH(long fromDate, char relation) { return (fromDate - 1)/60 + 1; } +static long asfreq_TtoS(long fromDate, char relation) { + 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_HtoB_forConvert(long fromDate, char relation) + { return asfreq_DtoB_forConvert(asfreq_HtoD(fromDate, relation), relation); } + +// 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) { + 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) { @@ -312,42 +244,135 @@ static long asfreq_BtoS(long fromDate, char relation) { return asfreq_DtoS(asfreq_BtoD(fromDate, relation), relation); } -//************ FROM HOURLY *************** +//************ FROM WEEKLY *************** -static long asfreq_HtoA(long fromDate, char relation) { return 0; } -static long asfreq_HtoQ(long fromDate, char relation) { return 0; } -static long asfreq_HtoM(long fromDate, char relation) { return 0; } -static long asfreq_HtoW(long fromDate, char relation) { return 0; } -static long asfreq_HtoB(long fromDate, char relation) { return 0; } -static long asfreq_HtoB_forConvert(long fromDate, char relation) { return 0; } -static long asfreq_HtoD(long fromDate, char relation) { return 0; } -static long asfreq_HtoT(long fromDate, char relation) { return 0; } -static long asfreq_HtoS(long fromDate, char relation) { return 0; } +static long asfreq_WtoA(long fromDate, char relation) { return -1; } +static long asfreq_WtoQ(long fromDate, char relation) { return -1; } +static long asfreq_WtoM(long fromDate, char relation) { return -1; } +static long asfreq_WtoB(long fromDate, char relation) { return -1; } +static long asfreq_WtoD(long fromDate, char relation) { return -1; } +static long asfreq_WtoH(long fromDate, char relation) { return -1; } +static long asfreq_WtoT(long fromDate, char relation) { return -1; } +static long asfreq_WtoS(long fromDate, char relation) { return -1; } -//************ FROM MINUTELY *************** +//************ FROM MONTHLY *************** -static long asfreq_TtoA(long fromDate, char relation) { return 0; } -static long asfreq_TtoQ(long fromDate, char relation) { return 0; } -static long asfreq_TtoM(long fromDate, char relation) { return 0; } -static long asfreq_TtoW(long fromDate, char relation) { return 0; } -static long asfreq_TtoB(long fromDate, char relation) { return 0; } -static long asfreq_TtoB_forConvert(long fromDate, char relation) { return 0; } -static long asfreq_TtoD(long fromDate, char relation) { return 0; } -static long asfreq_TtoH(long fromDate, char relation) { return 0; } -static long asfreq_TtoS(long fromDate, char relation) { return 0; } +static long asfreq_MtoA(long fromDate, char relation) { return (fromDate - 1) / 12; } +static long asfreq_MtoQ(long fromDate, char relation) { return (fromDate - 1) / 3 + 1; } -//************ FROM SECONDLY *************** +static long asfreq_MtoW(long fromDate, char relation) { return -1; } -static long asfreq_StoA(long fromDate, char relation) { return 0; } -static long asfreq_StoQ(long fromDate, char relation) { return 0; } -static long asfreq_StoM(long fromDate, char relation) { return 0; } -static long asfreq_StoW(long fromDate, char relation) { return 0; } -static long asfreq_StoB(long fromDate, char relation) { return 0; } -static long asfreq_StoB_forConvert(long fromDate, char relation) { return 0; } -static long asfreq_StoD(long fromDate, char relation) { return 0; } -static long asfreq_StoH(long fromDate, char relation) { return 0; } -static long asfreq_StoT(long fromDate, char relation) { return 0; } +static void MtoD_ym(long fromDate, long *y, long *m) { + *y = (fromDate - 1) / 12; + *m = fromDate - 12 * (*y); +} +static long asfreq_MtoB(long fromDate, char relation) { + + long y, m; + + if (relation == 'B') { + MtoD_ym(fromDate, &y, &m); + return busday_before(y,m,1); + } else { + MtoD_ym(fromDate+1, &y, &m); + return busday_after(y, m, 1); + } +} + +static long asfreq_MtoD(long fromDate, char relation) { + + long y, m; + + if (relation == 'B') { + MtoD_ym(fromDate, &y, &m); + return absdate_from_ymd(y, m, 1); + } else { + MtoD_ym(fromDate+1, &y, &m); + return absdate_from_ymd(y, m, 1) - 1; + } +} + +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); } + +//************ FROM QUARTERLY *************** + +static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1) / 4; } + +static long asfreq_QtoM(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 3 - 2; } + else { return fromDate * 3; } +} + +static long asfreq_QtoW(long fromDate, char relation) { return -1; } + +static void QtoD_ym(long fromDate, long *y, long *m) { + *y = (fromDate - 1) / 4; + *m = fromDate * 3 - 12 * (*y) - 2; +} + +static long asfreq_QtoB(long fromDate, char relation) { + + long y, m; + + if (relation == 'B') { + QtoD_ym(fromDate, &y, &m); + return busday_before(y,m,1); + } else { + QtoD_ym(fromDate+1, &y, &m); + return busday_after(y, m, 1); + } +} + +static long asfreq_QtoD(long fromDate, char relation) { + + long y, m; + + if (relation == 'B') { + QtoD_ym(fromDate, &y, &m); + return absdate_from_ymd(y, m, 1); + } else { + QtoD_ym(fromDate+1, &y, &m); + return absdate_from_ymd(y, m, 1) - 1; + } +} + +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); } + + +//************ FROM ANNUAL *************** + +static long asfreq_AtoQ(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 4 + 1; } + else { return (fromDate + 1) * 4; } +} + +static long asfreq_AtoM(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 12 + 1; } + else { return (fromDate + 1) * 12; } +} + +static long asfreq_AtoW(long fromDate, char relation) { return -1; } + +static long asfreq_AtoB(long fromDate, char relation) { + if (relation == 'B') { return busday_before(fromDate,1,1); } + else { return busday_after(fromDate+1,1,1); } +} + +static long asfreq_AtoD(long fromDate, char relation) { + if (relation == 'B') { return absdate_from_ymd(fromDate,1,1); } + else { return absdate_from_ymd(fromDate+1,1,1) - 1; } +} + +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 nofunc(long fromDate, char relation) { return -1; } // end of frequency specific conversion routines @@ -494,82 +519,11 @@ } } -static long dInfo_year(mxDateTimeObject *dateObj) { return dateObj->year; } -static long dInfo_quarter(mxDateTimeObject *dateObj) { return ((dateObj->month-1)/3)+1; } -static long dInfo_month(mxDateTimeObject *dateObj) { return dateObj->month; } -static long dInfo_day(mxDateTimeObject *dateObj) { return dateObj->day; } -static long dInfo_dow(mxDateTimeObject *dateObj) { return dateObj->day_of_week; } - -static char cseries_getDateInfo_doc[] = ""; -static PyObject * -cseries_getDateInfo(PyObject *self, PyObject *args) -{ - char *freq; - char *info; - - PyArrayObject *array; - PyArrayObject *newArray; - PyArrayIterObject *iterSource, *iterResult; - mxDateTimeObject *convDate; - - PyObject *val; - long dateNum, dInfo; - - long (*toDaily)(long, char) = NULL; - long (*getDateInfo)(mxDateTimeObject*) = NULL; - - if (!PyArg_ParseTuple(args, "Oss: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, 'D', 0); - - switch(*info) - { - case 'Y': //year - getDateInfo = &dInfo_year; - break; - case 'Q': //quarter - getDateInfo = &dInfo_quarter; - break; - case 'M': //month - getDateInfo = &dInfo_month; - break; - case 'D': //day - getDateInfo = &dInfo_day; - break; - case 'W': //day of week - getDateInfo = &dInfo_dow; - break; - default: - return NULL; - } - - while (iterSource->index < iterSource->size) { - - val = PyArray_GETITEM(array, iterSource->dataptr); - dateNum = PyInt_AsLong(val); - - convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(toDaily(dateNum, 'A'), 0); - dInfo = getDateInfo(convDate); - Py_DECREF(convDate); - - PyArray_SETITEM(newArray, iterResult->dataptr, PyInt_FromLong(dInfo)); - - PyArray_ITER_NEXT(iterSource); - PyArray_ITER_NEXT(iterResult); - } - - Py_DECREF(iterSource); - Py_DECREF(iterResult); - - return (PyObject *) newArray; - -} - - +/* +Helper function for cseries_convert: + determine the size of the second dimension for the resulting + converted array +*/ static long get_height(char fromFreq, char toFreq) { int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; @@ -626,6 +580,7 @@ static PyObject * cseries_convert(PyObject *self, PyObject *args) { + PyObject *arrayTest; PyArrayObject *array, *newArray; PyArrayObject *mask, *newMask; @@ -685,7 +640,7 @@ //convert end index to new frequency newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A'); - if (newEndTemp == -1) { newEnd = asfreq_endpoints(startIndex, 'B'); } + if (newEndTemp == -1) { newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B'); } else { newEnd = newEndTemp; } newLen = newEnd - newStart + 1; @@ -698,16 +653,18 @@ nd = 2; dim = PyDimMem_NEW(nd); - dim[0] = newLen; - dim[1] = newHeight; + dim[0] = (npy_intp)newLen; + dim[1] = (npy_intp)newHeight; } else { nd = 1; dim = PyDimMem_NEW(nd); - dim[0] = newLen; + dim[0] = (npy_intp)newLen; } newIdx = PyDimMem_NEW(nd); - newArray = (PyArrayObject*)PyArray_SimpleNew(nd, dim, array->descr->type_num); + arrayTest = PyArray_SimpleNew(nd, dim, array->descr->type_num); + if (arrayTest == NULL) { return NULL; } + newArray = (PyArrayObject*)arrayTest; newMask = (PyArrayObject*)PyArray_SimpleNew(nd, dim, mask->descr->type_num); PyDimMem_FREE(dim); @@ -805,7 +762,81 @@ } +static long dInfo_year(mxDateTimeObject *dateObj) { return dateObj->year; } +static long dInfo_quarter(mxDateTimeObject *dateObj) { return ((dateObj->month-1)/3)+1; } +static long dInfo_month(mxDateTimeObject *dateObj) { return dateObj->month; } +static long dInfo_day(mxDateTimeObject *dateObj) { return dateObj->day; } +static long dInfo_dow(mxDateTimeObject *dateObj) { return dateObj->day_of_week; } +static char cseries_getDateInfo_doc[] = ""; +static PyObject * +cseries_getDateInfo(PyObject *self, PyObject *args) +{ + char *freq; + char *info; + + PyArrayObject *array; + PyArrayObject *newArray; + PyArrayIterObject *iterSource, *iterResult; + mxDateTimeObject *convDate; + + PyObject *val; + long dateNum, dInfo; + + long (*toDaily)(long, char) = NULL; + long (*getDateInfo)(mxDateTimeObject*) = NULL; + + if (!PyArg_ParseTuple(args, "Oss: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, 'D', 0); + + switch(*info) + { + case 'Y': //year + getDateInfo = &dInfo_year; + break; + case 'Q': //quarter + getDateInfo = &dInfo_quarter; + break; + case 'M': //month + getDateInfo = &dInfo_month; + break; + case 'D': //day + getDateInfo = &dInfo_day; + break; + case 'W': //day of week + getDateInfo = &dInfo_dow; + break; + default: + return NULL; + } + + while (iterSource->index < iterSource->size) { + + val = PyArray_GETITEM(array, iterSource->dataptr); + dateNum = PyInt_AsLong(val); + + convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(toDaily(dateNum, 'A'), 0); + dInfo = getDateInfo(convDate); + Py_DECREF(convDate); + + PyArray_SETITEM(newArray, iterResult->dataptr, PyInt_FromLong(dInfo)); + + PyArray_ITER_NEXT(iterSource); + PyArray_ITER_NEXT(iterResult); + } + + Py_DECREF(iterSource); + Py_DECREF(iterResult); + + return (PyObject *) newArray; + +} + /////////////////////////////////////////////////////////////////////// static PyMethodDef cseries_methods[] = { From scipy-svn at scipy.org Thu Jan 11 13:44:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 12:44:54 -0600 (CST) Subject: [Scipy-svn] r2538 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070111184454.0F67A39C00A@new.scipy.org> Author: mattknox_ca Date: 2007-01-11 12:44:52 -0600 (Thu, 11 Jan 2007) New Revision: 2538 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added error handling for converting to a high frequency when the start_date of the source series is outside the allowable range Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-11 18:26:01 UTC (rev 2537) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-11 18:44:52 UTC (rev 2538) @@ -635,14 +635,19 @@ //convert start index to new frequency newStartTemp = asfreq_main(startIndex, 'B'); - if (newStartTemp == -1) { newStart = asfreq_endpoints(startIndex, 'A'); } + if (newStartTemp < 1) { newStart = asfreq_endpoints(startIndex, 'A'); } else { newStart = newStartTemp; } //convert end index to new frequency newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A'); - if (newEndTemp == -1) { newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B'); } + if (newEndTemp < 1) { newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B'); } else { newEnd = newEndTemp; } + if (newStart < 1) { + PyErr_SetString(PyExc_ValueError, "start_date outside allowable range for destination frequency"); + return NULL; + } + newLen = newEnd - newStart + 1; newHeight = get_height(fromFreq[0], toFreq[0]); From scipy-svn at scipy.org Thu Jan 11 20:16:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 19:16:34 -0600 (CST) Subject: [Scipy-svn] r2539 - in trunk/Lib: linsolve linsolve/umfpack sparse sparse/tests Message-ID: <20070112011634.4999B39C114@new.scipy.org> Author: timl Date: 2007-01-11 19:16:24 -0600 (Thu, 11 Jan 2007) New Revision: 2539 Modified: trunk/Lib/linsolve/linsolve.py trunk/Lib/linsolve/umfpack/umfpack.py trunk/Lib/sparse/sparse.py trunk/Lib/sparse/tests/test_sparse.py Log: further refactoring to sparse matrices Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-01-11 18:44:52 UTC (rev 2538) +++ trunk/Lib/linsolve/linsolve.py 2007-01-12 01:16:24 UTC (rev 2539) @@ -87,10 +87,7 @@ else: mat, csc = _toCS_superLU( A ) - if csc: - index0 = mat.rowind - else: - index0 = mat.colind + index0 = mat.index ftype, lastel, data, index1 = mat.ftype, mat.nnz, mat.data, mat.indptr gssv = eval('_superlu.' + ftype + 'gssv') b = asarray(b, dtype=data.dtype) @@ -115,7 +112,7 @@ csc = A.tocsc() gstrf = eval('_superlu.' + csc.ftype + 'gstrf') - return gstrf(N, csc.nnz, csc.data, csc.rowind, csc.indptr, permc_spec, + return gstrf(N, csc.nnz, csc.data, csc.index, csc.indptr, permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) def _testme(): Modified: trunk/Lib/linsolve/umfpack/umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-11 18:44:52 UTC (rev 2538) +++ trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-12 01:16:24 UTC (rev 2539) @@ -317,10 +317,10 @@ def _getIndx( self, mtx ): if sp.isspmatrix_csc( mtx ): - indx = mtx.rowind + indx = mtx.index self.isCSR = 0 elif sp.isspmatrix_csr( mtx ): - indx = mtx.colind + indx = mtx.index self.isCSR = 1 else: raise TypeError, 'must be a CSC/CSR matrix (is %s)' % mtx.__class__ Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-11 18:44:52 UTC (rev 2538) +++ trunk/Lib/sparse/sparse.py 2007-01-12 01:16:24 UTC (rev 2539) @@ -5,6 +5,8 @@ Revision of sparsetools by Nathan Bell """ +import warnings + from numpy import zeros, isscalar, real, imag, asarray, asmatrix, matrix, \ ndarray, amax, amin, rank, conj, searchsorted, ndarray, \ less, where, greater, array, transpose, empty, ones, \ @@ -484,7 +486,7 @@ - def __add__(self, other, self_ind, other_ind, fn, cls): + def __add__(self, other, fn): # First check if argument is a scalar if isscalarlike(other): # Now we would add this scalar to every element. @@ -494,17 +496,12 @@ other = other.tocsc() if (other.shape != self.shape): raise ValueError, "inconsistent shapes" - if other_ind: - other = other.tocsc() - other_ind = other.rowind - else: - other = other.tocsr() - other_ind = other.colind + other = self._tothis(other) indptr, ind, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, \ + self.indptr, self.index, \ self.data, other.indptr, \ - other_ind, other.data) - return cls((data, ind, indptr), self.shape) + other.index, other.data) + return self.__class__((data, ind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them return other + self.todense() @@ -546,7 +543,7 @@ new.data *= -1 return new - def __pow__(self, other, self_ind, other_ind, fn, cls): + def __pow__(self, other, fn): """ Element-by-element power (unless other is a scalar, in which case return the matrix power.) """ @@ -557,40 +554,29 @@ new.ftype = _transtabl[new.dtype.char] return new elif isspmatrix(other): - if other_ind: - other = other.tocsc() - other_ind = other.rowind - else: - other = other.tocsr() - other_ind = other.colind - + other = self._tothis(other) if (other.shape != self.shape): raise ValueError, "inconsistent shapes" indptr, ind, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, \ + self.indptr, self.index, \ self.data, other.indptr, \ - other_ind, other.data) - return cls((data, ind, indptr), (self.shape[0], other.shape[1])) + other.index, other.data) + return self.__class__((data, ind, indptr), (self.shape[0], other.shape[1])) else: raise TypeError, "unsupported type for sparse matrix power" - def _matmat(self, other, self_ind, other_ind, fn, cls): + def _matmat(self, other, fn): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" - if other_ind: - other = other.tocsc() - other_ind = other.rowind - else: - other = other.tocsr() - other_ind = other.colind - indptr, ind, data = fn(M, N, self.indptr, self_ind, \ + other = self._tothis(other) + indptr, ind, data = fn(M, N, self.indptr, self.index, \ self.data, other.indptr, \ - other_ind, other.data) - return cls((data, ind, indptr), (M, N)) + other.index, other.data) + return self.__class__((data, ind, indptr), (M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! @@ -598,7 +584,7 @@ else: raise TypeError, "need a dense or sparse matrix" - def _matvec(self, other, self_ind, fn): + def _matvec(self, other, fn): if isdense(other): # This check is too harsh -- it prevents a column vector from # being created on-the-fly like dense matrix objects can. @@ -606,7 +592,7 @@ # raise ValueError, "dimension mismatch" oth = numpy.ravel(other) y = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, self.data, oth) + self.indptr, self.index, self.data, oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -630,7 +616,7 @@ else: cd = self.data oth = numpy.ravel(other) - y = fn(shape0, shape1, self.indptr, self.rowind, cd, oth) + y = fn(shape0, shape1, self.indptr, self.index, cd, oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' @@ -646,13 +632,80 @@ def getdata(self, ind): return self.data[ind] - def _tocoo(self, fn, self_ind): + def _tocoo(self, fn): rows, cols, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self_ind, self.data) + self.indptr, self.index, self.data) return coo_matrix((data, (rows, cols)), self.shape) + def copy(self): + new = self.__class__(self.shape, nzmax=self.nzmax, dtype=self.dtype) + new.data = self.data.copy() + new.index = self.index.copy() + new.indptr = self.indptr.copy() + new._check() + return new + + def _get_slice(self, i, start, stop, stride, dims): + """Returns a view of the elements [i, myslice.start:myslice.stop]. + """ + if stride != 1: + raise ValueError, "slicing with step != 1 not supported" + if stop <= start: + raise ValueError, "slice width must be >= 1" + + indices = [] + + for ind in xrange(self.indptr[i], self.indptr[i+1]): + if self.index[ind] >= start and self.index[ind] < stop: + indices.append(ind) + + index = self.index[indices] - start + data = self.data[indices] + indptr = numpy.array([0, len(indices)]) + return self.__class__((data, index, indptr), dims=dims, \ + dtype=self.dtype) + + + def _transpose(self, cls, copy=False): + M, N = self.shape + if copy: + data = self.data.copy() + index = self.index.copy() + indptr = self.indptr.copy() + else: + data = self.data + index = self.index + indptr = self.indptr + return cls((data,index,indptr),(N,M)) + + + def conj(self, copy=False): + new = self.__class__(self.shape, nzmax=self.nzmax, dtype=self.dtype) + if copy: + new.data = self.data.conj().copy() + new.index = self.index.conj().copy() + new.indptr = self.indptr.conj().copy() + else: + new.data = self.data.conj() + new.index = self.index.conj() + new.indptr = self.indptr.conj() + new._check() + return new + + def _ensure_sorted_indices(self, shape0, shape1, inplace=False): + """Return a copy of this matrix where the row indices are sorted + """ + if inplace: + sparsetools.ensure_sorted_indices(shape0, shape1, + self.indptr, self.index, + self.data ) + else: + return self._toother()._toother() + + + class csc_matrix(_cs_matrix): """ Compressed sparse column matrix This can be instantiated in several ways: @@ -690,7 +743,7 @@ s = s*1.0 if (rank(s) == 2): self.shape = s.shape - self.indptr, self.rowind, self.data = densetocsr(s.shape[1], \ + self.indptr, self.index, self.data = densetocsr(s.shape[1], \ s.shape[0], \ s.T) else: @@ -703,23 +756,23 @@ self.shape = s.shape if copy: self.data = s.data.copy() - self.rowind = s.rowind.copy() + self.index = s.index.copy() self.indptr = s.indptr.copy() else: self.data = s.data - self.rowind = s.rowind + self.index = s.index self.indptr = s.indptr elif isinstance(s, csr_matrix): self.shape = s.shape - self.indptr, self.rowind, self.data = csrtocsc(s.shape[0], + self.indptr, self.index, self.data = csrtocsc(s.shape[0], s.shape[1], s.indptr, - s.colind, + s.index, s.data) else: temp = s.tocsc() self.data = temp.data - self.rowind = temp.rowind + self.index = temp.index self.indptr = temp.indptr self.shape = temp.shape elif type(arg1) == tuple: @@ -728,7 +781,7 @@ # It's a tuple of matrix dimensions (M, N) M, N = arg1 self.data = zeros((nzmax,), self.dtype) - self.rowind = zeros((nzmax,), intc) + self.index = zeros((nzmax,), intc) self.indptr = zeros((N+1,), intc) self.shape = (M, N) else: @@ -744,11 +797,11 @@ self.dtype = getdtype(dtype, s) if copy: self.data = array(s) - self.rowind = array(rowind) + self.index = array(rowind) self.indptr = array(indptr, dtype=intc) else: self.data = asarray(s) - self.rowind = asarray(rowind) + self.index = asarray(rowind) self.indptr = asarray(indptr, dtype=intc) except: raise ValueError, "unrecognized form for csc_matrix constructor" @@ -760,7 +813,7 @@ dtype=self.dtype).tocsc() self.shape = temp.shape self.data = temp.data - self.rowind = temp.rowind + self.index = temp.index self.indptr = temp.indptr else: raise ValueError, "unrecognized form for csc_matrix constructor" @@ -778,8 +831,8 @@ raise TypeError, "dimensions not understood" else: M = N = None - if len(self.rowind) > 0: - M = max(oldM, M, int(amax(self.rowind)) + 1) + if len(self.index) > 0: + M = max(oldM, M, int(amax(self.index)) + 1) else: # Matrix is completely empty M = max(oldM, M) @@ -793,8 +846,8 @@ M, N = self.shape nnz = self.indptr[-1] - nzmax = len(self.rowind) - if (rank(self.data) != 1) or (rank(self.rowind) != 1) or \ + nzmax = len(self.index) + if (rank(self.data) != 1) or (rank(self.index) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, rowind, and indptr arrays "\ "should be rank 1" @@ -804,14 +857,14 @@ raise ValueError, "index pointer should be of of size N+1" if (nzmax < nnz): raise ValueError, "nzmax must not be less than nnz" - if (nnz>0) and (amax(self.rowind[:nnz]) >= M): + if (nnz>0) and (amax(self.index[:nnz]) >= M): raise ValueError, "row values must be < M" - if (self.indptr[-1] > len(self.rowind)): + if (self.indptr[-1] > len(self.index)): raise ValueError, \ "Last value of index list should be less than "\ "the size of data list" - if (self.rowind.dtype != numpy.intc): - self.rowind = self.rowind.astype(numpy.intc) + if (self.index.dtype != numpy.intc): + self.index = self.index.astype(numpy.intc) if (self.indptr.dtype != numpy.intc): self.indptr = self.indptr.astype(numpy.intc) @@ -824,6 +877,15 @@ self.ftype = _transtabl[self.dtype.char] + + def __getattr__(self, attr): + if attr == 'rowind': + warnings.warn("rowind attribute no longer in use. Use .indices instead", + DeprecationWarning) + return self.index + else: + return _cs_matrix.__getattr__(self, attr) + def __radd__(self, other): """ Function supporting the operation: self + other. @@ -836,9 +898,9 @@ if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, \ + self.indptr, self.index, \ self.data, ocs.indptr, \ - ocs.rowind, ocs.data) + ocs.index, ocs.data) return csc_matrix((data, rowind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. @@ -847,37 +909,17 @@ raise TypeError, "unsupported type for sparse matrix addition" def __add__(self, other): - return _cs_matrix.__add__(self, other, self.rowind, True, cscplcsc, csc_matrix) + return _cs_matrix.__add__(self, other, cscplcsc) def __pow__(self, other): - return _cs_matrix.__pow__(self, other, self.rowind, True, cscelmulcsc, csc_matrix) + return _cs_matrix.__pow__(self, other, cscelmulcsc) def transpose(self, copy=False): - M, N = self.shape + return _cs_matrix._transpose(self, csr_matrix, copy) - if copy: - data = self.data.copy() - colind = self.rowind.copy() - indptr = self.indptr.copy() - else: - data = self.data - colind = self.rowind - indptr = self.indptr - return csr_matrix((data,colind,indptr),(N,M)) - def conj(self, copy=False): - new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) - if copy: - new.data = self.data.conj().copy() - new.rowind = self.rowind.conj().copy() - new.indptr = self.indptr.conj().copy() - else: - new.data = self.data.conj() - new.rowind = self.rowind.conj() - new.indptr = self.indptr.conj() - new._check() - return new + return _cs_matrix.conj(self, copy) def sum(self, axis=None): # Override the base class sum method for efficiency in the cases @@ -889,30 +931,30 @@ # The first element in column j has index indptr[j], the last # indptr[j+1] indptr = self.indptr - for j in xrange(n): - out[j] = data[indptr[j] : indptr[j+1]].sum() + for i in xrange(n): + out[i] = data[indptr[i] : indptr[i+1]].sum() if axis == 0: # Output is a (1 x n) dense matrix return asmatrix(out) else: return out.sum() else: - rowind = self.rowind + index = self.index out = zeros(m, dtype=self.dtype) # Loop over non-zeros for k in xrange(self.nnz): - out[rowind[k]] += data[k] + out[index[k]] += data[k] # Output is a (m x 1) dense matrix return asmatrix(out).T def matvec(self, other): - return _cs_matrix._matvec(self, other, self.rowind, cscmux) + return _cs_matrix._matvec(self, other, cscmux) def rmatvec(self, other, conjugate=True): return _cs_matrix._rmatvec(self, other, shape[1], shape[0], cscmux, conjugate=conjugate) def matmat(self, other): - return _cs_matrix._matmat(self, other, self.rowind, True, cscmucsc, csc_matrix) + return _cs_matrix._matmat(self, other, cscmucsc) def __getitem__(self, key): @@ -932,7 +974,7 @@ if not (0<=row= 1" - - indices = [] - - for ind in xrange(self.indptr[j], self.indptr[j+1]): - if self.rowind[ind] >= start and self.rowind[ind] < stop: - indices.append(ind) - - rowind = self.rowind[indices] - start - data = self.data[indices] - indptr = numpy.array([0, len(indices)]) - return csc_matrix((data, rowind, indptr), dims=(stop-start, 1), \ - dtype=self.dtype) + return _cs_matrix._get_slice(self, j, start, stop, stride, (stop - start, 1)) def rowcol(self, ind): - row = self.rowind[ind] + row = self.index[ind] col = searchsorted(self.indptr, ind+1)-1 return (row, col) @@ -1023,12 +1050,18 @@ return self.toself(copy) def tocoo(self): - return _cs_matrix._tocoo(self, csctocoo, self.rowind) + return _cs_matrix._tocoo(self, csctocoo) def tocsr(self): indptr, colind, data = csctocsr(self.shape[0], self.shape[1], \ - self.indptr, self.rowind, self.data) + self.indptr, self.index, self.data) return csr_matrix((data, colind, indptr), self.shape) + + def _toother(self): + return self.tocsr() + + def _tothis(self, other): + return other.tocsc() def toarray(self): return self.tocsr().toarray() @@ -1043,30 +1076,16 @@ return self.nnz = nnz self.data = self.data[:nnz] - self.rowind = self.rowind[:nnz] + self.index = self.index[:nnz] self.nzmax = nnz self._check() def ensure_sorted_indices(self, inplace=False): """Return a copy of this matrix where the row indices are sorted """ - if inplace: - sparsetools.ensure_sorted_indices(self.shape[1], self.shape[0], - self.indptr, self.rowind, - self.data ) - else: - return self.tocsr().tocsc() + return _cs_matrix._ensure_sorted_indices(self, self.shape[1], self.shape[0], inplace) - def copy(self): - new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) - new.data = self.data.copy() - new.rowind = self.rowind.copy() - new.indptr = self.indptr.copy() - new._check() - return new - - class csr_matrix(_cs_matrix): """ Compressed sparse row matrix This can be instantiated in several ways: @@ -1099,7 +1118,7 @@ if rank(arg1) == 2: s = arg1 ocsc = csc_matrix(transpose(s)) - self.colind = ocsc.rowind + self.index = ocsc.index self.indptr = ocsc.indptr self.data = ocsc.data self.shape = (ocsc.shape[1], ocsc.shape[0]) @@ -1113,11 +1132,11 @@ self.shape = s.shape if copy: self.data = s.data.copy() - self.colind = s.colind.copy() + self.index = s.index.copy() self.indptr = s.indptr.copy() else: self.data = s.data - self.colind = s.colind + self.index = s.index self.indptr = s.indptr else: try: @@ -1125,7 +1144,7 @@ except AttributeError: temp = csr_matrix(s.tocsc()) self.data = temp.data - self.colind = temp.colind + self.index = temp.index self.indptr = temp.indptr self.shape = temp.shape elif type(arg1) == tuple: @@ -1134,7 +1153,7 @@ M, N = arg1 self.dtype = getdtype(dtype, default=float) self.data = zeros((nzmax,), self.dtype) - self.colind = zeros((nzmax,), intc) + self.index = zeros((nzmax,), intc) self.indptr = zeros((M+1,), intc) self.shape = (M, N) else: @@ -1153,11 +1172,11 @@ self.dtype = getdtype(dtype, s) if copy: self.data = array(s, dtype=self.dtype) - self.colind = array(colind) + self.index = array(colind) self.indptr = array(indptr, dtype=intc) else: self.data = asarray(s, dtype=self.dtype) - self.colind = asarray(colind) + self.index = asarray(colind) self.indptr = asarray(indptr, dtype=intc) else: # (data, ij) format @@ -1167,7 +1186,7 @@ dtype=self.dtype).tocsr() self.shape = temp.shape self.data = temp.data - self.colind = temp.colind + self.index = temp.index self.indptr = temp.indptr else: raise ValueError, "unrecognized form for csr_matrix constructor" @@ -1186,8 +1205,8 @@ else: M = N = None M = max(0, oldM, M, len(self.indptr) - 1) - if len(self.colind) > 0: - N = max(oldN, N, int(amax(self.colind)) + 1) + if len(self.index) > 0: + N = max(oldN, N, int(amax(self.index)) + 1) else: # Matrix is completely empty N = max(oldN, N) @@ -1200,8 +1219,8 @@ M, N = self.shape nnz = self.indptr[-1] - nzmax = len(self.colind) - if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ + nzmax = len(self.index) + if (rank(self.data) != 1) or (rank(self.index) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, colind, and indptr arrays "\ "should be rank 1" @@ -1209,14 +1228,14 @@ raise ValueError, "data and row list should have same length" if (len(self.indptr) != M+1): raise ValueError, "index pointer should be of length #rows + 1" - if (nnz>0) and (amax(self.colind[:nnz]) >= N): + if (nnz>0) and (amax(self.index[:nnz]) >= N): raise ValueError, "column-values must be < N" if (nnz > nzmax): raise ValueError, \ "last value of index list should be less than "\ "the size of data list" - if (self.colind.dtype != numpy.intc): - self.colind = self.colind.astype(numpy.intc) + if (self.index.dtype != numpy.intc): + self.index = self.index.astype(numpy.intc) if (self.indptr.dtype != numpy.intc): self.indptr = self.indptr.astype(numpy.intc) @@ -1229,28 +1248,26 @@ self.ftype = _transtabl[self.dtype.char] + def __getattr__(self, attr): + if attr == 'colind': + warnings.warn("colind attribute no longer in use. Use .indices instead", + DeprecationWarning) + return self.index + else: + return _cs_matrix.__getattr__(self, attr) def __add__(self, other): - return _cs_matrix.__add__(self, other, self.colind, False, csrplcsr, csr_matrix) + return _cs_matrix.__add__(self, other, csrplcsr) - def __pow__(self, other): - return _cs_matrix.__pow__(self, other, self.colind, False, csrelmulcsr, csr_matrix) + return _cs_matrix.__pow__(self, other, csrelmulcsr) def transpose(self, copy=False): - M, N = self.shape + return _cs_matrix._transpose(self, csc_matrix, copy) - if copy: - data = self.data.copy() - rowind = self.colind.copy() - indptr = self.indptr.copy() - else: - data = self.data - rowind = self.colind - indptr = self.indptr + def conj(self, copy=False): + return _cs_matrix.conj(self, copy) - return csc_matrix((data,rowind,indptr),(N,M)) - def sum(self, axis=None): # Override the base class sum method for efficiency in the cases # axis=1 and axis=None. @@ -1269,22 +1286,22 @@ else: return out.sum() else: - colind = self.colind + index = self.index out = zeros(n, dtype=self.dtype) # Loop over non-zeros for k in xrange(self.nnz): - out[colind[k]] += data[k] + out[index[k]] += data[k] # Output is a (1 x n) dense matrix return asmatrix(out) def matvec(self, other): - return _cs_matrix._matvec(self, other, self.colind, csrmux) + return _cs_matrix._matvec(self, other, csrmux) def rmatvec(self, other, conjugate=True): return _cs_matrix._rmatvec(self, other, shape[0], shape[1], csrmux, conjugate=conjugate) def matmat(self, other): - return _cs_matrix._matmat(self, other, self.colind, False, csrmucsr, csr_matrix) + return _cs_matrix._matmat(self, other, csrmucsr) def __getitem__(self, key): @@ -1304,7 +1321,7 @@ if not (0<=row= 1" - - indices = [] - - for ind in xrange(self.indptr[i], self.indptr[i+1]): - if self.colind[ind] >= start and self.colind[ind] < stop: - indices.append(ind) - - colind = self.colind[indices] - start - data = self.data[indices] - indptr = numpy.array([0, len(indices)]) - return csr_matrix((data, colind, indptr), dims=(1, stop-start), \ - dtype=self.dtype) + return _cs_matrix._get_slice(self, i, start, stop, stride, (1, stop-start)) def __setitem__(self, key, val): if isinstance(key, tuple): @@ -1355,21 +1357,21 @@ N = col+1 self.shape = (M, N) - indxs = numpy.where(col == self.colind[self.indptr[row]:self.indptr[row+1]]) + indxs = numpy.where(col == self.index[self.indptr[row]:self.indptr[row+1]]) if len(indxs[0]) == 0: #value not present nzmax = self.nzmax if (nzmax < self.nnz+1): # need more room alloc = max(1, self.allocsize) self.data = resize1d(self.data, nzmax + alloc) - self.colind = resize1d(self.colind, nzmax + alloc) + self.index = resize1d(self.index, nzmax + alloc) newindex = self.indptr[row] self.data[newindex+1:] = self.data[newindex:-1] - self.colind[newindex+1:] = self.colind[newindex:-1] + self.index[newindex+1:] = self.index[newindex:-1] self.data[newindex] = val - self.colind[newindex] = col + self.index[newindex] = col self.indptr[row+1:] += 1 elif len(indxs[0]) == 1: @@ -1384,7 +1386,7 @@ raise IndexError, "invalid index" def rowcol(self, ind): - col = self.colind[ind] + col = self.index[ind] row = searchsorted(self.indptr, ind+1)-1 return (row, col) @@ -1392,17 +1394,22 @@ return self.toself(copy) def tocoo(self): - return _cs_matrix._tocoo(self, csrtocoo, self.colind) + return _cs_matrix._tocoo(self, csrtocoo) def tocsc(self): indptr, rowind, data = csrtocsc(self.shape[0], self.shape[1], \ - self.indptr, self.colind, self.data) + self.indptr, self.index, self.data) return csc_matrix((data, rowind, indptr), self.shape) + def _toother(self): + return self.tocsc() + + def _tothis(self, other): + return other.tocsr() def toarray(self): data = numpy.zeros(self.shape, self.data.dtype) - csrtodense(self.shape[0], self.shape[1], self.indptr, self.colind, + csrtodense(self.shape[0], self.shape[1], self.indptr, self.index, self.data, data) return data @@ -1416,29 +1423,16 @@ raise RuntimeError, "should never have nnz > nzmax" return self.data = self.data[:nnz] - self.colind = self.colind[:nnz] + self.index = self.index[:nnz] self.nzmax = nnz self._check() def ensure_sorted_indices(self, inplace=False): """Return a copy of this matrix where the column indices are sorted """ - if inplace: - sparsetools.ensure_sorted_indices(self.shape[0], self.shape[1], - self.indptr, self.colind, - self.data ) - else: - return self.tocsc().tocsr() + return _cs_matrix._ensure_sorted_indices(self, self.shape[0], self.shape[1], inplace) - def copy(self): - new = csr_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) - new.data = self.data.copy() - new.colind = self.colind.copy() - new.indptr = self.indptr.copy() - new._check() - return new - # This function was for sorting dictionary keys by the second tuple element. # (We now use the Schwartzian transform instead for efficiency.) # def csc_cmp(x, y): @@ -2441,7 +2435,7 @@ if x.shape != (1, self.shape[1]): raise ValueError, "sparse matrix source must be (1 x n)" - self.rows[i] = x.colind.tolist() + self.rows[i] = x.index.tolist() self.data[i] = x.data.tolist() # This should be generalized to other shapes than an entire # row. Modified: trunk/Lib/sparse/tests/test_sparse.py =================================================================== --- trunk/Lib/sparse/tests/test_sparse.py 2007-01-11 18:44:52 UTC (rev 2538) +++ trunk/Lib/sparse/tests/test_sparse.py 2007-01-12 01:16:24 UTC (rev 2539) @@ -470,7 +470,7 @@ [0,2,0]],'d') bsp = csr_matrix(b) assert_array_almost_equal(bsp.data,[4,3,1,2]) - assert_array_equal(bsp.colind,[1,0,2,1]) + assert_array_equal(bsp.index,[1,0,2,1]) assert_array_equal(bsp.indptr,[0,1,3,4]) assert_equal(bsp.getnnz(),4) assert_equal(bsp.getformat(),'csr') @@ -481,7 +481,7 @@ b[3,4] = 5 bsp = csr_matrix(b) assert_array_almost_equal(bsp.data,[5]) - assert_array_equal(bsp.colind,[4]) + assert_array_equal(bsp.index,[4]) assert_array_equal(bsp.indptr,[0,0,0,0,1,1,1]) assert_array_almost_equal(bsp.todense(),b) @@ -491,7 +491,7 @@ [3,0]],'d') bsp = csr_matrix(b) assert_array_almost_equal(bsp.data,[1,2,3]) - assert_array_equal(bsp.colind,[0,1,0]) + assert_array_equal(bsp.index,[0,1,0]) assert_array_equal(bsp.indptr,[0,1,2,3]) assert_array_almost_equal(bsp.todense(),b) @@ -523,7 +523,7 @@ print 'in\n', asp asp.ensure_sorted_indices( inplace = True ) print 'out\n', asp - assert_array_equal(asp.colind,[1, 2, 7, 4, 5]) + assert_array_equal(asp.index,[1, 2, 7, 4, 5]) for ir in range( asp.shape[0] ): for ic in range( asp.shape[1] ): assert_equal( asp[ir, ic], bsp[ir, ic] ) @@ -535,7 +535,7 @@ b = matrix([[1,0,0],[3,0,1],[0,2,0]],'d') bsp = csc_matrix(b) assert_array_almost_equal(bsp.data,[1,3,2,1]) - assert_array_equal(bsp.rowind,[0,1,2,1]) + assert_array_equal(bsp.index,[0,1,2,1]) assert_array_equal(bsp.indptr,[0,2,3,4]) assert_equal(bsp.getnnz(),4) assert_equal(bsp.getformat(),'csc') @@ -545,14 +545,14 @@ b[2,4] = 5 bsp = csc_matrix(b) assert_array_almost_equal(bsp.data,[5]) - assert_array_equal(bsp.rowind,[2]) + assert_array_equal(bsp.index,[2]) assert_array_equal(bsp.indptr,[0,0,0,0,0,1,1]) def check_constructor3(self): b = matrix([[1,0],[0,2],[3,0]],'d') bsp = csc_matrix(b) assert_array_almost_equal(bsp.data,[1,3,2]) - assert_array_equal(bsp.rowind,[0,2,1]) + assert_array_equal(bsp.index,[0,2,1]) assert_array_equal(bsp.indptr,[0,2,3]) def check_empty(self): @@ -582,7 +582,7 @@ print 'in\n', asp asp.ensure_sorted_indices( inplace = True ) print 'out\n', asp - assert_array_equal(asp.rowind,[1, 2, 7, 4, 5]) + assert_array_equal(asp.index,[1, 2, 7, 4, 5]) for ir in range( asp.shape[0] ): for ic in range( asp.shape[1] ): assert_equal( asp[ir, ic], bsp[ir, ic] ) From scipy-svn at scipy.org Thu Jan 11 20:25:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 11 Jan 2007 19:25:05 -0600 (CST) Subject: [Scipy-svn] r2540 - in trunk/Lib: linsolve linsolve/umfpack sparse sparse/tests Message-ID: <20070112012505.D55B239C00A@new.scipy.org> Author: timl Date: 2007-01-11 19:24:56 -0600 (Thu, 11 Jan 2007) New Revision: 2540 Modified: trunk/Lib/linsolve/linsolve.py trunk/Lib/linsolve/umfpack/umfpack.py trunk/Lib/sparse/sparse.py trunk/Lib/sparse/tests/test_sparse.py Log: rename .index to .indices in cs matrices Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-01-12 01:16:24 UTC (rev 2539) +++ trunk/Lib/linsolve/linsolve.py 2007-01-12 01:24:56 UTC (rev 2540) @@ -87,7 +87,7 @@ else: mat, csc = _toCS_superLU( A ) - index0 = mat.index + index0 = mat.indices ftype, lastel, data, index1 = mat.ftype, mat.nnz, mat.data, mat.indptr gssv = eval('_superlu.' + ftype + 'gssv') b = asarray(b, dtype=data.dtype) @@ -112,7 +112,7 @@ csc = A.tocsc() gstrf = eval('_superlu.' + csc.ftype + 'gstrf') - return gstrf(N, csc.nnz, csc.data, csc.index, csc.indptr, permc_spec, + return gstrf(N, csc.nnz, csc.data, csc.indices, csc.indptr, permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) def _testme(): Modified: trunk/Lib/linsolve/umfpack/umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-12 01:16:24 UTC (rev 2539) +++ trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-12 01:24:56 UTC (rev 2540) @@ -317,10 +317,10 @@ def _getIndx( self, mtx ): if sp.isspmatrix_csc( mtx ): - indx = mtx.index + indx = mtx.indices self.isCSR = 0 elif sp.isspmatrix_csr( mtx ): - indx = mtx.index + indx = mtx.indices self.isCSR = 1 else: raise TypeError, 'must be a CSC/CSR matrix (is %s)' % mtx.__class__ Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-12 01:16:24 UTC (rev 2539) +++ trunk/Lib/sparse/sparse.py 2007-01-12 01:24:56 UTC (rev 2540) @@ -498,9 +498,9 @@ raise ValueError, "inconsistent shapes" other = self._tothis(other) indptr, ind, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self.index, \ + self.indptr, self.indices, \ self.data, other.indptr, \ - other.index, other.data) + other.indices, other.data) return self.__class__((data, ind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them @@ -558,9 +558,9 @@ if (other.shape != self.shape): raise ValueError, "inconsistent shapes" indptr, ind, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self.index, \ + self.indptr, self.indices, \ self.data, other.indptr, \ - other.index, other.data) + other.indices, other.data) return self.__class__((data, ind, indptr), (self.shape[0], other.shape[1])) else: raise TypeError, "unsupported type for sparse matrix power" @@ -573,9 +573,9 @@ if (K1 != K2): raise ValueError, "shape mismatch error" other = self._tothis(other) - indptr, ind, data = fn(M, N, self.indptr, self.index, \ + indptr, ind, data = fn(M, N, self.indptr, self.indices, \ self.data, other.indptr, \ - other.index, other.data) + other.indices, other.data) return self.__class__((data, ind, indptr), (M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation @@ -592,7 +592,7 @@ # raise ValueError, "dimension mismatch" oth = numpy.ravel(other) y = fn(self.shape[0], self.shape[1], \ - self.indptr, self.index, self.data, oth) + self.indptr, self.indices, self.data, oth) if isinstance(other, matrix): y = asmatrix(y) # If 'other' was an (nx1) column vector, transpose the result @@ -616,7 +616,7 @@ else: cd = self.data oth = numpy.ravel(other) - y = fn(shape0, shape1, self.indptr, self.index, cd, oth) + y = fn(shape0, shape1, self.indptr, self.indices, cd, oth) if isinstance(other, matrix): y = asmatrix(y) # In the (unlikely) event that this matrix is 1x1 and 'other' @@ -634,14 +634,14 @@ def _tocoo(self, fn): rows, cols, data = fn(self.shape[0], self.shape[1], \ - self.indptr, self.index, self.data) + self.indptr, self.indices, self.data) return coo_matrix((data, (rows, cols)), self.shape) def copy(self): new = self.__class__(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() - new.index = self.index.copy() + new.indices = self.indices.copy() new.indptr = self.indptr.copy() new._check() return new @@ -658,10 +658,10 @@ indices = [] for ind in xrange(self.indptr[i], self.indptr[i+1]): - if self.index[ind] >= start and self.index[ind] < stop: + if self.indices[ind] >= start and self.indices[ind] < stop: indices.append(ind) - index = self.index[indices] - start + index = self.indices[indices] - start data = self.data[indices] indptr = numpy.array([0, len(indices)]) return self.__class__((data, index, indptr), dims=dims, \ @@ -672,11 +672,11 @@ M, N = self.shape if copy: data = self.data.copy() - index = self.index.copy() + index = self.indices.copy() indptr = self.indptr.copy() else: data = self.data - index = self.index + index = self.indices indptr = self.indptr return cls((data,index,indptr),(N,M)) @@ -685,11 +685,11 @@ new = self.__class__(self.shape, nzmax=self.nzmax, dtype=self.dtype) if copy: new.data = self.data.conj().copy() - new.index = self.index.conj().copy() + new.indices = self.indices.conj().copy() new.indptr = self.indptr.conj().copy() else: new.data = self.data.conj() - new.index = self.index.conj() + new.indices = self.indices.conj() new.indptr = self.indptr.conj() new._check() return new @@ -699,7 +699,7 @@ """ if inplace: sparsetools.ensure_sorted_indices(shape0, shape1, - self.indptr, self.index, + self.indptr, self.indices, self.data ) else: return self._toother()._toother() @@ -743,7 +743,7 @@ s = s*1.0 if (rank(s) == 2): self.shape = s.shape - self.indptr, self.index, self.data = densetocsr(s.shape[1], \ + self.indptr, self.indices, self.data = densetocsr(s.shape[1], \ s.shape[0], \ s.T) else: @@ -756,23 +756,23 @@ self.shape = s.shape if copy: self.data = s.data.copy() - self.index = s.index.copy() + self.indices = s.indices.copy() self.indptr = s.indptr.copy() else: self.data = s.data - self.index = s.index + self.indices = s.indices self.indptr = s.indptr elif isinstance(s, csr_matrix): self.shape = s.shape - self.indptr, self.index, self.data = csrtocsc(s.shape[0], + self.indptr, self.indices, self.data = csrtocsc(s.shape[0], s.shape[1], s.indptr, - s.index, + s.indices, s.data) else: temp = s.tocsc() self.data = temp.data - self.index = temp.index + self.indices = temp.indices self.indptr = temp.indptr self.shape = temp.shape elif type(arg1) == tuple: @@ -781,7 +781,7 @@ # It's a tuple of matrix dimensions (M, N) M, N = arg1 self.data = zeros((nzmax,), self.dtype) - self.index = zeros((nzmax,), intc) + self.indices = zeros((nzmax,), intc) self.indptr = zeros((N+1,), intc) self.shape = (M, N) else: @@ -797,11 +797,11 @@ self.dtype = getdtype(dtype, s) if copy: self.data = array(s) - self.index = array(rowind) + self.indices = array(rowind) self.indptr = array(indptr, dtype=intc) else: self.data = asarray(s) - self.index = asarray(rowind) + self.indices = asarray(rowind) self.indptr = asarray(indptr, dtype=intc) except: raise ValueError, "unrecognized form for csc_matrix constructor" @@ -813,7 +813,7 @@ dtype=self.dtype).tocsc() self.shape = temp.shape self.data = temp.data - self.index = temp.index + self.indices = temp.indices self.indptr = temp.indptr else: raise ValueError, "unrecognized form for csc_matrix constructor" @@ -831,8 +831,8 @@ raise TypeError, "dimensions not understood" else: M = N = None - if len(self.index) > 0: - M = max(oldM, M, int(amax(self.index)) + 1) + if len(self.indices) > 0: + M = max(oldM, M, int(amax(self.indices)) + 1) else: # Matrix is completely empty M = max(oldM, M) @@ -846,8 +846,8 @@ M, N = self.shape nnz = self.indptr[-1] - nzmax = len(self.index) - if (rank(self.data) != 1) or (rank(self.index) != 1) or \ + nzmax = len(self.indices) + if (rank(self.data) != 1) or (rank(self.indices) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, rowind, and indptr arrays "\ "should be rank 1" @@ -857,14 +857,14 @@ raise ValueError, "index pointer should be of of size N+1" if (nzmax < nnz): raise ValueError, "nzmax must not be less than nnz" - if (nnz>0) and (amax(self.index[:nnz]) >= M): + if (nnz>0) and (amax(self.indices[:nnz]) >= M): raise ValueError, "row values must be < M" - if (self.indptr[-1] > len(self.index)): + if (self.indptr[-1] > len(self.indices)): raise ValueError, \ "Last value of index list should be less than "\ "the size of data list" - if (self.index.dtype != numpy.intc): - self.index = self.index.astype(numpy.intc) + if (self.indices.dtype != numpy.intc): + self.indices = self.indices.astype(numpy.intc) if (self.indptr.dtype != numpy.intc): self.indptr = self.indptr.astype(numpy.intc) @@ -882,7 +882,7 @@ if attr == 'rowind': warnings.warn("rowind attribute no longer in use. Use .indices instead", DeprecationWarning) - return self.index + return self.indices else: return _cs_matrix.__getattr__(self, attr) @@ -898,9 +898,9 @@ if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" indptr, rowind, data = cscplcsc(self.shape[0], self.shape[1], \ - self.indptr, self.index, \ + self.indptr, self.indices, \ self.data, ocs.indptr, \ - ocs.index, ocs.data) + ocs.indices, ocs.data) return csc_matrix((data, rowind, indptr), self.shape) elif isdense(other): # Convert this matrix to a dense matrix and add them. @@ -939,7 +939,7 @@ else: return out.sum() else: - index = self.index + index = self.indices out = zeros(m, dtype=self.dtype) # Loop over non-zeros for k in xrange(self.nnz): @@ -965,7 +965,7 @@ raise IndexError, "csc_matrix supports slices only of a single"\ " column" elif isinstance(row, slice): - return self._getcolslice(row, col) + return self._getslice(row, col) M, N = self.shape if (row < 0): row = M + row @@ -974,7 +974,7 @@ if not (0<=row 0: - N = max(oldN, N, int(amax(self.index)) + 1) + if len(self.indices) > 0: + N = max(oldN, N, int(amax(self.indices)) + 1) else: # Matrix is completely empty N = max(oldN, N) @@ -1219,8 +1222,8 @@ M, N = self.shape nnz = self.indptr[-1] - nzmax = len(self.index) - if (rank(self.data) != 1) or (rank(self.index) != 1) or \ + nzmax = len(self.indices) + if (rank(self.data) != 1) or (rank(self.indices) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "data, colind, and indptr arrays "\ "should be rank 1" @@ -1228,14 +1231,14 @@ raise ValueError, "data and row list should have same length" if (len(self.indptr) != M+1): raise ValueError, "index pointer should be of length #rows + 1" - if (nnz>0) and (amax(self.index[:nnz]) >= N): + if (nnz>0) and (amax(self.indices[:nnz]) >= N): raise ValueError, "column-values must be < N" if (nnz > nzmax): raise ValueError, \ "last value of index list should be less than "\ "the size of data list" - if (self.index.dtype != numpy.intc): - self.index = self.index.astype(numpy.intc) + if (self.indices.dtype != numpy.intc): + self.indices = self.indices.astype(numpy.intc) if (self.indptr.dtype != numpy.intc): self.indptr = self.indptr.astype(numpy.intc) @@ -1252,7 +1255,7 @@ if attr == 'colind': warnings.warn("colind attribute no longer in use. Use .indices instead", DeprecationWarning) - return self.index + return self.indices else: return _cs_matrix.__getattr__(self, attr) @@ -1286,7 +1289,7 @@ else: return out.sum() else: - index = self.index + index = self.indices out = zeros(n, dtype=self.dtype) # Loop over non-zeros for k in xrange(self.nnz): @@ -1312,7 +1315,7 @@ raise IndexError, "csr_matrix supports slices only of a single"\ " row" elif isinstance(col, slice): - return self._getrowslice(row, col) + return self._getslice(row, col) M, N = self.shape if (row < 0): row = M + row @@ -1320,8 +1323,8 @@ col = N + col if not (0<=row nzmax" return self.data = self.data[:nnz] - self.index = self.index[:nnz] + self.indices = self.indices[:nnz] self.nzmax = nnz self._check() @@ -2435,7 +2440,7 @@ if x.shape != (1, self.shape[1]): raise ValueError, "sparse matrix source must be (1 x n)" - self.rows[i] = x.index.tolist() + self.rows[i] = x.indices.tolist() self.data[i] = x.data.tolist() # This should be generalized to other shapes than an entire # row. Modified: trunk/Lib/sparse/tests/test_sparse.py =================================================================== --- trunk/Lib/sparse/tests/test_sparse.py 2007-01-12 01:16:24 UTC (rev 2539) +++ trunk/Lib/sparse/tests/test_sparse.py 2007-01-12 01:24:56 UTC (rev 2540) @@ -470,7 +470,7 @@ [0,2,0]],'d') bsp = csr_matrix(b) assert_array_almost_equal(bsp.data,[4,3,1,2]) - assert_array_equal(bsp.index,[1,0,2,1]) + assert_array_equal(bsp.indices,[1,0,2,1]) assert_array_equal(bsp.indptr,[0,1,3,4]) assert_equal(bsp.getnnz(),4) assert_equal(bsp.getformat(),'csr') @@ -481,7 +481,7 @@ b[3,4] = 5 bsp = csr_matrix(b) assert_array_almost_equal(bsp.data,[5]) - assert_array_equal(bsp.index,[4]) + assert_array_equal(bsp.indices,[4]) assert_array_equal(bsp.indptr,[0,0,0,0,1,1,1]) assert_array_almost_equal(bsp.todense(),b) @@ -491,7 +491,7 @@ [3,0]],'d') bsp = csr_matrix(b) assert_array_almost_equal(bsp.data,[1,2,3]) - assert_array_equal(bsp.index,[0,1,0]) + assert_array_equal(bsp.indices,[0,1,0]) assert_array_equal(bsp.indptr,[0,1,2,3]) assert_array_almost_equal(bsp.todense(),b) @@ -523,7 +523,7 @@ print 'in\n', asp asp.ensure_sorted_indices( inplace = True ) print 'out\n', asp - assert_array_equal(asp.index,[1, 2, 7, 4, 5]) + assert_array_equal(asp.indices,[1, 2, 7, 4, 5]) for ir in range( asp.shape[0] ): for ic in range( asp.shape[1] ): assert_equal( asp[ir, ic], bsp[ir, ic] ) @@ -535,7 +535,7 @@ b = matrix([[1,0,0],[3,0,1],[0,2,0]],'d') bsp = csc_matrix(b) assert_array_almost_equal(bsp.data,[1,3,2,1]) - assert_array_equal(bsp.index,[0,1,2,1]) + assert_array_equal(bsp.indices,[0,1,2,1]) assert_array_equal(bsp.indptr,[0,2,3,4]) assert_equal(bsp.getnnz(),4) assert_equal(bsp.getformat(),'csc') @@ -545,14 +545,14 @@ b[2,4] = 5 bsp = csc_matrix(b) assert_array_almost_equal(bsp.data,[5]) - assert_array_equal(bsp.index,[2]) + assert_array_equal(bsp.indices,[2]) assert_array_equal(bsp.indptr,[0,0,0,0,0,1,1]) def check_constructor3(self): b = matrix([[1,0],[0,2],[3,0]],'d') bsp = csc_matrix(b) assert_array_almost_equal(bsp.data,[1,3,2]) - assert_array_equal(bsp.index,[0,2,1]) + assert_array_equal(bsp.indices,[0,2,1]) assert_array_equal(bsp.indptr,[0,2,3]) def check_empty(self): @@ -582,7 +582,7 @@ print 'in\n', asp asp.ensure_sorted_indices( inplace = True ) print 'out\n', asp - assert_array_equal(asp.index,[1, 2, 7, 4, 5]) + assert_array_equal(asp.indices,[1, 2, 7, 4, 5]) for ir in range( asp.shape[0] ): for ic in range( asp.shape[1] ): assert_equal( asp[ir, ic], bsp[ir, ic] ) From scipy-svn at scipy.org Fri Jan 12 11:42:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 12 Jan 2007 10:42:36 -0600 (CST) Subject: [Scipy-svn] r2541 - in trunk/Lib/sparse: . tests Message-ID: <20070112164236.8F78239C1E2@new.scipy.org> Author: timl Date: 2007-01-12 10:42:30 -0600 (Fri, 12 Jan 2007) New Revision: 2541 Modified: trunk/Lib/sparse/sparse.py trunk/Lib/sparse/tests/test_sparse.py Log: update lil_matrix to support all kinds of fancy indexing (i think) Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-01-12 01:24:56 UTC (rev 2540) +++ trunk/Lib/sparse/sparse.py 2007-01-12 16:42:30 UTC (rev 2541) @@ -12,9 +12,9 @@ less, where, greater, array, transpose, empty, ones, \ arange, shape, intc import numpy -from scipy.sparse.sparsetools import densetocsr, csrtocsc, csrtodense, cscplcsc, \ - cscelmulcsc, cscmux, csrmux, csrmucsr, csrtocoo, cootocsc, cootocsr, \ - cscmucsc, csctocoo, csctocsr, csrplcsr, csrelmulcsr +from scipy.sparse.sparsetools import densetocsr, csrtocsc, csrtodense, \ + cscplcsc, cscelmulcsc, cscmux, csrmux, csrmucsr, csrtocoo, cootocsc, \ + cootocsr, cscmucsc, csctocoo, csctocsr, csrplcsr, csrelmulcsr import sparsetools import itertools, operator, copy from bisect import bisect_left @@ -561,7 +561,7 @@ self.indptr, self.indices, \ self.data, other.indptr, \ other.indices, other.data) - return self.__class__((data, ind, indptr), (self.shape[0], other.shape[1])) + return self.__class__((data, ind, indptr), self.shape) else: raise TypeError, "unsupported type for sparse matrix power" @@ -775,7 +775,7 @@ self.indices = temp.indices self.indptr = temp.indptr self.shape = temp.shape - elif type(arg1) == tuple: + elif isinstance(arg1, tuple): if isshape(arg1): self.dtype = getdtype(dtype, default=float) # It's a tuple of matrix dimensions (M, N) @@ -973,7 +973,7 @@ col = N + col if not (0<=row 0 - assert N == int(N) and N > 0 - self.shape = (int(M), int(N)) - return - except (TypeError, ValueError, AssertionError): + if not isshape(A): raise TypeError, "dimensions must be a 2-tuple of positive"\ " integers" + self.shape = A elif isspmatrix(A): # For sparse matrices, this is too inefficient; we need # something else. @@ -1555,10 +1549,9 @@ matrix with just these elements. """ try: - assert len(key) == 2 - except (AssertionError, TypeError): + i, j = key + except (ValueError, TypeError): raise TypeError, "index must be a pair of integers or slices" - i, j = key # Bounds checking if isintlike(i): @@ -2020,20 +2013,17 @@ """ Resize the matrix to dimensions given by 'shape', removing any non-zero elements that lie outside. """ - M, N = self.shape - try: - newM, newN = shape - assert newM == int(newM) and newM > 0 - assert newN == int(newN) and newN > 0 - except (TypeError, ValueError, AssertionError): + if not isshape(shape): raise TypeError, "dimensions must be a 2-tuple of positive"\ " integers" + newM, newN = shape + M, N = self.shape if newM < M or newN < N: # Remove all elements outside new dimensions for (i, j) in self.keys(): if i >= newM or j >= newN: del self[i, j] - self.shape = (newM, newN) + self.shape = shape @@ -2236,11 +2226,11 @@ self.shape = (M, N) # Pluck out all non-zeros from the dense array/matrix A - self.rows = [] - for i in xrange(M): - self.rows.append([]) - # The non-zero values of the matrix: - self.data = [[] for i in xrange(M)] + self.rows = numpy.empty((M,), dtype=object) + self.data = numpy.empty((M,), dtype=object) + for i in range(M): + self.rows[i] = [] + self.data[i] = [] if A is not None: for i in xrange(A.shape[0]): @@ -2281,6 +2271,37 @@ new.rows[0] = self.rows[i][:] new.data[0] = self.data[i][:] return new + + + + def _get1(self, i, j): + row = self.rows[i] + data = self.data[i] + if j > self.shape[1]: + raise IndexError + + pos = bisect_left(row, j) + if pos != len(data) and row[pos] == j: + return data[pos] + else: + return 0 + + def _slicetoseq(self, j, shape): + if j.start is not None and j.start < 0: + start = shape + j.start + elif j.start is None: + start = 0 + else: + start = j.start + if j.stop is not None and j.stop < 0: + stop = shape + j.stop + elif j.stop is None: + stop = shape + else: + stop = j.stop + j = range(start, stop, j.step or 1) + return j + def __getitem__(self, index): """Return the element(s) index=(i, j), where j may be a slice. @@ -2288,187 +2309,112 @@ Python lists return copies. """ try: - assert len(index) == 2 + i, j = index except (AssertionError, TypeError): raise IndexError, "invalid index" - i, j = index - if type(i) is slice: - raise IndexError, "lil_matrix supports slices only of a single row" - # TODO: add support for this, like in __setitem__ - elif isintlike(i): - i = int(i) # Python list indices must be machine-sized ints - if not (i>=0 and i= self.shape[1]: - raise IndexError, "invalid index" - if stop <= start: - raise ValueError, "slice width must be >= 1" - # Look up 'start' and 'stop' in column index - startind = bisect_left(row, start) - stopind = bisect_left(row, stop) - new = lil_matrix((1, stop - start), dtype=self.dtype) - new.data = [self.data[i][startind:stopind]] - new.rows = [[colind - start for colind in row[startind:stopind]]] - return new - elif operator.isSequenceType(j): - raise NotImplementedError, "sequence indexing not yet fully supported" - elif isintlike(j): - j = int(j) # Python list indices must be machine-sized ints - if not (j>=0 and j=0 and i=0 and j 0 and N > 0 except (ValueError, TypeError, AssertionError): return False else: @@ -2686,6 +2633,11 @@ diags = ones((1, n), dtype = dtype) return spdiags(diags, k, n, m) + +def issequence(t): + return isinstance(t, (list, tuple)) + + def _testme(): a = csc_matrix((arange(1, 9), \ transpose([[0, 1, 1, 2, 2, 3, 3, 4], [0, 1, 3, 0, 2, 3, 4, 4]]))) Modified: trunk/Lib/sparse/tests/test_sparse.py =================================================================== --- trunk/Lib/sparse/tests/test_sparse.py 2007-01-12 01:24:56 UTC (rev 2540) +++ trunk/Lib/sparse/tests/test_sparse.py 2007-01-12 16:42:30 UTC (rev 2541) @@ -32,7 +32,7 @@ self.dat = matrix([[1,0,0,2],[3,0,1,0],[0,2,0,0]],'d') self.datsp = self.spmatrix(self.dat) - def check_getelement(self): + def check_getelement(self): assert_equal(self.datsp[0,0],1) assert_equal(self.datsp[0,1],0) assert_equal(self.datsp[1,0],3) @@ -724,7 +724,7 @@ A = B / 10 B[0, :] = A[0, :] assert_array_equal(A[0, :].A, B[0, :].A) - assert_array_equal(A[0, :].A, array([[0, 0, 0, 1, 0, 0, 0, 0, 0, 0]])) + assert_array_equal(A[0, :].A, array([[0, 0, 0, 1, 0, 0, 0, 0, 0, 0.]])) def check_lil_from_csr(self): """ Tests whether a lil_matrix can be constructed from a From scipy-svn at scipy.org Fri Jan 12 15:26:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 12 Jan 2007 14:26:01 -0600 (CST) Subject: [Scipy-svn] r2542 - trunk/Lib/signal Message-ID: <20070112202601.7101439C1EE@new.scipy.org> Author: rkern Date: 2007-01-12 14:25:59 -0600 (Fri, 12 Jan 2007) New Revision: 2542 Modified: trunk/Lib/signal/filter_design.py Log: Be explicit about where sum comes from. Modified: trunk/Lib/signal/filter_design.py =================================================================== --- trunk/Lib/signal/filter_design.py 2007-01-12 16:42:30 UTC (rev 2541) +++ trunk/Lib/signal/filter_design.py 2007-01-12 20:25:59 UTC (rev 2542) @@ -1,5 +1,3 @@ -## Automatically adapted for scipy Oct 21, 2005 by convertcode.py - """Filter design. """ @@ -7,7 +5,7 @@ from numpy.core.umath import * from numpy import atleast_1d, poly, polyval, roots, imag, real, asarray,\ allclose, resize, pi, concatenate, absolute, logspace -from numpy import mintypecode, select, sum +from numpy import mintypecode, select from scipy import special, optimize, linalg from scipy.misc import comb import string, types @@ -1539,4 +1537,4 @@ alpha = N//2 m = numpy.arange(0,N) h = win*special.sinc(cutoff*(m-alpha)) - return h / sum(h,axis=0) + return h / numpy.sum(h,axis=0) From scipy-svn at scipy.org Fri Jan 12 16:19:25 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 12 Jan 2007 15:19:25 -0600 (CST) Subject: [Scipy-svn] r2543 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070112211925.BE72C39C055@new.scipy.org> Author: mattknox_ca Date: 2007-01-12 15:19:21 -0600 (Fri, 12 Jan 2007) New Revision: 2543 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: fixed some bugs Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-12 20:25:59 UTC (rev 2542) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-12 21:19:21 UTC (rev 2543) @@ -18,7 +18,7 @@ // helpers for frequency conversion routines // -static long DtoB_weekday(long fromDate) { return (((fromDate / 7) * 5) + fromDate%7); } +static long DtoB_weekday(long fromDate) { return (((fromDate) / 7) * 5) + (fromDate)%7; } static long DtoB_WeekendToMonday(mxDateTimeObject *dailyDate) { @@ -108,7 +108,7 @@ long result; mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); - result = (long)((mxDate->year) * 4 + (mxDate->month-1)/3 + 1); + result = (long)((mxDate->year - 1) * 4 + (mxDate->month-1)/3 + 1); Py_DECREF(mxDate); return result; } @@ -118,7 +118,7 @@ long result; mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(fromDate, 0); - result = (long)((mxDate->year) * 12 + mxDate->month); + result = (long)((mxDate->year - 1) * 12 + mxDate->month); Py_DECREF(mxDate); return result; } @@ -257,14 +257,14 @@ //************ FROM MONTHLY *************** -static long asfreq_MtoA(long fromDate, char relation) { return (fromDate - 1) / 12; } +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_MtoW(long fromDate, char relation) { return -1; } static void MtoD_ym(long fromDate, long *y, long *m) { - *y = (fromDate - 1) / 12; - *m = fromDate - 12 * (*y); + *y = (fromDate - 1) / 12 + 1; + *m = fromDate - 12 * (*y) - 1; } static long asfreq_MtoB(long fromDate, char relation) { @@ -299,7 +299,7 @@ //************ FROM QUARTERLY *************** -static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1) / 4; } +static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1)/ 4 + 1; } static long asfreq_QtoM(long fromDate, char relation) { if (relation == 'B') { return fromDate * 3 - 2; } @@ -309,8 +309,8 @@ static long asfreq_QtoW(long fromDate, char relation) { return -1; } static void QtoD_ym(long fromDate, long *y, long *m) { - *y = (fromDate - 1) / 4; - *m = fromDate * 3 - 12 * (*y) - 2; + *y = (fromDate - 1) / 4 + 1; + *m = (fromDate + 4) * 3 - 12 * (*y) - 2; } static long asfreq_QtoB(long fromDate, char relation) { @@ -347,13 +347,13 @@ //************ FROM ANNUAL *************** static long asfreq_AtoQ(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 4 + 1; } - else { return (fromDate + 1) * 4; } + if (relation == 'B') { return fromDate * 4 - 3; } + else { return fromDate * 4; } } static long asfreq_AtoM(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 12 + 1; } - else { return (fromDate + 1) * 12; } + if (relation == 'B') { return fromDate * 12 - 11; } + else { return fromDate * 12; } } static long asfreq_AtoW(long fromDate, char relation) { return -1; } From scipy-svn at scipy.org Fri Jan 12 20:13:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 12 Jan 2007 19:13:16 -0600 (CST) Subject: [Scipy-svn] r2544 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070113011316.3C3EE39C014@new.scipy.org> Author: pierregm Date: 2007-01-12 19:13:12 -0600 (Fri, 12 Jan 2007) New Revision: 2544 Added: trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py Removed: trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/mrecords.py Log: Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-12 21:19:21 UTC (rev 2543) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-13 01:13:12 UTC (rev 2544) @@ -1,3 +1,5 @@ +#2007-01-12 : Mrecords +# : - Complete reorganization... #2007-01-10 : Mrecords # : - Defines a class of records that support masked arrays #2007-01-08 : Core: Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-12 21:19:21 UTC (rev 2543) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-13 01:13:12 UTC (rev 2544) @@ -19,25 +19,80 @@ import numpy.core.numerictypes as ntypes from numpy.core.defchararray import chararray from numpy.core.records import find_duplicate -from numpy import bool_ from numpy.core.records import format_parser, record, recarray +from numpy.core.records import fromarrays as recfromarrays ndarray = numeric.ndarray _byteorderconv = N.core.records._byteorderconv _typestr = ntypes._typestr import maskedarray as MA -#reload(MA) -from maskedarray import masked, nomask, mask_or, filled, getmaskarray, masked_array +reload(MA) +from maskedarray import masked, nomask, mask_or, filled, getmask, getmaskarray, \ + masked_array, make_mask +from maskedarray import MaskedArray +from maskedarray.core import default_fill_value, masked_print_option import warnings -#import logging -#logging.basicConfig(level=logging.DEBUG, -# format='%(name)-15s %(levelname)s %(message)s',) +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) -class mrecarray(ndarray): + +def _getformats(data): + """Returns the formats of each array of arraylist as a comma-separated + string.""" + if isinstance(data, record): + return ",".join([desc[1] for desc in data.dtype.descr]) + + formats = '' + for obj in data: + obj = numeric.asarray(obj) +# if not isinstance(obj, ndarray): +## if not isinstance(obj, ndarray): +# raise ValueError, "item in the array list must be an ndarray." + formats += _typestr[obj.dtype.type] + if issubclass(obj.dtype.type, ntypes.flexible): + formats += `obj.itemsize` + formats += ',' + return formats[:-1] + +def _checknames(descr, names=None): + """Checks that the field names of the descriptor `descr` are not some + reserved keywords. If this is the case, a default 'f%i' is substituted. + If the argument `names` is not None, updates the field names to valid names. + """ + ndescr = len(descr) + default_names = ['f%i' % i for i in range(ndescr)] + reserved = ['_data','_mask','_fieldmask', 'dtype'] + if names is None: + new_names = default_names + else: + if isinstance(names, (tuple, list)): + new_names = names + elif isinstance(names, str): + new_names = names.split(',') + else: + raise NameError, "illegal input names %s" % `names` + nnames = len(new_names) + if nnames < ndescr: + new_names += default_names[nnames:] + ndescr = [] + for (n, d, t) in zip(new_names, default_names, descr.descr): + if n in reserved: + if t[0] in reserved: + ndescr.append((d,t[1])) + else: + ndescr.append(t) + else: + ndescr.append((n,t[1])) + return numeric.dtype(ndescr) + + + +class MaskedRecords(MaskedArray, object): """ :IVariables: @@ -47,76 +102,92 @@ Dictionary of global fields, as the combination of a `_data` and a `_mask`. (`f0`) """ - __localfdict = {} - __globalfdict = {} - def __new__(subtype, shape, dtype=None, buf=None, offset=0, strides=None, + _defaultfieldmask = nomask + _defaulthardmask = False + def __new__(cls, data, mask=nomask, dtype=None, + hard_mask=False, fill_value=None, +# offset=0, strides=None, formats=None, names=None, titles=None, - byteorder=None, aligned=False, hard_mask=False): - + byteorder=None, aligned=False): + # + if isinstance(data, MaskedRecords): + cls._defaultfieldmask = data._fieldmask + cls._defaulthardmask = data._hardmask | hard_mask + cls._fill_value = data._fill_value + return data._data.view(cls) + # Get the new descriptor ................ if dtype is not None: descr = numeric.dtype(dtype) else: - descr = format_parser(formats, names, titles, aligned, byteorder)._descr - - if buf is None: - mrec = ndarray.__new__(subtype, shape, (record, descr)) + if formats is None: + formats = _getformats(data) + parsed = format_parser(formats, names, titles, aligned, byteorder) + descr = parsed._descr + if names is not None: + descr = _checknames(descr,names) + _names = descr.names + mdescr = [(t[0],'|b1') for t in descr.descr] + # + shape = numeric.asarray(data[0]).shape + if isinstance(shape, int): + shape = (shape,) +# logging.debug('__new__: shape: %s' % str(shape)) + # Construct the _data recarray .......... + if isinstance(data, record): + _data = numeric.asarray(data).view(recarray) + _fieldmask = mask + elif isinstance(data, recarray): + _data = data + _fieldmask = mask else: - mrec = ndarray.__new__(subtype, shape, (record, descr), - buffer=buf, offset=offset, - strides=strides) - # Stores the field names in directories.. - mrec.__localfdict = dict(descr.fields) - mrec.__globalfdict = {} - keys = sorted(mrec.__localfdict.keys()) - for i in range(len(keys)//2): - ikey = keys[2*i] - nkey = "_".join(ikey.split('_')[:-1]) - (dfield, mfield) = ("%s_data" % nkey, "%s_mask" % nkey) - mrec.__globalfdict[nkey] = dict(_data=mrec.__localfdict[dfield], - _mask=mrec.__localfdict[mfield]) - mrec._hardmask = hard_mask - return mrec - - def __getallfields(self,fieldname): - """Returns all the fields sharing the same fieldname base. - The fieldname base is either `_data` or `_mask`.""" -# logging.debug('__getallfields(%s)' % fieldname) - (names, formats, offsets, objs) = ([], [], [], []) - fkeyname = '%%s%s' % fieldname - for s in self._mrecarray__globalfdict.keys(): - fkey = fkeyname % s - fattr = self._mrecarray__localfdict[fkey] - names.append(s) - obj = self.__getobj(ndarray.__getitem__(self,fkey)) - objs.append(obj) - formats.append(fattr[0]) - offsets.append(fattr[1]) - descr = [(n,f) for (n,f) in zip(names, formats)] - return N.core.records.fromarrays(objs, dtype=descr) - - def _getdata(self): - """Returns all the `_data` fields.""" - return self.__getallfields('_data') - - def _getfieldmask(self): - """Returns a recarray of the mask of each field.""" - return self.__getallfields('_mask') - - def _getmask(self): - """Returns the mask of the mrecarray. - An element of the mrecarray is considered masked when all the corresponding - fields are masked.""" - nbfields = len(self.dtype )//2 - recmask = self._getfieldmask().view(bool_).reshape(-1,nbfields) - return recmask.all(1) - - def __getobj(self, obj, viewtype=ndarray): - "Returns an object as a view of a ndarray, or as itself." - if (isinstance(obj, ndarray) and obj.dtype.isbuiltin): - return obj.view(viewtype) - return obj + _data = recarray(shape, dtype=descr) + _fieldmask = recarray(shape, dtype=mdescr) + for (n,v) in zip(_names, data): + _data[n] = numeric.asarray(v).view(ndarray) + _fieldmask[n] = getmaskarray(v) + +# logging.debug('__new__: _fieldmask: %s' % _fieldmask) + # Set filling value ..................... + if fill_value is None: + cls._fill_value = [default_fill_value(numeric.dtype(d[1])) + for d in descr.descr] + else: + cls._fill_value = fill_value + # Set class defaults .................... + cls._defaultfieldmask = _fieldmask + cls._defaulthardmask = hard_mask + # + return _data.view(cls) + + def __array_finalize__(self,obj): +# logging.debug("__array_finalize__ received %s" % type(obj)) + if isinstance(obj, MaskedRecords): + self.__dict__.update(_data=obj._data, + _fieldmask=obj._fieldmask, + _hardmask=obj._hardmask, + _fill_value=obj._fill_value + ) +# self._data = obj._data +# self._fieldmask = obj._fieldmask +# self._hardmask = obj._series._hardmask +# self._fill_value = obj._fill_value + else: +# self._data = obj.view(recarray) +# self._fieldmask = self._defaultfieldmask +# self._hardmask = self._defaulthardmask +# self.fill_value = self._fill_value + self.__dict__.update(_data = obj.view(recarray), + _fieldmask = self._defaultfieldmask, + _hardmask = self._defaulthardmask, + fill_value = self._fill_value + ) + MaskedRecords._defaultfieldmask = nomask + MaskedRecords._defaulthardmask = False +# logging.debug("__array_finalize__ exit ") + return #...................................................... def __getattribute__(self, attr): +# logging.debug('__getattribute__ %s' % attr) try: # Returns a generic attribute return object.__getattribute__(self,attr) @@ -124,61 +195,37 @@ # OK, so attr must be a field name pass # Get the list of fields ...... - fdict = ndarray.__getattribute__(self,'_mrecarray__localfdict') or {} - # Case #1: attr is a basic field - if attr in fdict.keys(): - fattr = fdict[attr] - obj = self.getfield(*fattr) - if obj.dtype.fields: - return obj - if obj.dtype.char in 'SU': - return obj.view(chararray) - return obj.view(ndarray) - # Case #2: attr is acompund field - elif ("%s_data" % attr) in fdict.keys(): - data = self.getfield(*fdict["%s_data" % attr ][:2]) - mask = self.getfield(*fdict["%s_mask" % attr ][:2]) - return MA.masked_array(data.view(ndarray), - mask=mask.view(ndarray), - copy=False) - # Case #3/4/5: attr is a generic field - elif attr == '_data': - func = ndarray.__getattribute__(self,'_mrecarray__getallfields') - return func.__call__('_data') - elif attr == '_fieldmask': - func = ndarray.__getattribute__(self,'_mrecarray__getallfields') - return func.__call__('_mask') +# logging.debug('__getattribute__ %s listfield' % attr) + _names = self.dtype.names + _local = self.__dict__ + _mask = _local['_fieldmask'] + if attr in _names: + _data = _local['_data'] + obj = numeric.asarray(_data.__getattribute__(attr)).view(MaskedArray) + obj._mask = make_mask(_mask.__getattribute__(attr)) + return obj elif attr == '_mask': -# logging.debug('__getattribute__: all fields %s' % attr) - func = ndarray.__getattribute__(self,'_getmask') - return func.__call__() - # Case #6: attr is not a field at all ! - else: - raise AttributeError, "record array has no attribute %s" % attr - -# Save the dictionary -# If the attr is a field name and not in the saved dictionary -# Undo any "setting" of the attribute and do a setfield -# Thus, you can't create attributes on-the-fly that are field names. - +# logging.debug('__getattribute__ return mask') + if self.size > 1: + return _mask.view((bool_, len(self.dtype))).all(1) + return _mask.view((bool_, len(self.dtype))) + raise AttributeError,"No attribute '%s' !" % attr + def __setattr__(self, attr, val): - # gets some status on attr: an existing field ? a new attribute ? - fdict = ndarray.__getattribute__(self,'_mrecarray__localfdict') or {} - gdict = ndarray.__getattribute__(self,'_mrecarray__globalfdict') or {} - attrlist = fdict.keys() + ['_data', '_fieldmask', '_mask'] - isvalidattr = (attr in attrlist ) or ('%s_data' % attr in attrlist) +# logging.debug('__setattribute__ %s' % attr) newattr = attr not in self.__dict__ - try: # Is attr a generic attribute ? ret = object.__setattr__(self, attr, val) except: # Not a generic attribute: exit if it's not a valid field - if not isvalidattr: +# logging.debug('__setattribute__ %s' % attr) + fielddict = self.dtype.names or {} + if attr not in fielddict: exctype, value = sys.exc_info()[:2] raise exctype, value else: - if not isvalidattr: + if attr not in list(self.dtype.names) + ['_mask']: return ret if newattr: # We just added this one try: # or this setattr worked on an internal @@ -186,94 +233,72 @@ object.__delattr__(self, attr) except: return ret - # Case #1.: Basic field ............ - if attr in fdict.keys(): - return self.setfield(val, *fdict[attr][:2]) - # Case #2 Compund field ............ - elif ("%s_data" % attr) in fdict.keys(): - data = self.setfield(filled(val), *fdict["%s_data" % attr ][:2]) - mask = self.setfield(getmaskarray(val), *fdict["%s_mask" % attr ][:2]) - return - elif attr == '_data': + base_fmask = self._fieldmask + _names = self.dtype.names + if attr in _names: fval = filled(val) - for k in gdict.keys(): - self.setfield(fval, *gdict["%s_data" % k ][:2]) - return -# func = ndarray.__getattribute__(self,'_mrecarray__getallfields') -# return func.__call__('_data') - elif attr == '_fieldmask': mval = getmaskarray(val) - for k in gdict.keys(): - self.setfield(mval, *gdict["%s_mask" % k ][:2]) + if self._hardmask: + mval = mask_or(mval, base_fmask.__getattr__(attr)) + self._data.__setattr__(attr, fval) + base_fmask.__setattr__(attr, mval) return -# func = ndarray.__getattribute__(self,'_mrecarray__getallfields') -# return func.__call__('_mask') elif attr == '_mask': -# logging.debug(" setattr _mask to %s [%s]" % (val,(val is nomask))) if self._hardmask: # logging.debug("setattr: object has hardmask") if val is not nomask: mval = getmaskarray(val) - for k in gdict.keys(): - fkey = fdict["%s_mask" % k ][:2] - m = mask_or(mval, self.getfield(*fkey)) -# logging.debug("setattr: set %s to %s" % (k,m)) - self.setfield(m, *fkey) + for k in _names: + m = mask_or(mval, base_fmask.__getattr__(k)) + base_fmask.__setattr__(k, m) else: mval = getmaskarray(val) - for k in gdict.keys(): - self.setfield(mval, *fdict["%s_mask" % k ][:2]) -# logging.debug('__getattribute__: all fields %s' % attr) + for k in _names: + base_fmask.__setattr__(k, mval) return -# func = ndarray.__getattribute__(self,'_getmask') -# return func.__call__() - - - #...................................................... + #............................................ def __getitem__(self, indx): -# logging.debug('__getitem__ got %s' % indx) - try: - obj = ndarray.__getitem__(self, indx) - except ValueError: - if indx in self.__globalfdict.keys(): - objd = ndarray.__getitem__(self, "%s_data" % indx) - objm = ndarray.__getitem__(self, "%s_mask" % indx) - return MA.masked_array(objd.view(ndarray), - mask=objm.view(ndarray)) - elif indx in ['_data', '_fieldmask']: - return self.__getallfields(indx) - elif indx == '_mask': - return self._getmask() - else: - msg = "Cannot do anything w/ indx '%s'!" % indx - raise ValueError, msg - -# logging.debug('__getitem__ send %s' % type(self.__getobj(obj))) - return self.__getobj(obj) - #....................................................... - def field(self,attr, val=None): - """Sets the field `attr` to the new value `val`. - If `val` is None, returns the corresponding field. - """ - if isinstance(attr,int): - names = ndarray.__getattribute__(self,'dtype').names - attr = names[attr] - - fdict = ndarray.__getattribute__(self,'_mrecarray__localfdict') or {} - f = fdict[attr] - # Case #1: just retrieve the data ....... - if val is None: - try: - return self.__getattribute__(attr) - except: - raise ValueError, "Unable to retrieve field '%s'" % attr - # Case #2: set the field to a new value .. + """Returns all the fields sharing the same fieldname base. + The fieldname base is either `_data` or `_mask`.""" +# logging.debug('__getitem__(%s)' % indx) + _localdict = self.__dict__ + # We want a field ........ + if isinstance(indx, str): + obj = _localdict['_data'][indx].view(MaskedArray) + obj._mask = make_mask(_localdict['_fieldmask'][indx]) + return obj + # We want some elements .. + return MaskedRecords(_localdict['_data'][indx], + mask=_localdict['_fieldmask'][indx], + dtype=self.dtype) + #...................................................... + def __str__(self): + """x.__str__() <==> str(x) +Calculates the string representation, using masked for fill if it is enabled. +Otherwise, fills with fill value. + """ + if self.size > 1: + mstr = ["(%s)" % ",".join([str(i) for i in s]) + for s in zip(*[getattr(self,f) for f in self.dtype.names])] + return "[%s]" % ", ".join(mstr) else: - try: - return self.__setattribute__(attr) - except: - raise ValueError, "Unable to set field '%s'" % attr + mstr = numeric.asarray(self._data.item(), dtype=object_) + mstr[list(self._fieldmask)] = masked_print_option + return str(mstr) + + def __repr__(self): + """x.__repr__() <==> repr(x) +Calculates the repr representation, using masked for fill if it is enabled. +Otherwise fill with fill value. + """ + _names = self.dtype.names + fmt = "%%%is : %%s" % (max([len(n) for n in _names])+4,) + reprstr = [fmt % (f,getattr(self,f)) for f in self.dtype.names] + reprstr.insert(0,'masked_records(') + reprstr.extend([fmt % (' fill_value', self._fill_value), + ' )']) + return str("\n".join(reprstr)) #...................................................... def view(self, obj): """Returns a view of the mrecarray.""" @@ -294,23 +319,17 @@ def soften_mask(self): "Forces the mask to soft" self._hardmask = False + #............................................. + def copy(self): + _localdict = self.__dict__ + return MaskedRecords(_localdict['_data'].copy(), + mask=_localdict['_fieldmask'].copy(), + dtype=self.dtype) + #####--------------------------------------------------------------------------- #---- --- Constructors --- #####--------------------------------------------------------------------------- -def _splitfields(descr): - """Creates a new descriptor from the descriptor `descr`. - The initial fields are renamed by adding a `_data` suffix to the name. - Their dtype is kept. - New fields are also created from the initial ones by adding a `_mask` suffix - to the name. - The dtype of these latter is set to `bool_` - """ - mdescr = [] - for (n,d) in descr.descr: - mdescr.append( ("%s_data" % n, d) ) - mdescr.append( ("%s_mask" % n, bool_) ) - return numeric.dtype(mdescr) def fromarrays(arraylist, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None): @@ -347,17 +366,7 @@ shape = (shape,) # Define formats from scratch ............... if formats is None and dtype is None: - # go through each object in the list to see if it is an ndarray - # and determine the formats. - formats = '' - for obj in arraylist: - if not isinstance(obj, ndarray): - raise ValueError, "item in the array list must be an ndarray." - formats += _typestr[obj.dtype.type] - if issubclass(obj.dtype.type, ntypes.flexible): - formats += `obj.itemsize` - formats += ',' - formats = formats[:-1] + formats = _getformats(arraylist) # logging.debug("fromarrays: formats",formats) # Define the dtype .......................... if dtype is not None: @@ -383,58 +392,25 @@ if testshape != shape: raise ValueError, "Array-shape mismatch in array %d" % k # Reconstruct the descriptor, by creating a _data and _mask version - mdescr = _splitfields(descr) - _array = mrecarray(shape, mdescr) - _names = mdescr.names - # Populate the record array (makes a copy) - for i in range(len(arraylist)): -# logging.debug("fromarrays: i:%i-%s/%s" % \ -# (i, arraylist[i]._data, MA.getmaskarray(arraylist[i]))) -# logging.debug("fromarrays: i:%i-%s/%s" % \ -# (i,_names[2*i], _names[2*i+1])) - _array[_names[2*i]] = arraylist[i]._data - _array[_names[2*i+1]] = getmaskarray(arraylist[i]) - return _array + return MaskedRecords(arraylist, dtype=descr) #.............................................................................. def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None): - """Creates a mrecarray from a list of records. + """Creates a MaskedRecords from a list of records. The data in the same field can be heterogeneous, they will be promoted to the highest data type. This method is intended for creating smaller record arrays. If used to create large array without formats - defined + defined, it can be slow. - r=fromrecords([(2,3.,'abc')]*100000) - - it can be slow. - - If formats is None, then this will auto-detect formats. Use list of - tuples rather than list of lists for faster processing. - - >>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3') - >>> print r[0] - (456, 'dbe', 1.2) - >>> r.col1 - array([456, 2]) - >>> r.col2 - chararray(['dbe', 'de']) - >>> import cPickle - >>> print cPickle.loads(cPickle.dumps(r)) - recarray[ - (456, 'dbe', 1.2), - (2, 'de', 1.3) - ] + If formats is None, then this will auto-detect formats. Use a list of + tuples rather than a list of lists for faster processing. """ - # Case #1: reclist is in fact a mrecarray ........ - if isinstance(reclist, mrecarray): + # reclist is in fact a mrecarray ................. + if isinstance(reclist, MaskedRecords): mdescr = reclist.dtype shape = reclist.shape - _array = mrecarray(shape, mdescr) - for (i,r) in enumerate(reclist): - _array[i] = r - return _array - + return MaskedRecords(reclist, dtype=mdescr) # No format, no dtype: create from to arrays ..... nfields = len(reclist[0]) if formats is None and dtype is None: # slower @@ -446,8 +422,8 @@ obj = numeric.array(reclist,dtype=object) arrlist = [numeric.array(obj[...,i].tolist()) for i in xrange(nfields)] - return fromarrays(arrlist, formats=formats, shape=shape, names=names, - titles=titles, aligned=aligned, byteorder=byteorder) + return MaskedRecords(arrlist, formats=formats, names=names, + titles=titles, aligned=aligned, byteorder=byteorder) # Construct the descriptor ....................... if dtype is not None: descr = numeric.dtype(dtype) @@ -456,7 +432,6 @@ parsed = format_parser(formats, names, titles, aligned, byteorder) _names = parsed._names descr = parsed._descr - mdescr = _splitfields(descr) try: retval = numeric.array(reclist, dtype = descr) @@ -467,21 +442,15 @@ shape = (shape*2,) if len(shape) > 1: raise ValueError, "Can only deal with 1-d array." - _array = recarray(shape, mdescr) - raise NotImplementedError,"I should really test that..." - for k in xrange(_array.size): - _array[k] = tuple(reclist[k]) - return _array + retval = recarray(shape, mdescr) + for k in xrange(retval.size): + retval[k] = tuple(reclist[k]) + return MaskedRecords(retval, dtype=descr) else: if shape is not None and retval.shape != shape: retval.shape = shape # - tmp = retval.view(recarray) - _array = mrecarray(shape, mdescr) - for n in tmp.dtype.names: - _array['%s_data' % n] = tmp[n] - _array['%s_mask' % n] = nomask - return _array + return MaskedRecords(retval, dtype=descr) def _guessvartypes(arr): """Tries to guess the dtypes of the str_ ndarray `arr`, by testing element-wise @@ -561,16 +530,14 @@ line = f.readline() firstline = line[:line.find(commentchar)].strip() _varnames = firstline.split(delimitor) - logging.debug("_VARNAMES:%s-%s"% (_varnames,len(_varnames))) +# logging.debug("_VARNAMES:%s-%s"% (_varnames,len(_varnames))) if len(_varnames) > 1: break if varnames is None: varnames = _varnames # Get the data .............................. - _variables = [line.strip().split(delimitor) for line in f - if line[0] != commentchar and len(line) > 1] - _variables = N.array(_variables) - #_variables = MA.masked_equal(_variables,'') + _variables = MA.asarray([line.strip().split(delimitor) for line in f + if line[0] != commentchar and len(line) > 1]) (nvars, nfields) = _variables.shape # Try to guess the dtype .................... if vartypes is None: @@ -584,43 +551,14 @@ vartypes = _guessvartypes(_variables[0]) # Construct the descriptor .................. mdescr = [(n,f) for (n,f) in zip(varnames, vartypes)] +# logging.debug("fromtextfile: descr: %s" % mdescr) # Get the data and the mask ................. # We just need a list of masked_arrays. It's easier to create it like that: _mask = (_variables.T == missingchar) _datalist = [masked_array(a,mask=m,dtype=t) for (a,m,t) in zip(_variables.T, _mask, vartypes)] - return fromarrays(_datalist, dtype=mdescr) + return MaskedRecords(_datalist, dtype=mdescr) ################################################################################ -from maskedarray.testutils import assert_equal, assert_array_equal -if 1: - if 0: - 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]) -#............................................................................... - - - - - - Deleted: trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py 2007-01-12 21:19:21 UTC (rev 2543) +++ trunk/Lib/sandbox/maskedarray/tests/test_mrecarray.py 2007-01-13 01:13:12 UTC (rev 2544) @@ -1,131 +0,0 @@ -# pylint: disable-msg=W0611, W0612, W0511,R0201 -"""Tests suite for mrecarray. - -: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 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 -reload(maskedarray.testutils) -from maskedarray.testutils import * - -import maskedarray.core as MA -#reload(MA) -import maskedarray.mrecords -#reload(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 Added: trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py 2007-01-12 21:19:21 UTC (rev 2543) +++ trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py 2007-01-13 01:13:12 UTC (rev 2544) @@ -0,0 +1,134 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for mrecarray. + +: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 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 +reload(maskedarray.testutils) +from maskedarray.testutils import * + +import maskedarray.core as MA +##reload(MA) +#import maskedarray.mrecords +##reload(maskedarray.mrecords) +#from maskedarray.mrecords import mrecarray, fromarrays, fromtextfile, fromrecords +import mrecords +reload(mrecords) +from mrecords import MaskedRecords, fromarrays, fromtextfile, fromrecords + +#.............................................................................. +class test_mrecords(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) + mrecord = fromarrays(base.T,) + self.data = [d, m, mrecord] + + def test_get(self): + "Tests fields retrieval" + [d, m, mrec] = self.data + mrec = mrec.copy() + 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[1], mrec[1].f0) + + def test_set(self): + "Tests setting fields/attributes." + [d, m, mrecord] = self.data + mrecord.f0._data[:] = 5 + assert_equal(mrecord['f0']._data, [5,5,5,5,5]) + mrecord.f0 = 1 + assert_equal(mrecord['f0']._data, [1]*5) + assert_equal(getmaskarray(mrecord['f0']), [0]*5) + mrecord.f1 = MA.masked + assert_equal(mrecord.f1.mask, [1]*5) + assert_equal(getmaskarray(mrecord['f1']), [1]*5) + mrecord._mask = MA.masked + assert_equal(getmaskarray(mrecord['f1']), [1]*5) + assert_equal(mrecord['f0']._mask, mrecord['f1']._mask) + mrecord._mask = MA.nomask + assert_equal(getmaskarray(mrecord['f1']), [0]*5) + assert_equal(mrecord['f0']._mask, mrecord['f1']._mask) + + def test_hardmask(self): + "Test hardmask" + [d, m, mrec] = self.data + mrec = mrec.copy() + 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(mrec['f1']._mask is nomask) + assert_equal(mrec['f0']._mask,mrec['f1']._mask) + + 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]) + + 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, MaskedRecords)) + 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]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Property changes on: trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Sat Jan 13 12:34:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 13 Jan 2007 11:34:11 -0600 (CST) Subject: [Scipy-svn] r2545 - trunk/Lib/interpolate Message-ID: <20070113173411.E314C39C159@new.scipy.org> Author: jtravs Date: 2007-01-13 11:33:43 -0600 (Sat, 13 Jan 2007) New Revision: 2545 Modified: trunk/Lib/interpolate/fitpack.py Log: Fixed two bugs in splrep and make edits so that the tests at the end of fitpack.py run (fixes ticket #332). Modified: trunk/Lib/interpolate/fitpack.py =================================================================== --- trunk/Lib/interpolate/fitpack.py 2007-01-13 01:13:12 UTC (rev 2544) +++ trunk/Lib/interpolate/fitpack.py 2007-01-13 17:33:43 UTC (rev 2545) @@ -363,7 +363,8 @@ t = empty((nest,),float) _curfit_cache['t'] = t if task <= 0: - _curfit_cache['wrk'] = empty((m*(k+1)+nest*(7+3*k),),float) + if per: _curfit_cache['wrk'] = empty((m*(k+1)+nest*(8+5*k),),float) + else: _curfit_cache['wrk'] = empty((m*(k+1)+nest*(7+3*k),),float) _curfit_cache['iwrk'] = empty((nest,),int32) try: t=_curfit_cache['t'] @@ -376,7 +377,7 @@ n,c,fp,ier = dfitpack.curfit(task, x, y, w, t, wrk, iwrk, xb, xe, k, s) else: n,c,fp,ier = dfitpack.percur(task, x, y, w, t, wrk, iwrk, k, s) - tck = (t[:n],c[:n-k-1],k) + tck = (t[:n],c[:n],k) if ier<=0 and not quiet: print _iermess[ier][0] print "\tk=%d n=%d m=%d fp=%f s=%f"%(k,len(t),m,fp,s) @@ -781,7 +782,7 @@ v,v1=f(x),f(x1) nk=[] for k in range(1,6): - tck=splrep(x,v,s=s,per=per,k=k,nest=-1,xe=xe) + tck=splrep(x,v,s=s,per=per,k=k,xe=xe) if at:t=tck[0][k:-k] else: t=x1 nd=[] @@ -810,7 +811,7 @@ v=f(x) nk=[] for k in range(1,6): - tck=splrep(x,v,s=s,per=per,k=k,nest=-1,xe=xe) + tck=splrep(x,v,s=s,per=per,k=k,xe=xe) nk.append([splint(ia,ib,tck),spalde(dx,tck)]) print "\nf = %s s=S_k(x;t,c) x in [%s, %s] > [%s, %s]"%(f(None), `round(xb,3)`,`round(xe,3)`, @@ -839,7 +840,7 @@ print " k : Roots of s(x) approx %s x in [%s,%s]:"%\ (f(None),`round(a,3)`,`round(b,3)`) for k in range(1,6): - tck=splrep(x,v,s=s,per=per,k=k,nest=-1,xe=xe) + tck=splrep(x,v,s=s,per=per,k=k,xe=xe) print ' %d : %s'%(k,`sproot(tck).tolist()`) def test4(f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None, ia=0,ib=2*pi,dx=0.2*pi): @@ -853,7 +854,7 @@ print " k : [x(u), %s(x(u))] Error of splprep Error of splrep "%(f(0,None)) for k in range(1,6): tckp,u=splprep([x,v],s=s,per=per,k=k,nest=-1) - tck=splrep(x,v,s=s,per=per,k=k,nest=-1) + tck=splrep(x,v,s=s,per=per,k=k) uv=splev(dx,tckp) print " %d : %s %.1e %.1e"%\ (k,`map(lambda x:round(x,3),uv)`, From scipy-svn at scipy.org Sun Jan 14 07:35:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 06:35:33 -0600 (CST) Subject: [Scipy-svn] r2546 - trunk/Lib/sandbox/models Message-ID: <20070114123533.55E4239C013@new.scipy.org> Author: jarrod.millman Date: 2007-01-14 06:35:28 -0600 (Sun, 14 Jan 2007) New Revision: 2546 Modified: trunk/Lib/sandbox/models/__init__.py Log: use absolute imports and define __all__ Modified: trunk/Lib/sandbox/models/__init__.py =================================================================== --- trunk/Lib/sandbox/models/__init__.py 2007-01-13 17:33:43 UTC (rev 2545) +++ trunk/Lib/sandbox/models/__init__.py 2007-01-14 12:35:28 UTC (rev 2546) @@ -2,15 +2,17 @@ # models - Statistical Models # -from info import __doc__ +from scipy.sandbox.models.info import __doc__ -import model -import formula -import regression -import robust -import family -from glm import model as glm -from rlm import model as rlm +import scipy.sandbox.models.model +import scipy.sandbox.models.formula +import scipy.sandbox.models.regression +import scipy.sandbox.models.robust +import scipy.sandbox.models.family +from scipy.sandbox.models.glm import model as glm +from scipy.sandbox.models.rlm import model as rlm +__all__ = filter(lambda s:not s.startswith('_'),dir()) + from numpy.testing import NumpyTest test = NumpyTest().test From scipy-svn at scipy.org Sun Jan 14 08:12:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 07:12:34 -0600 (CST) Subject: [Scipy-svn] r2547 - in trunk/Lib/sandbox/models: . tests Message-ID: <20070114131234.45D5F39C013@new.scipy.org> Author: jarrod.millman Date: 2007-01-14 07:12:30 -0600 (Sun, 14 Jan 2007) New Revision: 2547 Modified: trunk/Lib/sandbox/models/bspline.py trunk/Lib/sandbox/models/cox.py trunk/Lib/sandbox/models/gam.py trunk/Lib/sandbox/models/glm.py trunk/Lib/sandbox/models/setup.py trunk/Lib/sandbox/models/smoothers.py trunk/Lib/sandbox/models/tests/test_robust.py Log: minor clean ups Modified: trunk/Lib/sandbox/models/bspline.py =================================================================== --- trunk/Lib/sandbox/models/bspline.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/bspline.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -1,10 +1,9 @@ - import numpy as N import numpy.linalg as L +from scipy.linalg import solveh_banded from scipy.optimize import golden from scipy.sandbox.models import _bspline -from scipy.linalg import solveh_banded def _upper2lower(ub): """ Modified: trunk/Lib/sandbox/models/cox.py =================================================================== --- trunk/Lib/sandbox/models/cox.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/cox.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -1,6 +1,8 @@ import shutil import tempfile + import numpy as N + from scipy.sandbox.models import survival, model class discrete: @@ -197,7 +199,7 @@ for i in range(2*n): subjects[i].X = X[i] - import formula as F + import scipy.sandbox.models.formula as F x = F.quantitative('X') f = F.formula(x) Modified: trunk/Lib/sandbox/models/gam.py =================================================================== --- trunk/Lib/sandbox/models/gam.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/gam.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -1,9 +1,9 @@ import numpy as N + from scipy.sandbox.models import family +from scipy.sandbox.models.bspline import SmoothingSpline +from scipy.sandbox.models.glm import model as glm -from glm import model as glm -from bspline import SmoothingSpline - def default_smoother(x): _x = x.copy() _x.sort() Modified: trunk/Lib/sandbox/models/glm.py =================================================================== --- trunk/Lib/sandbox/models/glm.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/glm.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -25,11 +25,13 @@ """ if results is None: results = self.results - if Y is None: Y = self.Y + if Y is None: + Y = self.Y return self.family.deviance(Y, results.mu) / scale def next(self): - results = self.results; Y = self.Y + results = self.results + Y = self.Y self.weights = self.family.weights(results.mu) self.initialize(self.design) Z = results.predict + self.family.link.deriv(results.mu) * (Y - results.mu) Modified: trunk/Lib/sandbox/models/setup.py =================================================================== --- trunk/Lib/sandbox/models/setup.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/setup.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -8,7 +8,7 @@ config.add_data_dir('tests') try: - from bspline_module import mod + from scipy.sandbox.models.bspline_module import mod n, s, d = weave_ext(mod) config.add_extension(n, s, **d) except ImportError: pass Modified: trunk/Lib/sandbox/models/smoothers.py =================================================================== --- trunk/Lib/sandbox/models/smoothers.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/smoothers.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -7,13 +7,11 @@ import numpy as N import numpy.linalg as L -from scipy.optimize import golden from scipy.linalg import solveh_banded +from scipy.optimize import golden -from bspline import bspline -from utils import band2array - from scipy.sandbox.models import _bspline +from scipy.sandbox.models.bspline import bspline, band2array class poly_smoother: @@ -96,7 +94,7 @@ mask = N.flatnonzero(1 - N.alltrue(N.equal(bt, 0), axis=0)) - bt = bt[:,mask] + bt = bt[:, mask] y = y[mask] self.df_total = y.shape[0] @@ -115,9 +113,9 @@ nband, nbasis = self.g.shape for i in range(nbasis): for k in range(min(nband, nbasis-i)): - self.btb[k,i] = (bt[i] * bt[i+k]).sum() + self.btb[k, i] = (bt[i] * bt[i+k]).sum() - bty.shape = (1,bty.shape[0]) + bty.shape = (1, bty.shape[0]) self.chol, self.coef = solveh_banded(self.btb + pen*self.g, bty, lower=1) @@ -164,7 +162,6 @@ return self.rank class smoothing_spline_fixeddf(smoothing_spline): - """ Fit smoothing spline with approximately df degrees of freedom used in the fit, i.e. so that self.trace() is approximately df. @@ -172,7 +169,6 @@ In general, df must be greater than the dimension of the null space of the Gram inner product. For cubic smoothing splines, this means that df > 2. - """ target_df = 5 Modified: trunk/Lib/sandbox/models/tests/test_robust.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 12:35:28 UTC (rev 2546) +++ trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 13:12:30 UTC (rev 2547) @@ -1,8 +1,9 @@ -import scipy.sandbox.models as S import unittest + import numpy.random as R -import numpy as N +import scipy.sandbox.models as S + W = R.standard_normal class RegressionTest(unittest.TestCase): From scipy-svn at scipy.org Sun Jan 14 08:52:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 07:52:34 -0600 (CST) Subject: [Scipy-svn] r2548 - trunk/Lib/sandbox/models/tests Message-ID: <20070114135234.5806039C013@new.scipy.org> Author: jarrod.millman Date: 2007-01-14 07:52:31 -0600 (Sun, 14 Jan 2007) New Revision: 2548 Modified: trunk/Lib/sandbox/models/tests/test_formula.py trunk/Lib/sandbox/models/tests/test_glm.py trunk/Lib/sandbox/models/tests/test_regression.py trunk/Lib/sandbox/models/tests/test_robust.py trunk/Lib/sandbox/models/tests/test_utils.py Log: cleaning up tests Modified: trunk/Lib/sandbox/models/tests/test_formula.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_formula.py 2007-01-14 13:12:30 UTC (rev 2547) +++ trunk/Lib/sandbox/models/tests/test_formula.py 2007-01-14 13:52:31 UTC (rev 2548) @@ -1,17 +1,17 @@ import csv import os import string -import unittest +#import unittest import numpy as N import numpy.random as R import numpy.linalg as L -from numpy.testing import assert_almost_equal, NumpyTestCase +from numpy.testing import assert_almost_equal, NumpyTest, NumpyTestCase import scipy from scipy.sandbox.models import utils, formula, contrast -class test_term(unittest.TestCase): +class test_term(NumpyTestCase): def test_init(self): t1 = formula.term("trivial") @@ -226,10 +226,11 @@ self.assertEquals(estimable, False) -def suite(): - suite = unittest.makeSuite(formulaTest) - return suite +#def suite(): +# suite = unittest.makeSuite(formulaTest) +# return suite - -if __name__ == '__main__': - unittest.main() +if __name__ == "__main__": + NumpyTest().run() +#if __name__ == '__main__': +# unittest.main() Modified: trunk/Lib/sandbox/models/tests/test_glm.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_glm.py 2007-01-14 13:12:30 UTC (rev 2547) +++ trunk/Lib/sandbox/models/tests/test_glm.py 2007-01-14 13:52:31 UTC (rev 2548) @@ -1,4 +1,4 @@ -import unittest +#import unittest import numpy as N import numpy.random as R Modified: trunk/Lib/sandbox/models/tests/test_regression.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_regression.py 2007-01-14 13:12:30 UTC (rev 2547) +++ trunk/Lib/sandbox/models/tests/test_regression.py 2007-01-14 13:52:31 UTC (rev 2548) @@ -1,12 +1,13 @@ -import unittest +#import unittest from numpy.random import standard_normal +from numpy.testing import NumpyTest, NumpyTestCase from scipy.sandbox.models.regression import ols_model, ar_model W = standard_normal -class test_Regression(unittest.TestCase): +class test_Regression(NumpyTestCase): def testOLS(self): X = W((40,10)) @@ -38,6 +39,7 @@ results = model.fit(Y) self.assertEquals(results.df_resid, 31) - -if __name__ == '__main__': - unittest.main() +if __name__ == "__main__": + NumpyTest().run() +#if __name__ == '__main__': +# unittest.main() Modified: trunk/Lib/sandbox/models/tests/test_robust.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 13:12:30 UTC (rev 2547) +++ trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 13:52:31 UTC (rev 2548) @@ -1,12 +1,13 @@ -import unittest +#import unittest import numpy.random as R +from numpy.testing import NumpyTest, NumpyTestCase import scipy.sandbox.models as S W = R.standard_normal -class RegressionTest(unittest.TestCase): +class RegressionTest(NumpyTestCase): def testRobust(self): X = W((40,10)) @@ -23,6 +24,7 @@ results = model.fit(Y) self.assertEquals(results.df_resid, 31) - -if __name__ == '__main__': - unittest.main() +if __name__ == "__main__": + NumpyTest().run() +#if __name__ == '__main__': +# unittest.main() Modified: trunk/Lib/sandbox/models/tests/test_utils.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_utils.py 2007-01-14 13:12:30 UTC (rev 2547) +++ trunk/Lib/sandbox/models/tests/test_utils.py 2007-01-14 13:52:31 UTC (rev 2548) @@ -1,13 +1,13 @@ -import unittest +#import unittest import numpy as N import numpy.random as R -from numpy.testing import assert_almost_equal +from numpy.testing import assert_almost_equal, NumpyTest, NumpyTestCase import scipy from scipy.sandbox.models import utils -class test_Utils(unittest.TestCase): +class test_Utils(NumpyTestCase): def test_recipr(self): X = N.array([[2,1],[-1,0]]) @@ -53,5 +53,7 @@ y = N.zeros((2, 2)) self.assertRaises(ValueError, utils.StepFunction, x, y) -if __name__ == '__main__': - unittest.main() +if __name__ == "__main__": + NumpyTest().run() +#if __name__ == '__main__': +# unittest.main() From scipy-svn at scipy.org Sun Jan 14 09:23:47 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 08:23:47 -0600 (CST) Subject: [Scipy-svn] r2549 - trunk/Lib/sandbox/models/tests Message-ID: <20070114142347.35C7F39C08B@new.scipy.org> Author: jarrod.millman Date: 2007-01-14 08:23:43 -0600 (Sun, 14 Jan 2007) New Revision: 2549 Added: trunk/Lib/sandbox/models/tests/test_rlm.py Removed: trunk/Lib/sandbox/models/tests/__init__.py trunk/Lib/sandbox/models/tests/test_robust.py Modified: trunk/Lib/sandbox/models/tests/test_formula.py trunk/Lib/sandbox/models/tests/test_glm.py trunk/Lib/sandbox/models/tests/test_regression.py trunk/Lib/sandbox/models/tests/test_utils.py Log: minor fixes of the models.test() Deleted: trunk/Lib/sandbox/models/tests/__init__.py =================================================================== --- trunk/Lib/sandbox/models/tests/__init__.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/__init__.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -1,10 +0,0 @@ -import unittest - -from scipy.sandbox.models.tests import test_formula -from scipy.sandbox.models.tests import test_regression -from scipy.sandbox.models.tests import test_utils - -def suite(): - return unittest.TestSuite([test_formula.suite(), - test_regression.suite(), - test_utils.suite()]) Modified: trunk/Lib/sandbox/models/tests/test_formula.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_formula.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/test_formula.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -1,7 +1,8 @@ -import csv -import os +""" +Test functions for models.formula +""" + import string -#import unittest import numpy as N import numpy.random as R @@ -226,11 +227,5 @@ self.assertEquals(estimable, False) -#def suite(): -# suite = unittest.makeSuite(formulaTest) -# return suite - if __name__ == "__main__": NumpyTest().run() -#if __name__ == '__main__': -# unittest.main() Modified: trunk/Lib/sandbox/models/tests/test_glm.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_glm.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/test_glm.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -1,11 +1,13 @@ -#import unittest +""" +Test functions for models.glm +""" import numpy as N import numpy.random as R from numpy.testing import NumpyTest, NumpyTestCase import scipy.sandbox.models as S -from scipy.sandbox.models.glm import model +import scipy.sandbox.models.glm as models W = R.standard_normal @@ -15,7 +17,7 @@ X = W((40,10)) Y = N.greater(W((40,)), 0) family = S.family.Binomial() - cmodel = model(design=X, family=S.family.Binomial()) + cmodel = models(design=X, family=S.family.Binomial()) results = cmodel.fit(Y) self.assertEquals(results.df_resid, 30) @@ -24,10 +26,9 @@ X[:,0] = X[:,1] + X[:,2] Y = N.greater(W((40,)), 0) family = S.family.Binomial() - cmodel = model(design=X, family=S.family.Binomial()) + cmodel = models(design=X, family=S.family.Binomial()) results = cmodel.fit(Y) self.assertEquals(results.df_resid, 31) - if __name__ == "__main__": NumpyTest().run() Modified: trunk/Lib/sandbox/models/tests/test_regression.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_regression.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/test_regression.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -1,4 +1,6 @@ -#import unittest +""" +Test functions for models.regression +""" from numpy.random import standard_normal from numpy.testing import NumpyTest, NumpyTestCase @@ -41,5 +43,3 @@ if __name__ == "__main__": NumpyTest().run() -#if __name__ == '__main__': -# unittest.main() Copied: trunk/Lib/sandbox/models/tests/test_rlm.py (from rev 2548, trunk/Lib/sandbox/models/tests/test_robust.py) =================================================================== --- trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/test_rlm.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -0,0 +1,30 @@ +""" +Test functions for models.rlm +""" + +import numpy.random as R +from numpy.testing import NumpyTest, NumpyTestCase + +import scipy.sandbox.models.rlm as models + +W = R.standard_normal + +class test_Regression(NumpyTestCase): + + def test_Robust(self): + X = W((40,10)) + Y = W((40,)) + model = models(design=X) + results = model.fit(Y) + self.assertEquals(results.df_resid, 30) + + def test_Robustdegenerate(self): + X = W((40,10)) + X[:,0] = X[:,1] + X[:,2] + Y = W((40,)) + model = models(design=X) + results = model.fit(Y) + self.assertEquals(results.df_resid, 31) + +if __name__ == "__main__": + NumpyTest().run() Deleted: trunk/Lib/sandbox/models/tests/test_robust.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/test_robust.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -1,30 +0,0 @@ -#import unittest - -import numpy.random as R -from numpy.testing import NumpyTest, NumpyTestCase - -import scipy.sandbox.models as S - -W = R.standard_normal - -class RegressionTest(NumpyTestCase): - - def testRobust(self): - X = W((40,10)) - Y = W((40,)) - model = S.rlm(design=X) - results = model.fit(Y) - self.assertEquals(results.df_resid, 30) - - def testRobustdegenerate(self): - X = W((40,10)) - X[:,0] = X[:,1] + X[:,2] - Y = W((40,)) - model = S.rlm(design=X) - results = model.fit(Y) - self.assertEquals(results.df_resid, 31) - -if __name__ == "__main__": - NumpyTest().run() -#if __name__ == '__main__': -# unittest.main() Modified: trunk/Lib/sandbox/models/tests/test_utils.py =================================================================== --- trunk/Lib/sandbox/models/tests/test_utils.py 2007-01-14 13:52:31 UTC (rev 2548) +++ trunk/Lib/sandbox/models/tests/test_utils.py 2007-01-14 14:23:43 UTC (rev 2549) @@ -1,10 +1,12 @@ -#import unittest +""" +Test functions for models.utils +""" import numpy as N import numpy.random as R from numpy.testing import assert_almost_equal, NumpyTest, NumpyTestCase + import scipy - from scipy.sandbox.models import utils class test_Utils(NumpyTestCase): @@ -55,5 +57,3 @@ if __name__ == "__main__": NumpyTest().run() -#if __name__ == '__main__': -# unittest.main() From scipy-svn at scipy.org Sun Jan 14 16:23:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 15:23:02 -0600 (CST) Subject: [Scipy-svn] r2550 - in trunk/Lib/sandbox/timeseries: . archived_version Message-ID: <20070114212302.3153D39C049@new.scipy.org> Author: pierregm Date: 2007-01-14 15:22:58 -0600 (Sun, 14 Jan 2007) New Revision: 2550 Added: trunk/Lib/sandbox/timeseries/archived_version/ trunk/Lib/sandbox/timeseries/archived_version/corelib.py trunk/Lib/sandbox/timeseries/archived_version/timeseries.py trunk/Lib/sandbox/timeseries/archived_version/tsdate.py Log: Moved the initial version to the `archived_version` folder Copied: trunk/Lib/sandbox/timeseries/archived_version/corelib.py (from rev 2549, trunk/Lib/sandbox/timeseries/corelib.py) Copied: trunk/Lib/sandbox/timeseries/archived_version/timeseries.py (from rev 2549, trunk/Lib/sandbox/timeseries/timeseries.py) Copied: trunk/Lib/sandbox/timeseries/archived_version/tsdate.py (from rev 2549, trunk/Lib/sandbox/timeseries/tsdate.py) From scipy-svn at scipy.org Sun Jan 14 16:25:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 15:25:22 -0600 (CST) Subject: [Scipy-svn] r2551 - trunk/Lib/sandbox/timeseries Message-ID: <20070114212522.3FA9739C0A1@new.scipy.org> Author: pierregm Date: 2007-01-14 15:25:20 -0600 (Sun, 14 Jan 2007) New Revision: 2551 Added: trunk/Lib/sandbox/timeseries/tests/ Log: added the tests directory Copied: trunk/Lib/sandbox/timeseries/tests (from rev 2488, trunk/Lib/sandbox/timeseries/mtimeseries/tests) From scipy-svn at scipy.org Sun Jan 14 17:39:29 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 16:39:29 -0600 (CST) Subject: [Scipy-svn] r2552 - in trunk/Lib/sandbox/timeseries: . build build/lib.linux-x86_64-2.4 build/lib.linux-x86_64-2.4/timeseries build/temp.linux-x86_64-2.4 examples src tests Message-ID: <20070114223929.39FD139C049@new.scipy.org> Author: pierregm Date: 2007-01-14 16:39:15 -0600 (Sun, 14 Jan 2007) New Revision: 2552 Added: trunk/Lib/sandbox/timeseries/.project trunk/Lib/sandbox/timeseries/CHANGELOG trunk/Lib/sandbox/timeseries/MANIFEST trunk/Lib/sandbox/timeseries/build/ trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/ trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/ trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/__init__.py trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tcore.py trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tdates.py trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tseries.py trunk/Lib/sandbox/timeseries/build/temp.linux-x86_64-2.4/ trunk/Lib/sandbox/timeseries/build/temp.linux-x86_64-2.4/src/ 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 Removed: trunk/Lib/sandbox/timeseries/corelib.py trunk/Lib/sandbox/timeseries/mtimeseries/ trunk/Lib/sandbox/timeseries/timeseries.py trunk/Lib/sandbox/timeseries/tsdate.py Modified: trunk/Lib/sandbox/timeseries/ trunk/Lib/sandbox/timeseries/__init__.py trunk/Lib/sandbox/timeseries/examples/ trunk/Lib/sandbox/timeseries/examples/example.py trunk/Lib/sandbox/timeseries/src/ Log: cf changelog Property changes on: trunk/Lib/sandbox/timeseries ___________________________________________________________________ Name: svn:ignore + sandbox Added: trunk/Lib/sandbox/timeseries/.project =================================================================== --- trunk/Lib/sandbox/timeseries/.project 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/.project 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,17 @@ + + + scipy_svn_timeseries + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + Copied: trunk/Lib/sandbox/timeseries/CHANGELOG (from rev 2488, trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG) =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/CHANGELOG 2007-01-04 16:42:30 UTC (rev 2488) +++ trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,15 @@ +#2007-01-14 : Code reorganization: +# : - Moved Matt's initial version to archived_version +# : - Moved Pierre's version to base +# : tdates +# : - Fixed a bug w/ definition of months and weeks +# : - Renamed dateOf to asfreq + use cseries +#2007-01-04 : tsdate +# : - Corrected a bug w/ Date.__init__ and 'B' freq +#2007-01-03 : tseries +# : - Allowed endpoints adjustment after convert +# : - Put the estimation of the data length in its own function. +# : - Added a timestep compatibility check. +# : - The variables in a multi-series correspond now to the last axis. +# : - Blocked transpose/swapaxes, temporarily. +# : - Speed-up fill_missing_dates \ No newline at end of file Added: trunk/Lib/sandbox/timeseries/MANIFEST =================================================================== --- trunk/Lib/sandbox/timeseries/MANIFEST 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/MANIFEST 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,8 @@ +setup.py +./__init__.py +./corelib.py +./cseries.c +./shiftingarray.py +./timeseries.py +./tsdate.py +./examples/example.py Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -1,3 +0,0 @@ -from timeseries import * -from tsdate import * -from corelib import * Property changes on: trunk/Lib/sandbox/timeseries/__init__.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/__init__.py =================================================================== Added: trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tcore.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tcore.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,157 @@ +import numpy +import maskedarray as MA + + +#####--------------------------------------------------------------------------- +#---- --- Generic functions --- +#####--------------------------------------------------------------------------- +def first_unmasked_val(a): + "Returns the first unmasked value in a 1d maskedarray." + (i,j) = MA.extras.flatnotmasked_edges(a) + return a[i] + +def last_unmasked_val(a): + "Returns the last unmasked value in a 1d maskedarray." + (i,j) = MA.extras.flatnotmasked_edges(a) + return a[j] + +def reverse_dict(d): + "Reverses the keys and values of a dictionary." + alt = [] + tmp = [alt.extend([(w,k) for w in v]) for (k,v) in d.iteritems()] + return dict(alt) + + + +#####--------------------------------------------------------------------------- +#---- --- Option conversion --- +#####--------------------------------------------------------------------------- +obs_dict = {"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 +# +def fmtObserv(obStr): + "Converts a possible 'Observed' string into acceptable values." + if obStr is None: + return None + elif obStr.upper() in obs_dict.keys(): + return obStr.upper() + else: + raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) + + +fmtfreq_dict = {'A': ['ANNUAL','ANNUALLY','YEAR','YEARLY'], + 'B': ['BUSINESS','BUSINESSLYT'], + 'D': ['DAY','DAILY',], + 'H': ['HOUR','HOURLY',], + 'M': ['MONTH','MONTHLY',], + 'Q': ['QUARTER','QUARTERLY',], + 'S': ['SECOND','SECONDLY',], + 'T': ['MINUTE','MINUTELY',], + 'W': ['WEEK','WEEKLY',], + 'U': ['UNDEF','UNDEFINED'], + } +fmtfreq_revdict = reverse_dict(fmtfreq_dict) + +def fmtFreq (freqStr): + "Converts a possible 'frequency' string to acceptable values." + if freqStr is None: + return None + elif freqStr.upper() in fmtfreq_dict.keys(): + return freqStr[0].upper() + elif freqStr.upper() in fmtfreq_revdict.keys(): + return fmtfreq_revdict[freqStr.upper()] + else: + raise ValueError("Invalid frequency: %s " % str(freqStr)) + +class DateSpec: + "Fake data type for date variables." + def __init__(self, freq): + self.freq = fmtFreq(freq) + + def __hash__(self): + return hash(self.freq) + + def __eq__(self, other): + if hasattr(other, "freq"): + return self.freq == other.freq + else: + return False + def __str__(self): + return "Date(%s)" % str(self.freq) + + + +# define custom numpy types. +# Note: A more robust approach would register these as actual valid numpy types +# this is just a hack for now +numpy.dateA = DateSpec("Annual") +numpy.dateB = DateSpec("Business") +numpy.dateD = DateSpec("Daily") +numpy.dateH = DateSpec("Hourly") +numpy.dateM = DateSpec("Monthly") +numpy.dateQ = DateSpec("Quarterly") +numpy.dateS = DateSpec("Secondly") +numpy.dateT = DateSpec("Minutely") +numpy.dateW = DateSpec("Weekly") +numpy.dateU = DateSpec("Undefined") + + +freq_type_mapping = {'A': numpy.dateA, + 'B': numpy.dateB, + 'D': numpy.dateD, + 'H': numpy.dateH, + 'M': numpy.dateM, + 'Q': numpy.dateQ, + 'S': numpy.dateS, + 'T': numpy.dateT, + 'W': numpy.dateW, + 'U': numpy.dateU, + } + +def freqToType(freq): + return freq_type_mapping[fmtFreq(freq)] + +def isDateType(dtype): + #TODO: That looks messy. We should simplify that + if len([x for x in freq_type_mapping.values() if x == dtype]) > 0: + return True + else: + return False + +#####--------------------------------------------------------------------------- +#---- --- Misc functions --- +#####--------------------------------------------------------------------------- +#http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348 +def flatten_sequence(iterable): + """Flattens a compound of nested iterables.""" + itm = iter(iterable) + for elm in itm: + if hasattr(elm,'__iter__') and not isinstance(elm, basestring): + for f in flatten_sequence(elm): + yield f + else: + yield elm + +def flatargs(*args): + "Flattens the arguments." + if not hasattr(args, '__iter__'): + return args + else: + return flatten_sequence(args) + + Added: trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tdates.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tdates.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,1089 @@ +""" +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + +import datetime +import itertools +import warnings + + +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 maskedarray as MA +#reload(MA) + +import mx.DateTime as mxD +from mx.DateTime.Parser import DateFromString as mxDFromString + +import tscore as corelib +import cseries + + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) +daflog = logging.getLogger('darray_from') +dalog = logging.getLogger('DateArray') + +#####--------------------------------------------------------------------------- +#---- --- Date Info --- +#####--------------------------------------------------------------------------- +OriginDate = mxD.Date(1970) +secondlyOriginDate = OriginDate - mxD.DateTimeDeltaFrom(seconds=1) +minutelyOriginDate = OriginDate - mxD.DateTimeDeltaFrom(minutes=1) +hourlyOriginDate = OriginDate - mxD.DateTimeDeltaFrom(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 `mxDate` keyword with an existing mx.DateTime.DateTime object, or + even a datetime.datetime object. + + >>> td.Date('D', mxDate=mx.DateTime.now()) + >>> td.Date('D', mxDate=datetime.datetime.now()) + """ + def __init__(self, freq, year=None, month=None, day=None, quarter=None, + hours=None, minutes=None, seconds=None, + mxDate=None, value=None, string=None): + + if hasattr(freq, 'freq'): + self.freq = corelib.fmtFreq(freq.freq) + else: + self.freq = corelib.fmtFreq(freq) + self.type = corelib.freqToType(self.freq) + + if value is not None: + if self.freq == 'A': + self.mxDate = mxD.Date(value, -1, -1) + elif self.freq == 'B': + valtmp = (value - 1)//5 + self.mxDate = mxD.DateTimeFromAbsDateTime(value + valtmp*7 - valtmp*5) + elif self.freq in ['D','U']: + self.mxDate = mxD.DateTimeFromAbsDateTime(value) + elif self.freq == 'H': + self.mxDate = hourlyOriginDate + mxD.DateTimeDeltaFrom(hours=value) + elif self.freq == 'M': + self.mxDate = mxD.DateTimeFromAbsDateTime(1) + \ + mxD.RelativeDateTime(months=value-1, day=-1) + elif self.freq == 'Q': + self.mxDate = mxD.DateTimeFromAbsDateTime(1) + \ + mxD.RelativeDateTime(years=(value // 4), + month=((value * 3) % 12), day=-1) + elif self.freq == 'S': + self.mxDate = secondlyOriginDate + mxD.DateTimeDeltaFromSeconds(value) + elif self.freq == 'T': + self.mxDate = minutelyOriginDate + mxD.DateTimeDeltaFrom(minutes=value) + elif self.freq == 'W': + self.mxDate = mxD.Date(1,1,7) + \ + mxD.RelativeDateTime(weeks=value-1) +# mxD.RelativeDateTime(weeks=value-5./7-1) + + elif string is not None: + self.mxDate = mxDFromString(string) + + elif mxDate is not None: + if isinstance(mxDate, datetime.datetime): + mxDate = mxD.strptime(mxDate.isoformat()[:19], "%Y-%m-%dT%H:%M:%S") + self.mxDate = truncateDate(self.freq, mxDate) + + else: + # First, some basic checks..... + if year is None: + raise InsufficientDateError + if self.freq in ('B', 'D', 'W'): + if month is None or day is None: + raise InsufficientDateError + elif self.freq == 'M': + if month is None: + raise InsufficientDateError + day = -1 + elif self.freq == 'Q': + if quarter is None: + raise InsufficientDateError + month = quarter * 3 + day = -1 + elif self.freq == 'A': + month = -1 + day = -1 + elif self.freq == 'S': + if month is None or day is None or seconds is None: + raise InsufficientDateError + + if self.freq in ['A','B','D','M','Q','W']: + self.mxDate = truncateDate(self.freq, mxD.Date(year, month, day)) + if self.freq == 'B': + if self.mxDate.day_of_week in [5,6]: + raise ValueError("Weekend passed as business day") + elif self.freq in ['H','S','T']: + if not hours: + if not minutes: + if not seconds: + hours = 0 + else: + hours = seconds//3600 + else: + hours = minutes // 60 + if not minutes: + if not seconds: + minutes = 0 + else: + minutes = (seconds-hours*3600)//60 + if not seconds: + seconds = 0 + else: + seconds = seconds % 60 + self.mxDate = truncateDate(self.freq, + mxD.Date(year, month, day, + hours, minutes, seconds)) + self.value = self.__value() + # FIXME: Shall we set them as properties ? + def day(self): + "Returns the day of month." + return self.mxDate.day + def day_of_week(self): + "Returns the day of week." + return self.mxDate.day_of_week + def day_of_year(self): + "Returns the day of year." + return self.mxDate.day_of_year + def month(self): + "Returns the month." + return self.mxDate.month + def quarter(self): + "Returns the quarter." + return monthToQuarter(self.mxDate.month) + def year(self): + "Returns the year." + return self.mxDate.year + def second(self): + "Returns the seconds." + return int(self.mxDate.second) + def minute(self): + "Returns the minutes." + return int(self.mxDate.minute) + def hour(self): + "Returns the hour." + return int(self.mxDate.hour) + def week(self): + "Returns the week." + return self.mxDate.iso_week[1] + + def __add__(self, other): + if isinstance(other, Date): + raise FrequencyDateError("Cannot add dates", self.freq, other.freq) + 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.freq, other.freq) + 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 subtract dates", \ + self.freq, other.freq) + return int(self) == int(other) + + def __cmp__(self, other): + if not hasattr(other, 'freq'): + return False + elif self.freq != other.freq: + raise FrequencyDateError("Cannot subtract dates", \ + self.freq, other.freq) + 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.freq == 'A': + val = int(self.mxDate.year) + # Business days. + elif self.freq == 'B': + days = self.mxDate.absdate + weeks = days // 7 +# val = (weeks*5) + (days - weeks*7) + val = days - weeks*2 + # Daily/undefined + elif self.freq in ['D', 'U']: + val = self.mxDate.absdate + # Hourly........ + elif self.freq == 'H': + val = (self.mxDate - hourlyOriginDate).hours + # Monthly....... + elif self.freq == 'M': + val = (self.mxDate.year-1)*12 + self.mxDate.month + # Quarterly..... + elif self.freq == 'Q': + val = (self.mxDate.year-1)*4 + self.mxDate.month//3 + # Secondly...... + elif self.freq == 'S': + val = (self.mxDate - secondlyOriginDate).seconds + # Minutely...... + elif self.freq == 'T': + val = (self.mxDate - minutelyOriginDate).minutes + # Weekly........ + elif self.freq == 'W': + #val = int(self.mxDate.year*365.25/7.-1) + self.mxDate.iso_week[1] + val = self.mxDate.absdate//7 + return int(val) + #...................................................... + def default_fmtstr(self): + "Defines the default formats for printing Dates." + if self.freq == "A": + fmt = "%Y" + elif self.freq in ("B","D"): + fmt = "%d-%b-%y" + elif self.freq == "M": + fmt = "%b-%Y" + elif self.freq == "Q": + fmt = "%YQ%q" + elif self.freq == 'H': + fmt = "%d-%b-%Y %H:00" + elif self.freq == 'T': + fmt = "%d-%b-%Y %H:%M" + elif self.freq == "S": + fmt = "%d-%b-%Y %H:%M:%S" + elif self.freq == "W": + fmt = "%YW%W" + else: + fmt = "%d-%b-%y" + return fmt + + def strfmt(self, fmt): + "Formats the date" + qFmt = fmt.replace("%q", "XXXX") + tmpStr = self.mxDate.strftime(qFmt) + return tmpStr.replace("XXXX", str(self.quarter())) + + def __str__(self): + return self.strfmt(self.default_fmtstr()) + + def __repr__(self): + return "<%s : %s>" % (str(self.freq), str(self)) + #...................................................... + def toordinal(self): + "Returns the date as an ordinal." + return self.mxDate.absdays + + def fromordinal(self, ordinal): + "Returns the date as an ordinal." + return Date(self.freq, mxDate=mxD.DateTimeFromAbsDays(ordinal)) + + def tostring(self): + "Returns the date as a string." + return str(self) + + def toobject(self): + "Returns the date as itself." + return self + + def asfreq(self, toFreq, relation='before'): + """Converts the date to a new frequency.""" + return asfreq(self, toFreq, relation) + + 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 truncateDate(freq, mxDate): + """Chops off the irrelevant information from the mxDate passed in.""" + freq = corelib.fmtFreq(freq) + if freq == 'A': + return mxD.Date(mxDate.year) + elif freq == 'Q': + return mxD.Date(mxDate.year, monthToQuarter(mxDate.month)*3) + elif freq == 'M': + return mxD.Date(mxDate.year, mxDate.month) + elif freq == 'W': + d = mxDate.absdate + return mxD.DateTimeFromAbsDateTime(d + (7 - d % 7) % 7 - 1) + elif freq in ('B', 'D'): + if freq == 'B' and mxDate.day_of_week in [5,6]: + raise ValueError("Weekend passed as business day") + return mxD.Date(mxDate.year, mxDate.month, mxDate.day) + elif freq == 'H': + return mxD.Date(mxDate.year, mxDate.month, mxDate.day, \ + mxDate.hour) + elif freq == 'T': + return mxD.Date(mxDate.year, mxDate.month, mxDate.day, \ + mxDate.hour, mxDate.minute) + else: + return mxDate + +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.fmtFreq(freq) + tempDate = mxD.now() + # if it is Saturday or Sunday currently, freq==B, then we want to use Friday + if freq == 'B' and tempDate.day_of_week >= 5: + tempDate -= (tempDate.day_of_week - 4) + if freq in ('B','D','H','S','T','W'): + return Date(freq, mxDate=tempDate) + elif freq == 'M': + return Date(freq, year=tempDate.year, month=tempDate.month) + elif freq == 'Q': + return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) + elif freq == '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 = mxD.localtime() + 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.fmtFreq(toFreq) + _rel = relation.upper()[0] +# if _rel not in ['B', 'A']: +# msg = "Invalid relation '%s': Should be in ['before', 'after']" +# raise ValueError, msg % relation +# elif _rel == 'B': +# before = True +# else: +# before = False + +# if not isDateType(date): + if not isinstance(date, Date): + raise DateError, "Date should be a valid Date instance!" + + if date.freq == toFreq: + return date + else: + value = cseries.asfreq(numeric.asarray(date.value), date.freq, toFreq, _rel) + if value > 0: + return Date(freq=toFreq, value=value) + else: + return None +# # Convert to annual .................... +# elif toFreq == 'A': +# return Date(freq='A', year=date.year()) +# # Convert to quarterly ................. +# elif toFreq == 'Q': +# if date.freq == 'A': +# if before: +# return Date(freq='A', year=date.year(), quarter=1) +# else: +# return Date(freq='A', year=date.year(), quarter=4) +# else: +# return Date(freq='Q', year=date.year(), quarter=date.quarter()) +# # Convert to monthly.................... +# elif toFreq == 'M': +# if date.freq == 'A': +# if before: +# return Date(freq='M', year=date.year(), month=1) +# else: +# return Date(freq='M', year=date.year(), month=12) +# elif date.freq == 'Q': +# if before: +# return dateOf(date-1, 'M', "AFTER")+1 +# else: +# return Date(freq='M', year=date.year(), month=date.month()) +# else: +# return Date(freq='M', year=date.year(), month=date.month()) +# # Convert to weekly .................... +# elif toFreq == 'W': +# if date.freq == 'A': +# if before: +# return Date(freq='W', year=date.year(), month=1, day=1) +# else: +# return Date(freq='W', year=date.year(), month=12, day=-1) +# elif date.freq in ['Q','M']: +# if before: +# return dateOf(date-1, 'W', "AFTER")+1 +# else: +# return Date(freq='W', year=date.year(), month=date.month()) +# else: +# val = date.weeks() + int(date.year()*365.25/7.-1) +# return Date(freq='W', value=val) +# # Convert to business days.............. +# elif toFreq == 'B': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D'), 'B', "AFTER") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") +# elif date.freq == 'D': +# # BEFORE result: preceeding Friday if date is a weekend, same day otherwise +# # AFTER result: following Monday if date is a weekend, same day otherwise +# tempDate = date.mxDate +# if before: +# if tempDate.day_of_week >= 5: +# tempDate -= (tempDate.day_of_week - 4) +# else: +# if tempDate.day_of_week >= 5: +# tempDate += 7 - tempDate.day_of_week +# return Date(freq='B', mxDate=tempDate) +# else: +# if before: +# return dateOf(dateOf(date, 'D'), 'B', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D'), 'B', "AFTER") +# # Convert to day ....................... +# elif toFreq == 'D': +# # ...from annual +# if date.freq == 'A': +# if before: +# return Date(freq='D', year=date.year(), month=1, day=1) +# else: +# return Date(freq='D', year=date.year(), month=12, day=31) +# # ...from quarter +# elif date.freq == 'Q': +# if before: +# return dateOf(date-1, 'D', "AFTER")+1 +# else: +# return Date(freq='D', year=date.year(), month=date.month(), +# day=date.day()) +# # ...from month +# elif date.freq == 'M': +# if before: +# return Date(freq='D', year=date.year(), month=date.month(), day=1) +# else: +# (mm,yy) = (date.month(), date.year()) +# if date.month() == 12: +# (mm, yy) = (1, yy + 1) +# else: +# mm = mm + 1 +# return Date('D', year=yy, month=mm, day=1)-1 +# # ...from week +# elif date.freq == 'W': +# if before: +# return Date(freq='D', year=date.year(), month=date.month(), +# day=date.day()) +# else: +# ndate = date + 1 +# return Date(freq='D', year=ndate.year(), month=ndate.month(), +# day=ndate.day()) +# # ...from a lower freq +# else: +# return Date('D', year=date.year(), month=date.month(), day=date.day()) +# #Convert to hour........................ +# elif toFreq == 'H': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D', "BEFORE"), 'H', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'H', "AFTER") +# if date.freq in ['B','D']: +# if before: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=0) +# else: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=23) +# else: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=date.hour()) +# #Convert to second...................... +# elif toFreq == 'T': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D', "BEFORE"), 'T', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'T', "AFTER") +# elif date.freq in ['B','D','H']: +# if before: +# return Date(freq='T', year=date.year(), month=date.month(), +# day=date.day(), minutes=0) +# else: +# return Date(freq='T', year=date.year(), month=date.month(), +# day=date.day(), minutes=24*60-1) +# else: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=date.hour(), minutes=date.minute()) +# #Convert to minute...................... +# elif toFreq == 'S': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D', "BEFORE"), 'S', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'S', "AFTER") +# elif date.freq in ['B','D']: +# if before: +# return Date(freq='S', year=date.year(), month=date.month(), +# day=date.day(), seconds=0) +# else: +# return Date(freq='S', year=date.year(), month=date.month(), +# day=date.day(), seconds=24*60*60-1) + +def isDate(data): + "Returns whether `data` is an instance of Date." + return isinstance(data, Date) + + +#####--------------------------------------------------------------------------- +#---- --- DateArray --- +#####--------------------------------------------------------------------------- +ufunc_dateOK = ['add','subtract', + 'equal','not_equal','less','less_equal', 'greater','greater_equal', + 'isnan'] + +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. + """ + def __new__(cls, dates=None, freq='U', copy=False): + #dalog.info("__new__ received %s [%i]" % (type(dates), numpy.size(dates))) + if isinstance(dates, DateArray): + #dalog.info("__new__ sends %s as %s" % (type(dates), cls)) + cls.__defaultfreq = dates.freq + if not copy: + return dates.view(cls) + return dates.copy().view(cls) + else: + _dates = numeric.asarray(dates, dtype=int_) + if copy: + _dates = _dates.copy() + #dalog.info("__new__ sends %s as %s" % (type(_dates), cls)) + if freq is None: + freq = 'U' + cls.__defaultfreq = corelib.fmtFreq(freq) + (cls.__toobj, cls.__toord, cls.__tostr) = (None, None, None) + (cls.__steps, cls.__full, cls.__hasdups) = (None, None, None) + return _dates.view(cls) + + 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): + #dalog.info("__array_finalize__ received %s" % type(obj)) + if hasattr(obj, 'freq'): + self.freq = obj.freq + else: + self.freq = self.__defaultfreq + #dalog.info("__array_finalize__ sends %s" % type(self)) + + def __getitem__(self, index): + #dalog.info("__getitem__ got index %s (%s)"%(index, type(index))) + if isinstance(index, Date): + index = self.find_dates(index) + elif numeric.asarray(index).dtype.kind == 'O': + try: + index = self.find_dates(index) + except AttributeError: + pass + r = ndarray.__getitem__(self, index) + if r.size == 1: + # Only one element, and it's not a scalar: we have a DateArray of size 1 + if len(r.shape) > 0: + r = r.item() + return Date(self.freq, value=r) + else: + return r + + def __repr__(self): + return ndarray.__repr__(self) + #...................................................... + @property + def years(self): + "Returns the years." + return numeric.asarray([d.year() for d in self], dtype=int_) + @property + def months(self): + "Returns the months." + return numeric.asarray([d.month() for d in self], dtype=int_) + @property + def day_of_year(self): + "Returns the days of years." + return numeric.asarray([d.day_of_year() for d in self], dtype=int_) + yeardays = day_of_year + @property + def day_of_week(self): + "Returns the days of week." + return numeric.asarray([d.day_of_week() for d in self], dtype=int_) + #.... Conversion methods .................... +# def toobject(self): +# "Converts the dates from ordinals to Date objects." +# # Note: we better try to cache the result +# if self.__toobj is None: +## toobj = numeric.empty(self.size, dtype=object_) +## toobj[:] = [Date(self.freq, value=d) for d in self] +## self.__toobj = toobj +# self.__toobj = self +# return self.__toobj + # + 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.__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.__toord = toord + return self.__toord + # + def tostring(self): + "Converts the dates to strings." + # Note: we better cache the result + if self.__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.__tostr = tostr + return self.__tostr + # +# def asfreq_ini(self, freq=None): +# "Converts the dates to another frequency." +# # Note: As we define a new object, we don't need caching +# if freq is None: +# return self +# freq = corelib.fmtFreq(freq) +# if freq == self.freq: +# return self +# if self.isvalid(): +# new = numeric.arange(self.size, dtype=int_) +# new += self[0].asfreq(freq).value +# else: +# new = numpy.fromiter((d.asfreq(freq).value for d in self), +# dtype=float_) +# return DateArray(new, freq=freq) + + 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: + return self + freq = corelib.fmtFreq(freq) + if freq == self.freq: + return self + _rel = relation.upper()[0] + new = cseries.asfreq(numeric.asarray(self), self.freq, freq, _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 ValueError, "Date out of bounds!" + return c +# def find_dates_alt(self, *dates): +# "Returns the indices corresponding to given dates, as an array." +# ifreq = self.freq +# c = numpy.zeros(self.shape, bool_) +# dates = date_array([d for d in corelib.flatargs(*dates)]).asfreq(ifreq) +# for d in numeric.asarray(dates): +# c += (self == d) +# c = c.nonzero() +# if fromnumeric.size(c) == 0: +# raise ValueError, "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 ValueError, "Date out of bounds!" + return index + else: + index_asarray = (self == date.value).nonzero() + if fromnumeric.size(index_asarray) == 0: + raise ValueError, "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 daily!") + if self.__steps is None: + val = numeric.asarray(self).ravel() + if val.size > 0: + steps = val[1:] - val[:-1] + if self.__full is None: + self.__full = (steps.max() == 1) + if self.__hasdups is None: + self.__hasdups = (steps.min() == 0) + else: + self.__full = True + self.__hasdups = False + self.__steps = steps + return self.__steps + + def has_missing_dates(self): + "Returns whether the DateArray have missing dates." + if self.__full is None: + steps = self.get_steps() + return not(self.__full) + + def isfull(self): + "Returns whether the DateArray has no missing dates." + if self.__full is None: + steps = self.get_steps() + return self.__full + + def has_duplicated_dates(self): + "Returns whether the DateArray has duplicated dates." + if self.__hasdups is None: + steps = self.get_steps() + return self.__hasdups + + def isvalid(self): + "Returns whether the DateArray is valid: no missing/duplicated dates." + return (self.isfull() and not self.has_duplicated_dates()) + #...................................................... +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 + #dalog.info('__datearithmetics got method %s' % methodname) + # + 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' + #dalog.info('__datearithmetics got other %s' % type(other)) + method = getattr(super(DateArray,instance), self.methodname) + if isinstance(other, DateArray): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) +# other = + elif isinstance(other, Date): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) + other = other.value + #dalog.info('__datearithmetics got other %s' % type(other)) + 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) +#............................ +DateArray.__add__ = _datearithmetics('__add__', asdates=True) +DateArray.__radd__ = _datearithmetics('__add__', asdates=True) +DateArray.__sub__ = _datearithmetics('__sub__', asdates=True) +DateArray.__rsub__ = _datearithmetics('__rsub__', asdates=True) +DateArray.__le__ = _datearithmetics('__le__', asdates=False) +DateArray.__lt__ = _datearithmetics('__lt__', asdates=False) +DateArray.__ge__ = _datearithmetics('__ge__', asdates=False) +DateArray.__gt__ = _datearithmetics('__gt__', asdates=False) +DateArray.__eq__ = _datearithmetics('__eq__', asdates=False) +DateArray.__ne__ = _datearithmetics('__ne__', asdates=False) + +#####--------------------------------------------------------------------------- +#---- --- 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() + # Case #1: dates as strings ................. + if dlist.dtype.kind == 'S': + #...construct a list of ordinals + ords = numpy.fromiter((mxDFromString(s).absdays 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 ['i','f']: + #...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), float_) + #...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, mxDate=m) for m in dlist] + #...as datetime objects + elif hasattr(dlist[0], 'toordinal'): + ords = numpy.fromiter((d.toordinal() for d in dlist), float_) + if freq is None: + freq = guess_freq(ords) + dates = [Date(freq, mxDate=mxD.DateTimeFromAbsDays(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.fmtFreq(freq) + # Case #1: we have a list ................... + if dlist is not None: + # Already a DateArray.................... + if isinstance(dlist, DateArray): + if freq != dlist.freq: + return dlist.asfreq(freq) + else: + return dlist + return _listparser(dlist, freq) + # Case #2: we have a starting date .......... + if start_date is None: + raise InsufficientDateError +# if not isDateType(start_date): + if not isinstance(start_date, Date): + raise DateError, "Starting date should be a valid Date instance!" + # Check if we have an end_date + if end_date is None: + if length is None: + raise ValueError,"No length precised!" + else: + if not isinstance(end_date, Date): + raise DateError, "Ending date should be a valid Date instance!" +# assert(isDateType(end_date), +# "Starting date should be a valid Date instance!") + length = 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: + 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') + + +################################################################################ Added: trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tseries.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/build/lib.linux-x86_64-2.4/timeseries/tseries.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,1254 @@ +# 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. + +These two classes were liberally adapted from `MaskedArray` class. + + + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + + +import logging +import weakref + + +import numpy +from numpy.core import bool_, float_, int_ +import numpy.core.fromnumeric as fromnumeric +import numpy.core.numeric as numeric +import numpy.core.umath as umath +from numpy import ndarray +from numpy.core.records import recarray +from numpy.core.records import fromarrays as recfromarrays + +#from cPickle import dump, dumps + +import maskedarray as MA +#import numpy.core.ma as MA +reload(MA) +#MaskedArray = MA.MaskedArray +from maskedarray.core import MaskedArray +masked = MA.masked +nomask = MA.nomask +MAError = MA.MAError +masked_array = MA.masked_array +filled = MA.filled +getmask = MA.getmask +getmaskarray = MA.getmaskarray +make_mask_none = MA.make_mask_none +mask_or = MA.mask_or +make_mask = MA.make_mask + +oldma = (MA.__name__ == 'numpy.core.ma') + +import tscore as corelib +#reload(corelib) +from tscore import * + +import tdates +reload(tdates) +from tdates import DateError, InsufficientDateError +from tdates import Date, isDate, DateArray, isDateArray, \ + date_array, date_array_fromlist, date_array_fromrange, thisday + +import cseries +reload(cseries) + +#............................................................................... +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) +talog = logging.getLogger('log.TimeArray') +tslog = logging.getLogger('TimeSeries') +btslog = logging.getLogger('BaseTimeSeries') + +ufunc_domain = {} +ufunc_fills = {} + +#### -------------------------------------------------------------------------- +#--- ... TimeSeriesError class ... +#### -------------------------------------------------------------------------- +class TimeSeriesError(Exception): + "Class for TS related errors." + def __init__ (self, args=None): + "Creates an exception." + Exception.__init__(self) + self.args = args + def __str__(self): + "Calculates the string representation." + return str(self.args) + __repr__ = __str__ + +class TimeSeriesCompatibilityError(TimeSeriesError): + """Defines the exception raised when series are incompatible.""" + def __init__(self, mode, first, second): + if mode == 'freq': + msg = "Incompatible time steps! (%s <> %s)" + elif mode == 'start_date': + msg = "Incompatible starting dates! (%s <> %s)" + elif mode == 'size': + msg = "Incompatible sizes! (%s <> %s)" + msg = msg % (first, second) + TimeSeriesError.__init__(self, msg) + + +#def _compatibilitycheck(a, b): +def _timeseriescompat(a, b): + """Checks the date compatibility of two TimeSeries object. + Returns True if everything's fine, or raises an exception.""" + if not (hasattr(a,'freq') and hasattr(b, 'freq')): + return True + if a.freq != b.freq: + raise TimeSeriesCompatibilityError('freq', a.freq, b.freq) + elif a.start_date() != b.start_date(): + raise TimeSeriesCompatibilityError('start_date', + a.start_date(), b.start_date()) + elif (a._dates.get_steps() != b._dates.get_steps()).any(): + 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), + "2: %s" % str(b.shape)) + return True + +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.""" + # If there's only 1 element, the date is a Date object, which has no size... + tsize = numeric.size(dates) + dsize = data.size + # Only one data + if dsize == tsize: + return True + elif data.ndim > 1: + dsize = numeric.asarray(data.shape)[:-1].prod() + if dsize == tsize: + return True + raise TimeSeriesCompatibilityError('size', "data: %s" % dsize, + "dates: %s" % tsize) + +def _getdatalength(data): + "Estimates the length of a series (size/nb of variables)." + if numeric.ndim(data) >= 2: + return numeric.asarray(numeric.shape(data))[:-1].prod() + else: + return numeric.size(data) + +##### -------------------------------------------------------------------------- +##--- ... Time Series ... +##### -------------------------------------------------------------------------- +#if oldma: +# parentclass = ndarray +#else: +# parentclass = MaskedArray +# +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. + """ + def __new__(cls, data, dates=None, mask=nomask, + freq=None, observed=None, start_date=None, + dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False): + #tslog.info("__new__: received data types %s, %s" % (type(data), data)) + options = dict(copy=copy, dtype=dtype, fill_value=fill_value, + keep_mask=keep_mask, small_mask=small_mask, + hard_mask=hard_mask, ) + if isinstance(data, TimeSeries): + # Check dates ........ + if dates is None: + newdates = data._dates + else: + if not hasattr(dates,'freq'): + raise DateError, "Invalid Dates!" + newdates = dates + data._dates = newdates + if hasattr(data, '_data') and hasattr(data._data, '_dates'): + data._data._dates = newdates + cls._defaultdates = newdates + # Check frequency...... + if freq is not None: + freq = corelib.fmtFreq(freq) + if freq != newdates.freq: + _dates = newdates.tofreq(freq) + else: + freq = newdates.freq + # Check observed....... + if observed is not None: + observed = data._observed + cls._defaultobserved = observed + _data = data._series + else: + # Check dates ........ + if dates is None: + length = _getdatalength(data) + newdates = date_array(start_date=start_date, length=length, + freq=freq) + elif not hasattr(dates, 'freq'): + newdates = date_array(dlist=dates, freq=freq) + else: + newdates = dates + _data = data + if hasattr(data, '_mask') : + mask = mask_or(data._mask, mask) + cls._defaultdates = newdates + cls._defaultobserved = observed +# if oldma: +# newdata = MaskedArray(data, mask=mask, dtype=dtype, +# copy=copy,fill_value=fill_value) +# cls._defaultmask = newdata._mask +# cls._defaulthardmask = True +# cls._fill_value = newdata._fill_value +# assert(_datadatescompat(newdata,dates)) +# return ndarray.__new__(cls,shape=newdata.shape,dtype=newdata.dtype, +# buffer=newdata._data) +# _data = data +# newdata = MaskedArray.__new__(cls, data=_data, mask=mask, **options) + newdata = super(TimeSeries,cls).__new__(cls, _data, mask=mask, + **options) + assert(_datadatescompat(data,newdates)) + return newdata + + #.................................. + def __array_wrap__(self, obj, context=None): +# if oldma: +# tmpself = MaskedArray(self._data, mask=self._mask) +# return TimeSeries(MaskedArray.__array_wrap__(tmpself, obj, context), +# dates=self._dates) +# print "__array_wrap__" + return TimeSeries(super(TimeSeries,self).__array_wrap__(obj, context), + dates=self._dates) + #............................................ + def __array_finalize__(self,obj): + #tslog.info("__array_finalize__ received %s" % type(obj)) + if isinstance(obj, TimeSeries): + self._dates = obj._dates + self._data = obj._series._data + self._mask = obj._series._mask + self._series = obj._series + self._hardmask = obj._series._hardmask + self.observed = obj.observed + self._fill_value = obj._fill_value + else: + self._dates = self._defaultdates + self.observed = self._defaultobserved + self._series = MA.array(obj, mask=self._defaultmask, + copy=False, hard_mask=self._defaulthardmask) + self._mask = self._defaultmask + self._data = obj + self._hardmask = self._defaulthardmask + self.fill_value = self._fill_value + self._mask = self._series._mask + self._data = self._series._data + self._hardmask = self._series._hardmask + #tslog.info("__array_finalize__ sends %s" % type(self)) + return + #............................................ + def __getattribute__(self,attr): + "Returns a given attribute." + # Here, we need to be smart: _mask should call _series._mask... + if attr in ['_data','_mask','_hardmask']: + return getattr(self._series,attr) + return super(TimeSeries, self).__getattribute__(attr) + def __setattribute__(self,attr, value): + """Sets an attribute to a given value.""" + # Same thing here: if we modify ._mask, we need to modify _series._mask + # ...as well + super(TimeSeries, self).__setattribute__(attr, value) + if attr in ['_data','_mask','_hardmask']: + super(self._series.__class__, self._series).__setattribute__(attr, value) + setattr(self._series, attr, value) + #............................................ + def __checkindex(self, index): + "Checks the validity of an index." + if isinstance(index, int): + return index + if isinstance(index, str): + return self._dates.date_to_index(Date(self._dates.freq, string=index)) + elif isDate(index) or isDateArray(index): + return self._dates.date_to_index(index) + elif isinstance(index,slice): + slice_start = self.__checkindex(index.start) + slice_stop = self.__checkindex(index.stop) + return slice(slice_start, slice_stop, index.step) + elif isTimeSeries(index): + index = index._series + if getmask(index) is not nomask: + msg = "Masked arrays must be filled before they can be used as indices!" + raise IndexError, msg + return index + + def __getitem__(self, index): + """x.__getitem__(y) <==> x[y] +Returns the item described by i. Not a copy as in previous versions. + """ + index = self.__checkindex(index) + data = self._series[index] + date = self._dates[index] + m = self._mask + scalardata = (len(numeric.shape(data))==0) + # + if m is nomask: + if scalardata: + return TimeSeries(data, dates=date) + else: + return TimeSeries(data, dates=date, mask=nomask, keep_mask=True, + copy=False) + #.... + mi = m[index] + if mi.size == 1: + if mi: + return TimeSeries(data, dates=date, mask=True) + return TimeSeries(data, dates=date, mask=nomask) + else: + return TimeSeries(data, dates=date, mask=mi) + #........................ + def __setitem__(self, index, value): + """x.__setitem__(i, y) <==> x[i]=y +Sets item described by index. If value is masked, masks those locations. + """ + if self is masked: + raise MAError, 'Cannot alter the masked element.' + index = self.__checkindex(index) + #.... + if isinstance(value, TimeSeries): + assert(_timeseriescompat(self[index], value)) + self._series[index] = value._series + else: + self._series[index] = value + # Don't forget to update the mask ! + self._mask = self._series._mask + + #........................ + def __getslice__(self, i, j): + "Gets slice described by i, j" + i = self.__checkindex(i) + j = self.__checkindex(j) + (data, date) = (self._series[i:j], self._dates[i:j]) + return TimeSeries(data, dates=date, copy=False) + #.... + def __setslice__(self, i, j, value): + "Gets item described by i. Not a copy as in previous versions." + i = self.__checkindex(i) + j = self.__checkindex(j) + #.... + data = self._series[i:j] + if isinstance(value, TimeSeries): + assert(_timeseriescompat(self[i:j], value)) + self._series[i:j] = value._series + else: + self._series[i:j] = value + # Don't forget to update the mask ! + self._mask = self._series._mask + #...................................................... + def __len__(self): + if self.ndim == 0: + return 0 + return ndarray.__len__(self) + #...................................................... + def __str__(self): + """Returns a string representation of self (w/o the dates...)""" + return str(self._series) + def __repr__(self): + """Calculates the repr representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + desc = """\ +timeseries(data = + %(data)s, + dates = + %(time)s, + freq = %(freq)s) +""" + desc_short = """\ +timeseries(data = %(data)s, + dates = %(time)s, + freq = %(freq)s) +""" + if numeric.size(self._dates) > 2 and self.isvalid(): + timestr = "[%s ... %s]" % (str(self._dates[0]),str(self._dates[-1])) + else: + timestr = str(self.dates) + + if self.ndim <= 1: + return desc_short % {'data': str(self._series), + 'time': timestr, + 'freq': self.freq, } + return desc % {'data': str(self._series), + 'time': timestr, + 'freq': self.freq, } + #............................................ + def _get_mask(self): + """Returns the current mask.""" + return self._series._mask + def _set_mask(self, mask): + """Sets the mask to `mask`.""" + mask = make_mask(mask, copy=False, small_mask=True) + if mask is not nomask: + if mask.size != self._data.size: + raise ValueError, "Inconsistent shape between data and mask!" + if mask.shape != self._data.shape: + mask.shape = self._data.shape + self._series._mask = mask + else: + self._series._mask = nomask + mask = property(fget=_get_mask, fset=_set_mask, doc="Mask") + + def ids (self): + """Return the ids of the data, dates and mask areas""" + return (id(self._series), id(self.dates),) + + def copy(self): + "Returns a copy of the TimeSeries." + return TimeSeries(self, copy=True) + + #------------------------------------------------------ + @property + def series(self): + "Returns the series." + return self._series + @property + def dates(self): + """Returns the dates""" + return self._dates + @property + def freq(self): + """Returns the corresponding frequency.""" + return self._dates.freq +# @property + def years(self): + """Returns the corresponding years.""" + return self._dates.years +# @property + def months(self): + """Returns the corresponding months.""" + return self._dates.months +# @property + def yeardays(self): + """Returns the corresponding days of year.""" + return self._dates.yeardays + day_of_year = yeardays +# @property + def weekdays(self): + """Returns the corresponding days of weeks.""" + return self._dates.day_of_week + day_of_week = weekdays + + def start_date(self): + """Returns the first date of the series.""" + return self._dates[0] +# + def end_date(self): + """Returns the last date of the series.""" + return self._dates[-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) + #..................................................... + 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', interp=None): + "Converts the dates to another frequency, and adapt the data." + return convert(self, freq, func=func, position=position, interp=interp) + +##### -------------------------------------------------------------------------- +##--- ... Additional methods ... +##### -------------------------------------------------------------------------- +class _inplacemethod(object): + """Defines a wrapper for inplace arithmetic array methods (iadd, imul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + self.obj = None + # + def __get__(self, obj, objtype=None): + "Gets the calling object." + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + assert(_timeseriescompat(instance,other)) + func = getattr(instance._series, self.f) + func(other, *args) + return instance +#...................................... +TimeSeries.__iadd__ = _inplacemethod('__iadd__') +TimeSeries.__iand__ = _inplacemethod('__iand__') +TimeSeries.__idiv__ = _inplacemethod('__idiv__') +TimeSeries.__isub__ = _inplacemethod('__isub__') +TimeSeries.__imul__ = _inplacemethod('__imul__') + + +class _tsmathmethod(object): + """Defines a wrapper for arithmetic array methods (add, mul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + # + def __get__(self, obj, objtype=None): + "Gets the calling object." + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + _dates = instance._dates + #tslog.info("_tsmathmethod: series: %s" % instance,) + #tslog.info("_tsmathmethod: other : %s" % other,) + func = getattr(instance._series, self.f) + if isinstance(other, TimeSeries): + assert(_timeseriescompat(instance, other)) + return instance.__class__(func(other, *args), dates=_dates,) +#...................................... +TimeSeries.__add__ = _tsmathmethod('__add__') +TimeSeries.__radd__ = _tsmathmethod('__add__') +TimeSeries.__sub__ = _tsmathmethod('__sub__') +TimeSeries.__rsub__ = _tsmathmethod('__rsub__') +TimeSeries.__pow__ = _tsmathmethod('__pow__') +TimeSeries.__mul__ = _tsmathmethod('__mul__') +TimeSeries.__rmul__ = _tsmathmethod('__mul__') +TimeSeries.__div__ = _tsmathmethod('__div__') +TimeSeries.__rdiv__ = _tsmathmethod('__rdiv__') +TimeSeries.__truediv__ = _tsmathmethod('__truediv__') +TimeSeries.__rtruediv__ = _tsmathmethod('__rtruediv__') +TimeSeries.__floordiv__ = _tsmathmethod('__floordiv__') +TimeSeries.__rfloordiv__ = _tsmathmethod('__rfloordiv__') +TimeSeries.__eq__ = _tsmathmethod('__eq__') +TimeSeries.__ne__ = _tsmathmethod('__ne__') +TimeSeries.__lt__ = _tsmathmethod('__lt__') +TimeSeries.__le__ = _tsmathmethod('__le__') +TimeSeries.__gt__ = _tsmathmethod('__gt__') +TimeSeries.__ge__ = _tsmathmethod('__ge__') +#................................................ +class _tsarraymethod(object): + """Defines a wrapper for basic array methods. +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +If `ondates` is True, the same operation is performed on the `_dates`. +If `ondates` is False, the `_dates` part remains unchanged. + """ + def __init__ (self, methodname, ondates=False): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + self._ondates = ondates + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args): + "Execute the call behavior." + _name = self._name + instance = self.obj + func_series = getattr(instance._series, _name) + if self._ondates: + func_dates = getattr(instance._dates, _name) + return instance.__class__(func_series(*args), + dates=func_dates(*args)) + else: + return instance.__class__(func_series(*args), + dates=instance._dates) +#TimeSeries.astype = _tsarraymethod('astype') +TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) +TimeSeries.copy = _tsarraymethod('copy', ondates=True) +TimeSeries.compress = _tsarraymethod('compress', ondates=True) +TimeSeries.ravel = _tsarraymethod('ravel', ondates=True) +TimeSeries.filled = _tsarraymethod('filled', ondates=False) +TimeSeries.cumsum = _tsarraymethod('cumsum',ondates=False) +TimeSeries.cumprod = _tsarraymethod('cumprod',ondates=False) +TimeSeries.anom = _tsarraymethod('anom',ondates=False) + +#...................................... +class _tsaxismethod(object): + """Defines a wrapper for array methods working on an axis (mean...). +When called, returns a ndarray, as the result of the method applied on the series. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + "Execute the call behavior." + (_dates, _series) = (self.obj._dates, self.obj._series) + func = getattr(_series, self._name) + result = func(*args, **params) + if _series.ndim < 2 or _dates.size == _series.size: + return result + else: + try: + axis = params.get('axis', args[0]) + if axis in [-1, _series.ndim-1]: + result = TimeSeries(result, dates=_dates) + except IndexError: + pass + return result +#....................................... +TimeSeries.sum = _tsaxismethod('sum') +TimeSeries.prod = _tsaxismethod('prod') +TimeSeries.mean = _tsaxismethod('mean') +TimeSeries.var = _tsaxismethod('var') +TimeSeries.varu = _tsaxismethod('varu') +TimeSeries.std = _tsaxismethod('std') +TimeSeries.stdu = _tsaxismethod('stdu') + +class _tsblockedmethods(object): + """Defines a wrapper for array methods that should be temporarily disabled. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + raise NotImplementedError +TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) +TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) + + +#####--------------------------------------------------------------------------- +#---- --- 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(TimeSeries, self._methodname).__doc__ + except: + 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') +# +##### --------------------------------------------------------------------------- +#---- ... Additional methods ... +##### --------------------------------------------------------------------------- +def tofile(self, output, sep='\t', format_dates=None): + """Writes the TimeSeries to a file. + +:Parameters: + - `output` (String) : Name or handle of the output file. + - `sep` (String) : Column separator *['\t']*. + - `format` (String) : Data format *['%s']*. + """ + if not hasattr(output, 'writeline'): + ofile = open(output,'w') + else: + ofile = output + 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(), + filled(self)): + ofile.write('%s\n' % sep.join([oformat % (_dates, _data) ])) + ofile.close() +TimeSeries.tofile = tofile + +#............................................ +def asrecords(series): + """Returns the masked time series as a recarray. +Fields are `_dates`, `_data` and _`mask`. + """ + desctype = [('_dates',int_), ('_series',series.dtype), ('_mask', bool_)] + flat = series.ravel() + _dates = numeric.asarray(flat._dates) + if flat.size > 0: + return recfromarrays([_dates, flat._data, getmaskarray(flat)], + dtype=desctype, + shape = (flat.size,), + ) + else: + return recfromarrays([[], [], []], dtype=desctype, + shape = (flat.size,), + ) +TimeSeries.asrecords = asrecords + +def flatten(series): + """Flattens a (multi-) time series to 1D series.""" + shp_ini = series.shape + # Already flat time series.... + if len(shp_ini) == 1: + return series + # Folded single time series .. + newdates = series._dates.ravel() + if series._dates.size == series._series.size: + newshape = (series._series.size,) + else: + newshape = (numeric.asarray(shp_ini[:-1]).prod(), shp_ini[-1]) + newseries = series._series.reshape(newshape) + return time_series(newseries, newdates) +TimeSeries.flatten = flatten + + + +#####--------------------------------------------------------------------------- +#---- --- Archiving --- +#####--------------------------------------------------------------------------- +def _tsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): + """Internal function that builds a new TimeSeries from the information stored +in a pickle.""" +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + _series = ndarray.__new__(ndarray, baseshape, basetype) + _dates = ndarray.__new__(datesclass, baseshape, int_) + _mask = ndarray.__new__(ndarray, baseshape, bool_) + return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, + dtype=basetype, fill_value=fill_value) +# +def _tsgetstate(a): + "Returns the internal state of the TimeSeries, for pickling purposes." +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + records = a.asrecords() + state = (1, + a.shape, + a.dtype, + a.freq, + records.flags.fnc, + a.fill_value, + records + ) + return state +# +def _tssetstate(a, 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 + - a binary string for the data + - a binary string for the mask. + """ + (ver, shp, typ, frq, isf, flv, rec) = state + a.fill_value = flv + a._dates = a._dates.__class__(rec['_dates'], freq=frq) + (a._dates).__tostr = None + _data = rec['_series'].view(typ) + _mask = rec['_mask'].view(MA.MaskType) + a._series = masked_array(_data, mask=_mask) +# a._data.shape = shp +# a._dates.shape = shp +# a._mask = rec['_mask'].view(MA.MaskType) +# a._mask.shape = shp +# +def _tsreduce(a): + """Returns a 3-tuple for pickling a MaskedArray.""" + return (_tsreconstruct, + (a.__class__, a.dates.__class__, (0,), 'b', -9999), + a.__getstate__()) +# +TimeSeries.__getstate__ = _tsgetstate +TimeSeries.__setstate__ = _tssetstate +TimeSeries.__reduce__ = _tsreduce +#TimeSeries.__dump__ = dump +#TimeSeries.__dumps__ = dumps + + +##### ------------------------------------------------------------------------- +#---- --- TimeSeries creator --- +##### ------------------------------------------------------------------------- +def time_series(data, dates=None, freq=None, observed=None, + start_date=None, end_date=None, length=None, include_last=True, + mask=nomask, + 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` : + Array of data. + """ + if dates is None: + length = _getdatalength(data) + dates = date_array(start_date=start_date, end_date=end_date, + length=length, include_last=include_last, 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, + hard_mask=hard_mask,) + + +def isTimeSeries(series): + "Returns whether the series is a valid TimeSeries object." + return isinstance(series, TimeSeries) + +##### -------------------------------------------------------------------------- +#---- ... Additional functions ... +##### -------------------------------------------------------------------------- +def mask_period(data, start_date=None, end_date=None, + inside=True, include_edges=True, inplace=True): + """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 + `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]* + Whether the dates inside the range should be masked. If not, masks outside. + `include_edges` : Boolean *[True]* + Whether the starting and ending dates should be masked. + `inplace` : Boolean *[True]* + Whether the data mask should be modified in place. If not, returns a new + TimeSeries. +""" + if not isTimeSeries(data): + raise ValueError,"Data should be a valid TimeSeries!" + # Check the starting date .............. + if start_date is None: + start_date = data._dates[0] + elif isinstance(start_date, str): + start_date = Date(data.freq, string=start_date) + elif not isDateType(start_date): + raise DateError,"Starting date should be a valid date!" + start_date = max(start_date, data.dates[0]) + # Check the ending date ................ + if end_date is None: + end_date = data._dates[-1] + elif isinstance(end_date, str): + end_date = Date(data.freq, string=end_date) + elif not isDateType(end_date): + raise DateError,"Starting date should be a valid date!" + end_date = min(end_date, data.dates[-1]) + # Constructs the selection mask ......... + if inside: + if include_edges: + selection = (data.dates >= start_date) & (data.dates <= end_date) + else: + selection = (data.dates > start_date) & (data.dates < end_date) + else: + if include_edges: + selection = (data.dates <= start_date) | (data.dates >= end_date) + 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 + else: + return TimeSeries(data, mask=selection, keep_mask=True) + return data + +def mask_inside_period(data, start_date=None, end_date=None, + include_edges=True, inplace=True): + """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): + """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) +#.......................................................... +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, + the new series is NOT a copy. + """ + # Series validity tests ..................... + if not isinstance(a, TimeSeries): + raise TypeError,"Argument should be a valid TimeSeries object!" + if a.freq == 'U': + raise TimeSeriesError, \ + "Cannot adjust a series with 'Undefined' frequency." + if not a.dates.isvalid(): + raise TimeSeriesError, \ + "Cannot adjust a series with missing or duplicated dates." + # Flatten the series if needed .............. + a = a.flatten() + shp_flat = a.shape + # Dates validity checks .,................... + msg = "%s should be a valid Date instance! (got %s instead)" + (dstart, dend) = a.dates[[0,-1]] + if start_date is None: + start_date = dstart + start_lag = 0 + else: + if not isDateType(start_date): + raise TypeError, msg % ('start_date', type(start_date)) + start_lag = start_date - dstart + #.... + if end_date is None: + end_date = dend + end_lag = 0 + else: + if not isDateType(end_date): + raise TypeError, msg % ('end_date', type(end_date)) + end_lag = end_date - dend + # Check if the new range is included in the old one + if start_lag >= 0: + if end_lag == 0: + return a[start_lag:] + elif end_lag < 0: + 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) + + newdata = masked_array(numeric.empty(newshape, dtype=a.dtype), mask=True) + newseries = TimeSeries(newdata, newdates) + start_date = max(start_date, dstart) + end_date = min(end_date, dend) + 1 + newseries[start_date:end_date] = a[start_date:end_date] + return newseries +#.................................................................... +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. + """ + if len(series) < 2: + return series + unique_freqs = numpy.unique([x.freq for x in series]) + try: + common_freq = unique_freqs.item() + except ValueError: + raise TimeSeriesError, \ + "All series must have same frequency!" + if common_freq == 'U': + raise TimeSeriesError, \ + "Cannot adjust a series with 'Undefined' frequency." + 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])) + if isinstance(start_date,str): + start_date = Date(common_freq, string=start_date) + end_date = kwargs.pop('end_date', max([x.end_date() for x in series])) + 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', interp=None): + """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 + appropriate function is determined based on the observed attribute + 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 + placed at the end of the month). Interp is the method that will be used + to fill in the gaps. Valid values are "CUBIC", "LINEAR", "CONSTANT", "DIVIDED", + and None. + + Note: interp currently not implemented + """ + if not isinstance(series,TimeSeries): + raise TypeError, "The argument should be a valid TimeSeries!" + if not series.isvalid(): + raise TimeSeriesError, \ + "Cannot adjust a series with missing or duplicated dates." + + if position.upper() not in ('END','START'): + raise ValueError("invalid value for position argument: (%s)",str(position)) + + toFreq = corelib.fmtFreq(freq) + fromFreq = series.freq + start_date = series._dates[0] + + if fromFreq == toFreq: + return series.copy() + + if series.size == 0: + return TimeSeries(series, freq=toFreq, + start_date=start_date.asfreq(toFreq)) + if func == 'auto': + func = corelib.obs_dict[series.observed] + + tempData = series._series.filled() + tempMask = getmaskarray(series) + + cRetVal = cseries.reindex(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: + tempData = MA.apply_along_axis(func, -1, tempData) + +# newEnd = series._dates[-1].asfreq(toFreq, "AFTER") + + newseries = TimeSeries(tempData, freq=toFreq, + observed=series.observed, + start_date=start_date) + return newseries +# return adjust_endpoints(newseries, end_date=newEnd) +TimeSeries.convert = convert +#.................................................................... +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 +`fill_value`. + +:Parameters: + `data` + Initial array of data. + `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 = corelib.fmtFreq(freq) + if freq == 'U': + raise ValueError,\ + "Unable to define a proper date resolution (found %s)." % freq + if dates is None: + if not isTimeSeries(data): + raise InsufficientDateError + dates = data._dates + freq = dates.freq + datad = data._series._data + datam = data._series._mask +# if fill_value is None: +# fill_value = data._fill_value + elif not isinstance(dates, DateArray): + dates = DateArray(dates, freq) + if isinstance(data, MaskedArray): + datad = data._data + datam = data._mask + else: + datad = data + datam = nomask + dflat = dates.asfreq(freq).ravel() + n = len(dflat) + if not dflat.has_missing_dates(): + return time_series(data, dflat) + + # ...and now, fill it ! ...... + (tstart, tend) = dflat[[0,-1]] + newdates = date_array(start_date=tstart, end_date=tend, include_last=True) + nsize = newdates.size + #............................. + # 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) for (i,e) in numpy.broadcast(slcid[:-1],slcid[1:])]) + addidx = delta[gap].astype(int_).cumsum() + newslc = numpy.r_[[oldslc[0]], + [slice(i+d,e+d) for (i,e,d) in \ + numpy.broadcast(slcid[1:-1],slcid[2:],addidx)] + ] + #............................. + # Just a quick check + vdflat = numeric.asarray(dflat) + vnewdates = numeric.asarray(newdates) + for (osl,nsl) in zip(oldslc,newslc): + assert numpy.equal(vdflat[osl],vnewdates[nsl]).all(),\ + "Slicing mishap ! Please check %s (old) and %s (new)" % (osl,nsl) + #............................. + data = MA.asarray(data) + newdatad = numeric.empty(nsize, data.dtype) + newdatam = numeric.ones(nsize, bool_) +# if fill_value is None: +# if hasattr(data,'fill_value'): +# fill_value = data.fill_value +# else: +# fill_value = MA.default_fill_value(data) + #data = data.filled(fill_value) + #.... + if datam is nomask: + for (new,old) in zip(newslc,oldslc): + newdatad[new] = datad[old] + newdatam[new] = False + else: + 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) + # Get new shape .............. + if data.ndim == 1: + nshp = (newdates.size,) + else: + nshp = tuple([-1,] + list(data.shape[1:])) + return time_series(newdata.reshape(nshp), newdates) + + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + from maskedarray.testutils import assert_equal + if 0: + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array(dlist) + data = masked_array(numeric.arange(15, dtype=float_), mask=[1,0,0,0,0]*3) +# btseries = BaseTimeSeries(data._data, dates) + tseries = time_series(data, dlist) + dseries = numpy.log(tseries) + if 1: + mlist = ['2005-%02i' % i for i in range(1,13)] + mlist += ['2006-%02i' % i for i in range(1,13)] + mdata = numpy.arange(24) + mser1 = time_series(mdata, mlist, observed='SUMMED') + # + mlist2 = ['2004-%02i' % i for i in range(1,13)] + mlist2 += ['2005-%02i' % i for i in range(1,13)] + mser2 = time_series(mdata, mlist2, observed='SUMMED') + # + today = thisday('m') + (malg1,malg2) = aligned(mser1, mser2) + + C = convert(mser2,'A') + D = convert(mser2,'A',func=None) + + if 0: + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array(dlist) + print "."*50+"\ndata" + data = masked_array(numeric.arange(15)-6, mask=[1,0,0,0,0]*3) + print "."*50+"\nseries" + tseries = time_series(data, dlist) + + if 1: + dlist_1 = ['2007-01-%02i' % i for i in range(1,8)] + dlist_2 = ['2007-01-%02i' % i for i in numpy.arange(1,28)[::4]] + data = masked_array(numeric.arange(7), mask=[1,0,0,0,0,0,0]) + tseries_1 = time_series(data, dlist_1) + tseries_2 = time_series(data, dlist_2) + tseries_3 = time_series(data[::-1], dlist_2) + + try: + tseries = tseries_1 + tseries_2 + except TimeSeriesCompatibilityError: + print "I knew it!" + tseries = tseries_2 + tseries_3 + assert_equal(tseries._dates, tseries_3._dates) + assert_equal(tseries._mask, [1,0,0,0,0,0,1]) + + if 1: + mser3 = time_series(MA.mr_[malg1._series, 100+malg2._series].reshape(2,-1).T, + dates=malg1.dates) + data = mser3._series._data + Deleted: trunk/Lib/sandbox/timeseries/corelib.py =================================================================== --- trunk/Lib/sandbox/timeseries/corelib.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/corelib.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -1,181 +0,0 @@ -import numpy -from numpy import ma - - -############################################################# -############## generally applicable functions ############### -############################################################# -def apply_along_axis(func1d, axis, arr, *args): - """ Execute func1d(arr[i],*args) where func1d takes 1-D arrays - and arr is an N-d array. i varies so as to apply the function - along the given axis for each 1-d subarray in arr. - - Slightly modified version of the standard numpy version to work with masked arrays. - """ - - nd = arr.ndim - if axis < 0: - axis += nd - if (axis >= nd): - raise ValueError("axis must be less than arr.ndim; axis=%d, rank=%d." - % (axis,nd)) - ind = [0]*(nd-1) - i = numpy.zeros(nd,'O') - indlist = range(nd) - indlist.remove(axis) - i[axis] = slice(None,None) - outshape = numpy.asarray(arr.shape).take(indlist) - i.put(indlist, ind) - res = func1d(arr[tuple(i.tolist())],*args) - # if res is a number, then we have a smaller output array - if not hasattr(res,'shape') or len(res.shape) == 0: - outarr = ma.zeros(outshape,ma.asarray(res).dtype) - outarr[ind] = res - Ntot = numpy.product(outshape) - k = 1 - while k < Ntot: - # increment the index - ind[-1] += 1 - n = -1 - while (ind[n] >= outshape[n]) and (n > (1-nd)): - ind[n-1] += 1 - ind[n] = 0 - n -= 1 - i.put(indlist,ind) - res = func1d(arr[tuple(i.tolist())],*args) - outarr[ind] = res - k += 1 - return outarr - else: - Ntot = numpy.product(outshape) - holdshape = outshape - outshape = list(arr.shape) - outshape[axis] = len(res) - outarr = ma.zeros(outshape,ma.asarray(res).dtype) - outarr[tuple(i.tolist())] = res - k = 1 - while k < Ntot: - # increment the index - ind[-1] += 1 - n = -1 - while (ind[n] >= holdshape[n]) and (n > (1-nd)): - ind[n-1] += 1 - ind[n] = 0 - n -= 1 - i.put(indlist, ind) - res = func1d(arr[tuple(i.tolist())],*args) - outarr[tuple(i.tolist())] = res - k += 1 - return outarr - - -def first_unmasked(m): - return __unmasked(m, False, 0) - -def last_unmasked(m): - return __unmasked(m, False, -1) - -def first_unmasked_val(m): - return __unmasked(m, True, 0) - -def last_unmasked_val(m): - return __unmasked(m, True, -1) - - -def __unmasked(m, get_val, relpos): - - if m.mask is ma.nomask: - return 0 - else: - idx = numpy.where(m.mask == False) - if len(idx) != 0 and len(idx[0]) != 0: - idx = idx[0][relpos] - else: - idx = None - - if get_val: - if idx is None: return ma.masked - else: return m[idx] - else: - return idx -############################################################# - -#converts possible strings for frequency into acceptable values -def fmtFreq (freqStr): - if freqStr is None: - return None - elif freqStr.upper() in ("A","ANNUAL","B","BUSINESS","D","DAILY","M","MONTHLY","Q","QUARTERLY","S","SECONDLY"): - return freqStr[0].upper() - else: - raise ValueError("Invalid frequency: "+str(freqStr)) - - -obsDict = { - "UNDEFINED":None, - "BEGINNING":first_unmasked_val, - "END":last_unmasked_val, - "AVERAGED":ma.average, - "SUMMED":ma.sum, - "MAXIMUM":ma.maximum, - "MINIMUM":ma.minimum - } - -#converts possible strings for observed into acceptable values -def fmtObserv(obStr): - - obsVals = list(obsDict) - - if obStr is None: - return None - elif obStr.upper() in obsVals: - return obStr.upper() - elif obStr.upper() in ("UNDEFINED", "BEGIN", "END", "AVERAGE", "SUM", "MAX", "MIN"): - obStr = obStr.upper() - for x in obsVals: - if obStr[:2] == x[:2]: - return x - else: - raise ValueError("Invalid value for observed attribute: "+str(obStr)) - -def freqToType(freq): - return freqTypeMapping[fmtFreq(freq)] - - -# fake data type for date variables -class DateSpec: - def __init__(self, freq): - self.freq = fmtFreq(freq) - - def __hash__(self): return hash(self.freq) - - def __eq__(self, other): - if hasattr(other, "freq"): return self.freq == other.freq - else: return False - - def __str__(self): return "Date(" + str(self.freq) + ")" - - - -# define custom numpy types. -# Note: A more robust approach would register these as actual valid numpy types -# this is just a hack for now -numpy.dateS = DateSpec("Secondly") -numpy.dateD = DateSpec("Daily") -numpy.dateB = DateSpec("Business") -numpy.dateM = DateSpec("Monthly") -numpy.dateQ = DateSpec("Quarterly") -numpy.dateA = DateSpec("Annual") - -freqTypeMapping = { - 'S':numpy.dateS, - 'D':numpy.dateD, - 'B':numpy.dateB, - 'M':numpy.dateM, - 'Q':numpy.dateQ, - 'A':numpy.dateA -} - -def isDateType(dtype): - if len([x for x in (numpy.dateS,numpy.dateD,numpy.dateB,numpy.dateM,numpy.dateQ,numpy.dateA) if x == dtype]) > 0: return True - else: return False - Property changes on: trunk/Lib/sandbox/timeseries/examples ___________________________________________________________________ Name: svn:ignore + example_alt.py Modified: trunk/Lib/sandbox/timeseries/examples/example.py =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -1,147 +1,290 @@ -import numpy as np -import timeseries as ts -from numpy import ma - - -# create a time series at business frequency and fill it with random data -bSer = ts.TimeSeries(np.random.uniform(-100,100,600),dtype=np.float64,freq='B',observed='SUMMED',start_date=ts.thisday('B')-600) - - -# Set negative values to zero. -bSer[bSer < 0] = 0 - - -# Set values occurring on Fridays to 100. -weekdays = ts.day_of_week(ts.tser(bSer.start_date(),bSer.end_date())) -bSer[weekdays == 4] = 100 - - -""" -Convert bSer to a monthly frequency series. - -The optional func argument to the convert method specifies is a -function that acts on a 1-dimension masked array and returns a single -value. -""" -mSer1 = bSer.convert('M',func=ts.average) - - -""" -If func is None, a "2 dimensional" time series will be returned. In this -example, the value for each month will be a length 23 masked array (23 -being the max number of business days in a month) -""" -mSer1_2d = bSer.convert('M',func=None) - - -""" -If func is not specified, the observed attribute of the series -will be used to determine the method. (SUMMED for this example) -""" -mSer1_default = bSer.convert('M') - - -""" -Convert mSer to a business frequency series. - -when converting from a lower frequency to a higher frequency, position is one -of 'START' or 'END', and determines where the data point will be placed in the -period. In the future, interpolation methods will be supported to fill in the -resulting masked values. -""" -mToB = bSer.convert('M',position='START') - - -# create another monthly frequency series -mSer2 = ts.TimeSeries(np.random.uniform(-100,100,100),dtype=np.float64,freq='m',observed='END',start_date=ts.thisday('M')-110) - - -""" -Slicing also supported. The intention is to have indexing behave -largely in the same manner as regular numpy arrays. - -series.adjust_date convert a date object into the corresponding -integer for indexing the series -""" -sixtyMonthsAgoIdx = mSer2.date_to_index(ts.thisday('m')-60) -mSer2[sixtyMonthsAgoIdx:sixtyMonthsAgoIdx+10] = 12 - - -# Mask the last value in the series -mSer2[-1] = ts.masked #ts.masked is the same thing as numpy.ma.masked - - -# dates can be used as indices as well -mSer2[ts.thisday('m')-55] = 400 - - -""" -the tser function makes it easy to index a series over a range of dates -without worrying about converting the dates to appropriate integers first -""" -mSer2[ts.tser(ts.thisday('m')-59, ts.thisday('m')-45)] = 25 - - -""" -Only series of the same frequency and size and same start date -can be used in the basic operations. - -The results are the same as you would expect for masked arrays with the -basic operations. - -start_date and end_date are optional parameters to the aligned function. -If omitted, the min start_date() and end_date() of all series is used as -the new boundaries for each series. -""" -mSer1, mSer2 = ts.aligned(mSer1, mSer2, start_date=ts.thisday('m')-100, end_date=ts.thisday('m')) -mAdd1 = mSer1 + mSer2 - - -# add the two series together, first filling in masked values with zeros -mAdd1_filled = mSer1.filled(fill_value=0, ts=True) + mSer2.filled(fill_value=0, ts=True) - -# adjust the start and end dates of a series -newSer = ts.adjust_endpoints(mSer1, start_date=ts.Date(freq='M', year=1954, month=5), end_date=ts.Date(freq='M', year=2000, month=6)) - -# calculate the average value in the series. Behaves the same as in ma -bAverage = ts.average(bSer) - - -# Take the sqrt root of each element in the series (returns a TimeSeries object). -# Not all functions from ma supported yet, but they are easy to implement -# for the most part. -bSqrt = ts.sqrt(bSer) - - -# get the last day of this year, at daily frequency -dLastDayOfYear = ts.dateOf(ts.thisday('A'),'D','AFTER') - - -# get the first day of this year, at business frequency -bFirstDayOfYear = ts.dateOf(ts.thisday('A'),'B','BEFORE') - - -# get the last day of the previous quarter, business frequency -bLastDayOfLastQuarter = ts.dateOf(ts.thisday('Q')-1,'B','AFTER') - - -# dateOf can also go from high frequency to low frequency. In this case, the third parameter has no impact -aTrueValue = (ts.thisday('Q') == ts.dateOf(ts.thisday('b'),'Q')) - - -# dates of the same frequency can be subtracted (but not added obviously) -numberOfBusinessDaysPassedThisYear = ts.thisday('b') - bFirstDayOfYear - - -# integers can be added/substracted to/from dates -fiveDaysFromNow = ts.thisday('d') + 5 - - -# get the previous business day, where business day is considered to -# end at day_end_hour and day_end_min -pbd = ts.prevbusday(day_end_hour=18,day_end_min=0) - - -# construct a date object explicitly -myDateQ = ts.Date(freq='Q',year=2004,quarter=3) -myDateD = ts.Date(freq='D',year=1985,month=10,day=4) + +""" +=== TimeSeries === + +A TimeSeries object is the combination of three ndarrays: + + - `dates`: DateArray object. + - `data` : ndarray. + - `mask` : Boolean ndarray, indicating missing or invalid data. + + +==== Construction ==== + +To construct a TimeSeries, you can use the class constructor: + +>>> TimeSeries(data, dates=None, mask=nomask, + freq=None, observed=None, start_date=None, + dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False) + +where `data` is a sequence. +If `dates` is None, a DateArray of the same length as the data is constructed at +a `freq` frequency, starting at `start_date`. + +Alternatively, you can use the `time_series` function: + + +time_series(data, dates=None, freq=None, + start_date=None, end_date=None, length=None, include_last=True, + mask=nomask, dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False) + + +Let us construct a series of 600 random elements, starting 600 business days ago, +at a business daily frequency + +>>> import numpy as np +>>> import tseries as ts +>>> import tsdate as td +>>> data = np.random.uniform(-100,100,600) +>>> today = td.thisday('B') +>>> series = ts.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', + start_date=today-600) + +Let us set negative values to zero... + +>>> series[series<0] = 0 + +... and the values falling on Fridays to 100 +>>> series[series.day_of_week == 4] = 100 + +Note that we could also create a temporary array of 'day_of weeks' for the +corresponding period, and use it as condition. + +>>> weekdays = td.day_of_week(series) +>>> series[weekdays == 4] = 100 + +==== Slicing ==== + +Accessing elements of a TimeSeries works just like slicing +>>> series[-30:] + +But you can also use a date: +>>> thirtydaysago = today-30 +>>> series[thirtydaysago:] + +Or even a string +>>> series[thirtydaysago.tostring():] + + +==== Conversions ==== + +To convert a TimeSeries to another frequency, use the `convert` method or function. +The optional argument `func` must be a function that acts on a 1D masked array +and returns a scalar. + +>>> mSer1 = series.convert('M',func=ma.average) + +If `func` is not specified, the default value `'auto'` is used instead. In that case, +the conversion function is estimated from the `observed` attribute of the series. +For example, if `observed='SUMMED'`, then `func='auto'` is in fact `func=sum`. + +>>> mSer1_default = series.convert('M') + +If `func` is None, the convert method/function returns a 2D array, where each row +corresponds to the new frequency, and the columns to the original data. In our +example, convert will return a 2D array with 23 columns, as there are at most +23 business days per month. + +>>> mSer1_2d = series.convert('M',func=None) + +When converting from a lower frequency to a higher frequency, an extra argument +`position` is required. The value of the argument is either 'START' or 'END', +and determines where the data point will be placed in the +period. In the future, interpolation methods will be supported to fill in the +resulting masked values. + +Let us create a second series, this time with a monthly frequency, starting 110 +months ago. +>>> data = np.random.uniform(-100,100,100).astype(np.float_) +>>> today = today.asfreq('M') - 110 +>>> mSer2 = ts.TimeSeries(data, freq='m', observed='END',start_date=today) +>>> sixtymonthsago = today-60 +>>> mSer2[sixtymonthsago:sixtymonthsago+10] = 12 + +""" +import numpy as np +import tseries as ts +reload(ts) +import tsdate as td +reload(td) +#from numpy import ma +import maskedarray as ma + +data = np.random.uniform(-100,100,600) +today = td.thisday('B') +series = ts.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', + start_date=today-600) +series[series < 0] = 0 + +#WARNING: The ORIGINAL day_of_week version seemed bugged. +#It told me that 2006/12/28 was a Friday. +weekdays = td.day_of_week(series) +series[weekdays == 4] = 100 + +mSer1 = series.convert('M',func=ma.average) +mSer1_2d = series.convert('M',func=None) +mSer1_default = series.convert('M') +mToB = series.convert('M',position='START') + + +# Create another monthly frequency series +data = np.random.uniform(-100,100,100).astype(np.float_) +today = today.asfreq('M') - 110 +mSer2 = ts.TimeSeries(data, freq='m', observed='END',start_date=today) +sixtymonthsago = today-60 +mSer2[sixtymonthsago:sixtymonthsago+10] = 12 + + +""" +==== Operations on TimeSeries ==== + +If you work with only one TimeSeries, you can use regular commands to process +the data. For example: + +>>> mSer2_log = np.log(mSer2) + +Note that invalid values (negative, in that case), are automatically masked. +Note as well that trying to use the maskedarray command directly is unlikely to +work: you would end up with a regular MaskedArray. + +When working with multiple series, only series of the same frequency, size and +starting date can be used in basic operations. The function `align_series` forces +series to have matching starting and ending dates. By default, the starting date +will be set to the smallest starting date of the series, and the ending date to +the largest. [An alias to `align_series` is aligned] + +Let's construct a list of months, starting on Jan 2005 and ending on Dec 2006, +with a gap from Oct 2005 to Dec 2006. + +>>> mlist = ['2005-%02i' % i for i in range(1,10)] +>>> mlist += ['2006-%02i' % i for i in range(2,13)] +>>> mdata = numpy.arange(len(mlist)) +>>> mser1 = time_series(mdata, mlist, observed='SUMMED') + +Note that the frequency is 'U', for undefined. In fact, you have to specify what +kind of data is actually missing by forcing a given frequency. + +>>> mser1 = mser1.asfreq('M') + +Let us check whether there are some duplicated dates (no): + +>>> mser1.has_duplicated_dates() + +...or missing dates (yes): + +>>> mser1.has_missing_dates() + +Let us construct a second monthly series, this time without missing dates + +>>> mlist2 = ['2004-%02i' % i for i in range(1,13)] +>>> mlist2 += ['2005-%02i' % i for i in range(1,13)] +>>> mser2 = time_series(mdata, mlist2, observed='SUMMED') + +Let's try to add the two series: + +>>> mser3 = mser1 + mser2 + +That doesn't work, as the series have different starting dates. We need to align +them first. + +>>> (malg1,malg2) = aligned(mser1, mser2) + +That still doesnt' work, as `malg1` has missing dates. Let us fill it, then: +data falling on a date that was missing will be masked. + +>>> mser1_filled = fill_missing_dates(mser1) +>>> (malg1,malg2) = align_series(mser1_filled, mser2) + +Now we can add the two series. Only the data that fall on dates common to the +original, non-aligned series will be actually added, the others will be masked. +After all, we are adding masked arrays. + +>>> mser3 = malg1 + malg2 + +We could have filled the initial series first: +>>> mser3 = filled(malg1,0) + filled(malg2,0) + +Alternatively, we can force the series to start/end at some given dates + +>>> (malg1,malg2) = aligned(mser1_filled, mser2, +>>> start_date='2004-06', end_date='2006-06') + +""" +mlist = ['2005-%02i' % i for i in range(1,10)] +mlist += ['2006-%02i' % i for i in range(2,13)] +mdata = np.arange(len(mlist)) +mser1 = ts.time_series(mdata, mlist, observed='SUMMED') +mser1 = mser1.asfreq('M') +# +mlist2 = ['2004-%02i' % i for i in range(1,13)] +mlist2 += ['2005-%02i' % i for i in range(1,13)] +mser2 = ts.time_series(np.arange(len(mlist2)), mlist2, observed='SUMMED') +# +mser1_filled = ts.fill_missing_dates(mser1) +(malg1,malg2) = ts.aligned(mser1_filled, mser2) +mser3 = malg1 + malg2 + +""" +# add the two series together, first filling in masked values with zeros +mAdd1_filled = mSer1.filled(fill_value=0, ts=True) + mSer2.filled(fill_value=0, ts=True) + +# adjust the start and end dates of a series +newSer = ts.adjust_endpoints(mSer1, start_date=td.Date(freq='M', year=1954, month=5), end_date=td.Date(freq='M', year=2000, month=6)) + +# calculate the average value in the series. Behaves the same as in ma +bAverage = ma.average(series) + + + + + +# Get the last day of this year, at daily frequency +dLastDayOfYear = td.dateOf(td.thisday('A'),'D','AFTER') + + +# Get the first day of this year, at business frequency +bFirstDayOfYear = td.dateOf(td.thisday('A'),'B','BEFORE') + +# Get the last day of the previous quarter, business frequency +bLastDayOfLastQuarter = td.dateOf(td.thisday('Q')-1,'B','AFTER') + +# dateOf can also go from high frequency to low frequency. In this case, the third parameter has no impact +aTrueValue = (td.thisday('Q') == td.dateOf(td.thisday('b'),'Q')) + +# Dates of the same frequency can be subtracted (but not added obviously) +numberOfBusinessDaysPassedThisYear = td.thisday('b') - bFirstDayOfYear + +# Integers can be added/substracted to/from dates +fiveDaysFromNow = td.thisday('d') + 5 + + +# Get the previous business day, where business day is considered to +# end at day_end_hour and day_end_min +pbd = td.prevbusday(day_end_hour=18,day_end_min=0) +""" +# ------------------------------------------------------------------------------ +""" +=== Date construction === +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 `mxDate` keyword with an existing mx.DateTime.DateTime object, or + even a datetime.datetime object. + + >>> td.Date('D', mxDate=mx.DateTime.now()) + >>> td.Date('D', mxDate=datetime.datetime.now()) +""" + +# Construct a sequence of dates at a given frequency Property changes on: trunk/Lib/sandbox/timeseries/src ___________________________________________________________________ Name: svn:ignore + buildit.sh Added: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,157 @@ +import numpy +import maskedarray as MA + + +#####--------------------------------------------------------------------------- +#---- --- Generic functions --- +#####--------------------------------------------------------------------------- +def first_unmasked_val(a): + "Returns the first unmasked value in a 1d maskedarray." + (i,j) = MA.extras.flatnotmasked_edges(a) + return a[i] + +def last_unmasked_val(a): + "Returns the last unmasked value in a 1d maskedarray." + (i,j) = MA.extras.flatnotmasked_edges(a) + return a[j] + +def reverse_dict(d): + "Reverses the keys and values of a dictionary." + alt = [] + tmp = [alt.extend([(w,k) for w in v]) for (k,v) in d.iteritems()] + return dict(alt) + + + +#####--------------------------------------------------------------------------- +#---- --- Option conversion --- +#####--------------------------------------------------------------------------- +obs_dict = {"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 +# +def fmtObserv(obStr): + "Converts a possible 'Observed' string into acceptable values." + if obStr is None: + return None + elif obStr.upper() in obs_dict.keys(): + return obStr.upper() + else: + raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) + + +fmtfreq_dict = {'A': ['ANNUAL','ANNUALLY','YEAR','YEARLY'], + 'B': ['BUSINESS','BUSINESSLYT'], + 'D': ['DAY','DAILY',], + 'H': ['HOUR','HOURLY',], + 'M': ['MONTH','MONTHLY',], + 'Q': ['QUARTER','QUARTERLY',], + 'S': ['SECOND','SECONDLY',], + 'T': ['MINUTE','MINUTELY',], + 'W': ['WEEK','WEEKLY',], + 'U': ['UNDEF','UNDEFINED'], + } +fmtfreq_revdict = reverse_dict(fmtfreq_dict) + +def fmtFreq (freqStr): + "Converts a possible 'frequency' string to acceptable values." + if freqStr is None: + return None + elif freqStr.upper() in fmtfreq_dict.keys(): + return freqStr[0].upper() + elif freqStr.upper() in fmtfreq_revdict.keys(): + return fmtfreq_revdict[freqStr.upper()] + else: + raise ValueError("Invalid frequency: %s " % str(freqStr)) + +class DateSpec: + "Fake data type for date variables." + def __init__(self, freq): + self.freq = fmtFreq(freq) + + def __hash__(self): + return hash(self.freq) + + def __eq__(self, other): + if hasattr(other, "freq"): + return self.freq == other.freq + else: + return False + def __str__(self): + return "Date(%s)" % str(self.freq) + + + +# define custom numpy types. +# Note: A more robust approach would register these as actual valid numpy types +# this is just a hack for now +numpy.dateA = DateSpec("Annual") +numpy.dateB = DateSpec("Business") +numpy.dateD = DateSpec("Daily") +numpy.dateH = DateSpec("Hourly") +numpy.dateM = DateSpec("Monthly") +numpy.dateQ = DateSpec("Quarterly") +numpy.dateS = DateSpec("Secondly") +numpy.dateT = DateSpec("Minutely") +numpy.dateW = DateSpec("Weekly") +numpy.dateU = DateSpec("Undefined") + + +freq_type_mapping = {'A': numpy.dateA, + 'B': numpy.dateB, + 'D': numpy.dateD, + 'H': numpy.dateH, + 'M': numpy.dateM, + 'Q': numpy.dateQ, + 'S': numpy.dateS, + 'T': numpy.dateT, + 'W': numpy.dateW, + 'U': numpy.dateU, + } + +def freqToType(freq): + return freq_type_mapping[fmtFreq(freq)] + +def isDateType(dtype): + #TODO: That looks messy. We should simplify that + if len([x for x in freq_type_mapping.values() if x == dtype]) > 0: + return True + else: + return False + +#####--------------------------------------------------------------------------- +#---- --- Misc functions --- +#####--------------------------------------------------------------------------- +#http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348 +def flatten_sequence(iterable): + """Flattens a compound of nested iterables.""" + itm = iter(iterable) + for elm in itm: + if hasattr(elm,'__iter__') and not isinstance(elm, basestring): + for f in flatten_sequence(elm): + yield f + else: + yield elm + +def flatargs(*args): + "Flattens the arguments." + if not hasattr(args, '__iter__'): + return args + else: + return flatten_sequence(args) + + Property changes on: trunk/Lib/sandbox/timeseries/tcore.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,1089 @@ +""" +: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 datetime +import itertools +import warnings + + +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 maskedarray as MA +#reload(MA) + +import mx.DateTime as mxD +from mx.DateTime.Parser import DateFromString as mxDFromString + +import tcore as corelib +import cseries + + +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) +daflog = logging.getLogger('darray_from') +dalog = logging.getLogger('DateArray') + +#####--------------------------------------------------------------------------- +#---- --- Date Info --- +#####--------------------------------------------------------------------------- +OriginDate = mxD.Date(1970) +secondlyOriginDate = OriginDate - mxD.DateTimeDeltaFrom(seconds=1) +minutelyOriginDate = OriginDate - mxD.DateTimeDeltaFrom(minutes=1) +hourlyOriginDate = OriginDate - mxD.DateTimeDeltaFrom(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 `mxDate` keyword with an existing mx.DateTime.DateTime object, or + even a datetime.datetime object. + + >>> td.Date('D', mxDate=mx.DateTime.now()) + >>> td.Date('D', mxDate=datetime.datetime.now()) + """ + def __init__(self, freq, year=None, month=None, day=None, quarter=None, + hours=None, minutes=None, seconds=None, + mxDate=None, value=None, string=None): + + if hasattr(freq, 'freq'): + self.freq = corelib.fmtFreq(freq.freq) + else: + self.freq = corelib.fmtFreq(freq) + self.type = corelib.freqToType(self.freq) + + if value is not None: + if self.freq == 'A': + self.mxDate = mxD.Date(value, -1, -1) + elif self.freq == 'B': + valtmp = (value - 1)//5 + self.mxDate = mxD.DateTimeFromAbsDateTime(value + valtmp*7 - valtmp*5) + elif self.freq in ['D','U']: + self.mxDate = mxD.DateTimeFromAbsDateTime(value) + elif self.freq == 'H': + self.mxDate = hourlyOriginDate + mxD.DateTimeDeltaFrom(hours=value) + elif self.freq == 'M': + self.mxDate = mxD.DateTimeFromAbsDateTime(1) + \ + mxD.RelativeDateTime(months=value-1, day=-1) + elif self.freq == 'Q': + self.mxDate = mxD.DateTimeFromAbsDateTime(1) + \ + mxD.RelativeDateTime(years=(value // 4), + month=((value * 3) % 12), day=-1) + elif self.freq == 'S': + self.mxDate = secondlyOriginDate + mxD.DateTimeDeltaFromSeconds(value) + elif self.freq == 'T': + self.mxDate = minutelyOriginDate + mxD.DateTimeDeltaFrom(minutes=value) + elif self.freq == 'W': + self.mxDate = mxD.Date(1,1,7) + \ + mxD.RelativeDateTime(weeks=value-1) +# mxD.RelativeDateTime(weeks=value-5./7-1) + + elif string is not None: + self.mxDate = mxDFromString(string) + + elif mxDate is not None: + if isinstance(mxDate, datetime.datetime): + mxDate = mxD.strptime(mxDate.isoformat()[:19], "%Y-%m-%dT%H:%M:%S") + self.mxDate = truncateDate(self.freq, mxDate) + + else: + # First, some basic checks..... + if year is None: + raise InsufficientDateError + if self.freq in ('B', 'D', 'W'): + if month is None or day is None: + raise InsufficientDateError + elif self.freq == 'M': + if month is None: + raise InsufficientDateError + day = -1 + elif self.freq == 'Q': + if quarter is None: + raise InsufficientDateError + month = quarter * 3 + day = -1 + elif self.freq == 'A': + month = -1 + day = -1 + elif self.freq == 'S': + if month is None or day is None or seconds is None: + raise InsufficientDateError + + if self.freq in ['A','B','D','M','Q','W']: + self.mxDate = truncateDate(self.freq, mxD.Date(year, month, day)) + if self.freq == 'B': + if self.mxDate.day_of_week in [5,6]: + raise ValueError("Weekend passed as business day") + elif self.freq in ['H','S','T']: + if not hours: + if not minutes: + if not seconds: + hours = 0 + else: + hours = seconds//3600 + else: + hours = minutes // 60 + if not minutes: + if not seconds: + minutes = 0 + else: + minutes = (seconds-hours*3600)//60 + if not seconds: + seconds = 0 + else: + seconds = seconds % 60 + self.mxDate = truncateDate(self.freq, + mxD.Date(year, month, day, + hours, minutes, seconds)) + self.value = self.__value() + # FIXME: Shall we set them as properties ? + def day(self): + "Returns the day of month." + return self.mxDate.day + def day_of_week(self): + "Returns the day of week." + return self.mxDate.day_of_week + def day_of_year(self): + "Returns the day of year." + return self.mxDate.day_of_year + def month(self): + "Returns the month." + return self.mxDate.month + def quarter(self): + "Returns the quarter." + return monthToQuarter(self.mxDate.month) + def year(self): + "Returns the year." + return self.mxDate.year + def second(self): + "Returns the seconds." + return int(self.mxDate.second) + def minute(self): + "Returns the minutes." + return int(self.mxDate.minute) + def hour(self): + "Returns the hour." + return int(self.mxDate.hour) + def week(self): + "Returns the week." + return self.mxDate.iso_week[1] + + def __add__(self, other): + if isinstance(other, Date): + raise FrequencyDateError("Cannot add dates", self.freq, other.freq) + 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.freq, other.freq) + 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 subtract dates", \ + self.freq, other.freq) + return int(self) == int(other) + + def __cmp__(self, other): + if not hasattr(other, 'freq'): + return False + elif self.freq != other.freq: + raise FrequencyDateError("Cannot subtract dates", \ + self.freq, other.freq) + 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.freq == 'A': + val = int(self.mxDate.year) + # Business days. + elif self.freq == 'B': + days = self.mxDate.absdate + weeks = days // 7 +# val = (weeks*5) + (days - weeks*7) + val = days - weeks*2 + # Daily/undefined + elif self.freq in ['D', 'U']: + val = self.mxDate.absdate + # Hourly........ + elif self.freq == 'H': + val = (self.mxDate - hourlyOriginDate).hours + # Monthly....... + elif self.freq == 'M': + val = (self.mxDate.year-1)*12 + self.mxDate.month + # Quarterly..... + elif self.freq == 'Q': + val = (self.mxDate.year-1)*4 + self.mxDate.month//3 + # Secondly...... + elif self.freq == 'S': + val = (self.mxDate - secondlyOriginDate).seconds + # Minutely...... + elif self.freq == 'T': + val = (self.mxDate - minutelyOriginDate).minutes + # Weekly........ + elif self.freq == 'W': + #val = int(self.mxDate.year*365.25/7.-1) + self.mxDate.iso_week[1] + val = self.mxDate.absdate//7 + return int(val) + #...................................................... + def default_fmtstr(self): + "Defines the default formats for printing Dates." + if self.freq == "A": + fmt = "%Y" + elif self.freq in ("B","D"): + fmt = "%d-%b-%y" + elif self.freq == "M": + fmt = "%b-%Y" + elif self.freq == "Q": + fmt = "%YQ%q" + elif self.freq == 'H': + fmt = "%d-%b-%Y %H:00" + elif self.freq == 'T': + fmt = "%d-%b-%Y %H:%M" + elif self.freq == "S": + fmt = "%d-%b-%Y %H:%M:%S" + elif self.freq == "W": + fmt = "%YW%W" + else: + fmt = "%d-%b-%y" + return fmt + + def strfmt(self, fmt): + "Formats the date" + qFmt = fmt.replace("%q", "XXXX") + tmpStr = self.mxDate.strftime(qFmt) + return tmpStr.replace("XXXX", str(self.quarter())) + + def __str__(self): + return self.strfmt(self.default_fmtstr()) + + def __repr__(self): + return "<%s : %s>" % (str(self.freq), str(self)) + #...................................................... + def toordinal(self): + "Returns the date as an ordinal." + return self.mxDate.absdays + + def fromordinal(self, ordinal): + "Returns the date as an ordinal." + return Date(self.freq, mxDate=mxD.DateTimeFromAbsDays(ordinal)) + + def tostring(self): + "Returns the date as a string." + return str(self) + + def toobject(self): + "Returns the date as itself." + return self + + def asfreq(self, toFreq, relation='before'): + """Converts the date to a new frequency.""" + return asfreq(self, toFreq, relation) + + 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 truncateDate(freq, mxDate): + """Chops off the irrelevant information from the mxDate passed in.""" + freq = corelib.fmtFreq(freq) + if freq == 'A': + return mxD.Date(mxDate.year) + elif freq == 'Q': + return mxD.Date(mxDate.year, monthToQuarter(mxDate.month)*3) + elif freq == 'M': + return mxD.Date(mxDate.year, mxDate.month) + elif freq == 'W': + d = mxDate.absdate + return mxD.DateTimeFromAbsDateTime(d + (7 - d % 7) % 7 - 1) + elif freq in ('B', 'D'): + if freq == 'B' and mxDate.day_of_week in [5,6]: + raise ValueError("Weekend passed as business day") + return mxD.Date(mxDate.year, mxDate.month, mxDate.day) + elif freq == 'H': + return mxD.Date(mxDate.year, mxDate.month, mxDate.day, \ + mxDate.hour) + elif freq == 'T': + return mxD.Date(mxDate.year, mxDate.month, mxDate.day, \ + mxDate.hour, mxDate.minute) + else: + return mxDate + +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.fmtFreq(freq) + tempDate = mxD.now() + # if it is Saturday or Sunday currently, freq==B, then we want to use Friday + if freq == 'B' and tempDate.day_of_week >= 5: + tempDate -= (tempDate.day_of_week - 4) + if freq in ('B','D','H','S','T','W'): + return Date(freq, mxDate=tempDate) + elif freq == 'M': + return Date(freq, year=tempDate.year, month=tempDate.month) + elif freq == 'Q': + return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) + elif freq == '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 = mxD.localtime() + 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.fmtFreq(toFreq) + _rel = relation.upper()[0] +# if _rel not in ['B', 'A']: +# msg = "Invalid relation '%s': Should be in ['before', 'after']" +# raise ValueError, msg % relation +# elif _rel == 'B': +# before = True +# else: +# before = False + +# if not isDateType(date): + if not isinstance(date, Date): + raise DateError, "Date should be a valid Date instance!" + + if date.freq == toFreq: + return date + else: + value = cseries.asfreq(numeric.asarray(date.value), date.freq, toFreq, _rel) + if value > 0: + return Date(freq=toFreq, value=value) + else: + return None +# # Convert to annual .................... +# elif toFreq == 'A': +# return Date(freq='A', year=date.year()) +# # Convert to quarterly ................. +# elif toFreq == 'Q': +# if date.freq == 'A': +# if before: +# return Date(freq='A', year=date.year(), quarter=1) +# else: +# return Date(freq='A', year=date.year(), quarter=4) +# else: +# return Date(freq='Q', year=date.year(), quarter=date.quarter()) +# # Convert to monthly.................... +# elif toFreq == 'M': +# if date.freq == 'A': +# if before: +# return Date(freq='M', year=date.year(), month=1) +# else: +# return Date(freq='M', year=date.year(), month=12) +# elif date.freq == 'Q': +# if before: +# return dateOf(date-1, 'M', "AFTER")+1 +# else: +# return Date(freq='M', year=date.year(), month=date.month()) +# else: +# return Date(freq='M', year=date.year(), month=date.month()) +# # Convert to weekly .................... +# elif toFreq == 'W': +# if date.freq == 'A': +# if before: +# return Date(freq='W', year=date.year(), month=1, day=1) +# else: +# return Date(freq='W', year=date.year(), month=12, day=-1) +# elif date.freq in ['Q','M']: +# if before: +# return dateOf(date-1, 'W', "AFTER")+1 +# else: +# return Date(freq='W', year=date.year(), month=date.month()) +# else: +# val = date.weeks() + int(date.year()*365.25/7.-1) +# return Date(freq='W', value=val) +# # Convert to business days.............. +# elif toFreq == 'B': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D'), 'B', "AFTER") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") +# elif date.freq == 'D': +# # BEFORE result: preceeding Friday if date is a weekend, same day otherwise +# # AFTER result: following Monday if date is a weekend, same day otherwise +# tempDate = date.mxDate +# if before: +# if tempDate.day_of_week >= 5: +# tempDate -= (tempDate.day_of_week - 4) +# else: +# if tempDate.day_of_week >= 5: +# tempDate += 7 - tempDate.day_of_week +# return Date(freq='B', mxDate=tempDate) +# else: +# if before: +# return dateOf(dateOf(date, 'D'), 'B', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D'), 'B', "AFTER") +# # Convert to day ....................... +# elif toFreq == 'D': +# # ...from annual +# if date.freq == 'A': +# if before: +# return Date(freq='D', year=date.year(), month=1, day=1) +# else: +# return Date(freq='D', year=date.year(), month=12, day=31) +# # ...from quarter +# elif date.freq == 'Q': +# if before: +# return dateOf(date-1, 'D', "AFTER")+1 +# else: +# return Date(freq='D', year=date.year(), month=date.month(), +# day=date.day()) +# # ...from month +# elif date.freq == 'M': +# if before: +# return Date(freq='D', year=date.year(), month=date.month(), day=1) +# else: +# (mm,yy) = (date.month(), date.year()) +# if date.month() == 12: +# (mm, yy) = (1, yy + 1) +# else: +# mm = mm + 1 +# return Date('D', year=yy, month=mm, day=1)-1 +# # ...from week +# elif date.freq == 'W': +# if before: +# return Date(freq='D', year=date.year(), month=date.month(), +# day=date.day()) +# else: +# ndate = date + 1 +# return Date(freq='D', year=ndate.year(), month=ndate.month(), +# day=ndate.day()) +# # ...from a lower freq +# else: +# return Date('D', year=date.year(), month=date.month(), day=date.day()) +# #Convert to hour........................ +# elif toFreq == 'H': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D', "BEFORE"), 'H', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'H', "AFTER") +# if date.freq in ['B','D']: +# if before: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=0) +# else: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=23) +# else: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=date.hour()) +# #Convert to second...................... +# elif toFreq == 'T': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D', "BEFORE"), 'T', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'T', "AFTER") +# elif date.freq in ['B','D','H']: +# if before: +# return Date(freq='T', year=date.year(), month=date.month(), +# day=date.day(), minutes=0) +# else: +# return Date(freq='T', year=date.year(), month=date.month(), +# day=date.day(), minutes=24*60-1) +# else: +# return Date(freq='H', year=date.year(), month=date.month(), +# day=date.day(), hours=date.hour(), minutes=date.minute()) +# #Convert to minute...................... +# elif toFreq == 'S': +# if date.freq in ['A','Q','M','W']: +# if before: +# return dateOf(dateOf(date, 'D', "BEFORE"), 'S', "BEFORE") +# else: +# return dateOf(dateOf(date, 'D', "AFTER"), 'S', "AFTER") +# elif date.freq in ['B','D']: +# if before: +# return Date(freq='S', year=date.year(), month=date.month(), +# day=date.day(), seconds=0) +# else: +# return Date(freq='S', year=date.year(), month=date.month(), +# day=date.day(), seconds=24*60*60-1) + +def isDate(data): + "Returns whether `data` is an instance of Date." + return isinstance(data, Date) + + +#####--------------------------------------------------------------------------- +#---- --- DateArray --- +#####--------------------------------------------------------------------------- +ufunc_dateOK = ['add','subtract', + 'equal','not_equal','less','less_equal', 'greater','greater_equal', + 'isnan'] + +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. + """ + def __new__(cls, dates=None, freq='U', copy=False): + #dalog.info("__new__ received %s [%i]" % (type(dates), numpy.size(dates))) + if isinstance(dates, DateArray): + #dalog.info("__new__ sends %s as %s" % (type(dates), cls)) + cls.__defaultfreq = dates.freq + if not copy: + return dates.view(cls) + return dates.copy().view(cls) + else: + _dates = numeric.asarray(dates, dtype=int_) + if copy: + _dates = _dates.copy() + #dalog.info("__new__ sends %s as %s" % (type(_dates), cls)) + if freq is None: + freq = 'U' + cls.__defaultfreq = corelib.fmtFreq(freq) + (cls.__toobj, cls.__toord, cls.__tostr) = (None, None, None) + (cls.__steps, cls.__full, cls.__hasdups) = (None, None, None) + return _dates.view(cls) + + 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): + #dalog.info("__array_finalize__ received %s" % type(obj)) + if hasattr(obj, 'freq'): + self.freq = obj.freq + else: + self.freq = self.__defaultfreq + #dalog.info("__array_finalize__ sends %s" % type(self)) + + def __getitem__(self, index): + #dalog.info("__getitem__ got index %s (%s)"%(index, type(index))) + if isinstance(index, Date): + index = self.find_dates(index) + elif numeric.asarray(index).dtype.kind == 'O': + try: + index = self.find_dates(index) + except AttributeError: + pass + r = ndarray.__getitem__(self, index) + if r.size == 1: + # Only one element, and it's not a scalar: we have a DateArray of size 1 + if len(r.shape) > 0: + r = r.item() + return Date(self.freq, value=r) + else: + return r + + def __repr__(self): + return ndarray.__repr__(self) + #...................................................... + @property + def years(self): + "Returns the years." + return numeric.asarray([d.year() for d in self], dtype=int_) + @property + def months(self): + "Returns the months." + return numeric.asarray([d.month() for d in self], dtype=int_) + @property + def day_of_year(self): + "Returns the days of years." + return numeric.asarray([d.day_of_year() for d in self], dtype=int_) + yeardays = day_of_year + @property + def day_of_week(self): + "Returns the days of week." + return numeric.asarray([d.day_of_week() for d in self], dtype=int_) + #.... Conversion methods .................... +# def toobject(self): +# "Converts the dates from ordinals to Date objects." +# # Note: we better try to cache the result +# if self.__toobj is None: +## toobj = numeric.empty(self.size, dtype=object_) +## toobj[:] = [Date(self.freq, value=d) for d in self] +## self.__toobj = toobj +# self.__toobj = self +# return self.__toobj + # + 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.__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.__toord = toord + return self.__toord + # + def tostring(self): + "Converts the dates to strings." + # Note: we better cache the result + if self.__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.__tostr = tostr + return self.__tostr + # +# def asfreq_ini(self, freq=None): +# "Converts the dates to another frequency." +# # Note: As we define a new object, we don't need caching +# if freq is None: +# return self +# freq = corelib.fmtFreq(freq) +# if freq == self.freq: +# return self +# if self.isvalid(): +# new = numeric.arange(self.size, dtype=int_) +# new += self[0].asfreq(freq).value +# else: +# new = numpy.fromiter((d.asfreq(freq).value for d in self), +# dtype=float_) +# return DateArray(new, freq=freq) + + 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: + return self + freq = corelib.fmtFreq(freq) + if freq == self.freq: + return self + _rel = relation.upper()[0] + new = cseries.asfreq(numeric.asarray(self), self.freq, freq, _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 ValueError, "Date out of bounds!" + return c +# def find_dates_alt(self, *dates): +# "Returns the indices corresponding to given dates, as an array." +# ifreq = self.freq +# c = numpy.zeros(self.shape, bool_) +# dates = date_array([d for d in corelib.flatargs(*dates)]).asfreq(ifreq) +# for d in numeric.asarray(dates): +# c += (self == d) +# c = c.nonzero() +# if fromnumeric.size(c) == 0: +# raise ValueError, "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 ValueError, "Date out of bounds!" + return index + else: + index_asarray = (self == date.value).nonzero() + if fromnumeric.size(index_asarray) == 0: + raise ValueError, "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 daily!") + if self.__steps is None: + val = numeric.asarray(self).ravel() + if val.size > 0: + steps = val[1:] - val[:-1] + if self.__full is None: + self.__full = (steps.max() == 1) + if self.__hasdups is None: + self.__hasdups = (steps.min() == 0) + else: + self.__full = True + self.__hasdups = False + self.__steps = steps + return self.__steps + + def has_missing_dates(self): + "Returns whether the DateArray have missing dates." + if self.__full is None: + steps = self.get_steps() + return not(self.__full) + + def isfull(self): + "Returns whether the DateArray has no missing dates." + if self.__full is None: + steps = self.get_steps() + return self.__full + + def has_duplicated_dates(self): + "Returns whether the DateArray has duplicated dates." + if self.__hasdups is None: + steps = self.get_steps() + return self.__hasdups + + def isvalid(self): + "Returns whether the DateArray is valid: no missing/duplicated dates." + return (self.isfull() and not self.has_duplicated_dates()) + #...................................................... +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 + #dalog.info('__datearithmetics got method %s' % methodname) + # + 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' + #dalog.info('__datearithmetics got other %s' % type(other)) + method = getattr(super(DateArray,instance), self.methodname) + if isinstance(other, DateArray): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) +# other = + elif isinstance(other, Date): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) + other = other.value + #dalog.info('__datearithmetics got other %s' % type(other)) + 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) +#............................ +DateArray.__add__ = _datearithmetics('__add__', asdates=True) +DateArray.__radd__ = _datearithmetics('__add__', asdates=True) +DateArray.__sub__ = _datearithmetics('__sub__', asdates=True) +DateArray.__rsub__ = _datearithmetics('__rsub__', asdates=True) +DateArray.__le__ = _datearithmetics('__le__', asdates=False) +DateArray.__lt__ = _datearithmetics('__lt__', asdates=False) +DateArray.__ge__ = _datearithmetics('__ge__', asdates=False) +DateArray.__gt__ = _datearithmetics('__gt__', asdates=False) +DateArray.__eq__ = _datearithmetics('__eq__', asdates=False) +DateArray.__ne__ = _datearithmetics('__ne__', asdates=False) + +#####--------------------------------------------------------------------------- +#---- --- 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() + # Case #1: dates as strings ................. + if dlist.dtype.kind == 'S': + #...construct a list of ordinals + ords = numpy.fromiter((mxDFromString(s).absdays 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 ['i','f']: + #...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), float_) + #...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, mxDate=m) for m in dlist] + #...as datetime objects + elif hasattr(dlist[0], 'toordinal'): + ords = numpy.fromiter((d.toordinal() for d in dlist), float_) + if freq is None: + freq = guess_freq(ords) + dates = [Date(freq, mxDate=mxD.DateTimeFromAbsDays(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.fmtFreq(freq) + # Case #1: we have a list ................... + if dlist is not None: + # Already a DateArray.................... + if isinstance(dlist, DateArray): + if freq != dlist.freq: + return dlist.asfreq(freq) + else: + return dlist + return _listparser(dlist, freq) + # Case #2: we have a starting date .......... + if start_date is None: + raise InsufficientDateError +# if not isDateType(start_date): + if not isinstance(start_date, Date): + raise DateError, "Starting date should be a valid Date instance!" + # Check if we have an end_date + if end_date is None: + if length is None: + raise ValueError,"No length precised!" + else: + if not isinstance(end_date, Date): + raise DateError, "Ending date should be a valid Date instance!" +# assert(isDateType(end_date), +# "Starting date should be a valid Date instance!") + length = 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: + 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') + + +################################################################################ Property changes on: trunk/Lib/sandbox/timeseries/tdates.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,144 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for MaskedArray. +Adapted from the original test_ma by Pierre Gerard-Marchant + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: test_core.py 59 2006-12-22 23:58:11Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 59 $" +__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' + +import types +import datetime + +import numpy +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 + +import maskedarray.testutils +from maskedarray.testutils import assert_equal, assert_array_equal + +import tdates +reload(tdates) +from tdates import date_array_fromlist, Date, DateArray, mxDFromString + +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" + dlist = ['2007-01-%02i' % i for i in range(1,15)] + # A simple case: daily data + dates = date_array_fromlist(dlist, 'D') + assert_equal(dates.freq,'D') + assert(dates.isfull()) + assert(not dates.has_duplicated_dates()) + assert_equal(dates, 732677+numpy.arange(len(dlist))) + # as simple, but we need to guess the frequency this time + dates = date_array_fromlist(dlist, 'D') + assert_equal(dates.freq,'D') + assert(dates.isfull()) + assert(not dates.has_duplicated_dates()) + assert_equal(dates, 732677+numpy.arange(len(dlist))) + # Still daily data, that we force to month + dates = date_array_fromlist(dlist, 'M') + assert_equal(dates.freq,'M') + assert(not dates.isfull()) + assert(dates.has_duplicated_dates()) + assert_equal(dates, [24073]*len(dlist)) + # Now, for monthly data + dlist = ['2007-%02i' % i for i in range(1,13)] + dates = date_array_fromlist(dlist, 'M') + assert_equal(dates.freq,'M') + assert(dates.isfull()) + assert(not dates.has_duplicated_dates()) + assert_equal(dates, 24073 + numpy.arange(12)) + # Monthly data w/ guessing + dlist = ['2007-%02i' % i for i in range(1,13)] + dates = date_array_fromlist(dlist, ) + assert_equal(dates.freq,'M') + assert(dates.isfull()) + assert(not dates.has_duplicated_dates()) + assert_equal(dates, 24073 + numpy.arange(12)) + + def test_fromstrings_wmissing(self): + "Tests creation from list of strings w/ missing dates" + 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.freq,'U') + assert(not dates.isfull()) + assert(not dates.has_duplicated_dates()) + assert_equal(dates.tovalue(),732676+numpy.array([1,2,4,5,7,8,10,11,13])) + # + ddates = date_array_fromlist(dlist, 'D') + assert_equal(ddates.freq,'D') + assert(not ddates.isfull()) + assert(not ddates.has_duplicated_dates()) + # + mdates = date_array_fromlist(dlist, 'M') + assert_equal(mdates.freq,'M') + assert(not dates.isfull()) + assert(mdates.has_duplicated_dates()) + # + + def test_fromsobjects(self): + "Tests creation from list of objects." + 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()] + odates = date_array_fromlist(dobj) + assert_equal(dates,odates) + dobj = [mxDFromString(d) for d in dlist] + odates = date_array_fromlist(dobj) + assert_equal(dates,odates) + + +class test_methods(NumpyTestCase): + "Base test class for MaskedArrays." + + def __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)] + 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]) + assert_equal(mdates[lag], mdates[0]) + lag = mdates.find_dates(Date('M',value=24080)) + 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], + DateArray([mdates[0], mdates[-1]], freq='M')) + assert_equal(mdates[[mdates[0],mdates[-1]]], mdates[lag]) + # + 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') + + + def test_getsteps(self): + 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]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Copied: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py (from rev 2488, trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py) =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/test_timeseries.py 2007-01-04 16:42:30 UTC (rev 2488) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,283 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for MaskedArray. +Adapted from the original test_ma by Pierre Gerard-Marchant + +: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 types + +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 +#reload(maskedarray.testutils) +from maskedarray.testutils import assert_equal, assert_array_equal + +#import tdates +##reload(tdates) +#from tdates import date_array_fromlist +import tseries +#reload(tseries) +from tseries import Date, date_array_fromlist +from tseries import time_series, TimeSeries, adjust_endpoints, mask_period + +class test_creation(NumpyTestCase): + "Base test class for MaskedArrays." + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array_fromlist(dlist) + data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3) + self.d = (dlist, dates, data) + + def test_fromlist (self): + "Base data definition." + (dlist, dates, data) = self.d + series = time_series(data, dlist) + assert(isinstance(series, TimeSeries)) + assert_equal(series._mask, [1,0,0,0,0]*3) + assert_equal(series._series, data) + assert_equal(series._dates, date_array_fromlist(dlist)) + assert_equal(series.freq, 'D') + + def test_fromrange (self): + "Base data definition." + (dlist, dates, data) = self.d + series = time_series(data, start_date=Date('D',value=dates[0]), + length=15) + assert(isinstance(series, TimeSeries)) + assert_equal(series._mask, [1,0,0,0,0]*3) + assert_equal(series._series, data) + assert_equal(series._dates, dates) + assert_equal(series.freq, 'D') + + def test_fromseries (self): + "Base data definition." + (dlist, dates, data) = self.d + series = time_series(data, dlist) + dates = dates+15 + series = time_series(series, dates) + assert(isinstance(series, TimeSeries)) + assert_equal(series._mask, [1,0,0,0,0]*3) + assert_equal(series._series, data) + assert_equal(series._dates, dates) + assert_equal(series.freq, 'D') +#............................................................................... + +class test_arithmetics(NumpyTestCase): + "Some basic arithmetic tests" + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + 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 + # + nseries = series+1 + assert(isinstance(nseries, TimeSeries)) + 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) + 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) + 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) + 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 + nseries = series.astype(float_) + idini = id(nseries) + data = data.astype(float_) + # + nseries += 1. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data+1.) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + nseries -= 1. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + nseries *= 2. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data*2.) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + nseries /= 2. + assert(isinstance(nseries, TimeSeries)) + assert_equal(nseries._mask, [1,0,0,0,0]*3) + assert_equal(nseries._series, data) + assert_equal(nseries._dates, series._dates) + assert_equal(id(nseries),idini) + # + def test_updatemask(self): + "Checks modification of mask." + (series, data) =self.d + assert_equal(series._mask, [1,0,0,0,0]*3) + series.mask = nomask + assert(series._mask is nomask) + assert(series._series._mask is nomask) + series._series.mask = [1,0,0]*5 + assert_equal(series._mask, [1,0,0]*5) + assert_equal(series._series._mask, [1,0,0]*5) + series[2] = masked + assert_equal(series._mask, [1,0,1]+[1,0,0]*4) + assert_equal(series._series._mask, [1,0,1]+[1,0,0]*4) +#............................................................................... + +class test_getitem(NumpyTestCase): + "Some getitem tests" + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + 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 + last_date = series[-1]._dates + assert_equal(series[-1], series[last_date]) + assert_equal(series._dates[-1], dates[-1]) + assert_equal(series[-1]._dates, dates[-1]) + assert_equal(series[last_date]._dates, dates[-1]) + assert_equal(series._series[-1], data._data[-1]) + assert_equal(series[-1]._series, data._data[-1]) + assert_equal(series._mask[-1], data._mask[-1]) + # + series['2007-01-06'] = 999 + assert_equal(series[5], 999) + # + def test_wtimeseries(self): + "Tests getitem w/ TimeSeries as index" + (series, data, dates) = self.d + # Testing a basic condition on data + cond = (series<8).filled(False) + dseries = series[cond] + assert_equal(dseries._data, [1,2,3,4,6,7]) + assert_equal(dseries._dates, series._dates[[1,2,3,4,6,7]]) + assert_equal(dseries._mask, nomask) + # 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 + # Basic slices + assert_equal(series[3:7]._series._data, data[3:7]._data) + assert_equal(series[3:7]._series._mask, data[3:7]._mask) + assert_equal(series[3:7]._dates, dates[3:7]) + # Ditto + assert_equal(series[:5]._series._data, data[:5]._data) + assert_equal(series[:5]._series._mask, data[:5]._mask) + assert_equal(series[:5]._dates, dates[:5]) + # With set + series[:5] = 0 + assert_equal(series[:5]._series, [0,0,0,0,0]) + dseries = N.log(series) + series[-5:] = dseries[-5:] + assert_equal(series[-5:], dseries[-5:]) + # Now, using dates ! + dseries = series[series.dates[3]:series.dates[7]] + assert_equal(dseries, series[3:7]) + +class test_functions(NumpyTestCase): + "Some getitem tests" + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + 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, dates) + # + def test_adjustendpoints(self): + "Tests adjust_endpoints" + (series, data, dates) = self.d + dseries = adjust_endpoints(series, series.dates[0], series.dates[-1]) + assert_equal(dseries, series) + dseries = adjust_endpoints(series, series.dates[3], series.dates[-3]) + assert_equal(dseries, series[3:-2]) + dseries = adjust_endpoints(series, end_date=Date('D', string='2007-01-31')) + assert_equal(dseries.size, 31) + assert_equal(dseries._mask, N.r_[series._mask, [1]*16]) + 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, + start_date=Date('D', string='2007-01-06'), + end_date=Date('D', string='2007-01-31')) + assert_equal(dseries.size, 26) + assert_equal(dseries._mask, N.r_[series._mask[5:], [1]*16]) + # + def test_maskperiod(self): + "Test mask_period" + (series, data, dates) = self.d + 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]) + # + def pickling(self): + "Tests pickling/unpickling" + (series, data, dates) = self.d + tmp = maskedarray.loads(series.dumps()) + assert_equal(tmp._data, series._data) + assert_equal(tmp._dates, series._dates) + assert_equal(tmp._mask, series._mask) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Property changes on: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Deleted: trunk/Lib/sandbox/timeseries/timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/timeseries.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -1,504 +0,0 @@ -import numpy -from numpy import ma - -import corelib -import cseries -import tsdate -import copy as copytools - -from types import MethodType - -masked = ma.masked -nomask = ma.nomask - -def ts_compatible(a, b): - if a.freq != b.freq: - raise ValueError("Both TimeSeries must have same freq!") - elif a.start_date() != b.start_date(): - raise ValueError("Both TimeSeries must have same start_date!") - elif a.shape != b.shape: - raise ValueError("Both TimeSeries must be of the same size!") - - -class ts_unary_operation: - def __init__ (self, abfunc): - self.f = abfunc - self.__doc__ = getattr(abfunc, "__doc__", str(abfunc)) - - def __call__ (self, a, *args, **kwargs): - "Execute the call behavior." - if isinstance(a, TimeSeries): - return TimeSeries(self.f(a, *args, **kwargs), freq=a.freq, observed=a.observed, start_date=a.start_date()) - else: - return self.f(a, *args, **kwargs) - - -class ts_binary_operation: - def __init__ (self, abfunc): - self.f = abfunc - self.__doc__ = getattr(abfunc, "__doc__", str(abfunc)) - - def __call__ (self, a, b, *args, **kwargs): - "Execute the call behavior." - - if isinstance(a, TimeSeries) and isinstance(b, TimeSeries): - ts_compatible(a, b) - return TimeSeries(self.f(a, b, *args, **kwargs), freq=a.freq, observed=a.observed, start_date=a.start_date()) - elif isinstance(a, TimeSeries): - if corelib.isDateType(a.tstype): - return TimeSeries(self.f(a, b, *args, **kwargs), dtype=a.tstype, freq=a.freq, observed=a.observed, start_date=a.start_date()) - else: - return TimeSeries(self.f(a, b, *args, **kwargs), freq=a.freq, observed=a.observed, start_date=a.start_date()) - elif isinstance(b, TimeSeries): - if corelib.isDateType(b.tstype): - return TimeSeries(self.f(a, b, *args, **kwargs), dtype=b.tstype, freq=b.freq, observed=b.observed, start_date=b.start_date()) - else: - return TimeSeries(self.f(a, b, *args, **kwargs), freq=b.freq, observed=b.observed, start_date=b.start_date()) - else: - return self.f(a, b, *args, **kwargs) - - def reduce (self, target, axis=0, dtype=None): - return self.f.reduce(target, axis, dtype) - - def outer (self, a, b): - return self.f.outer(a, b) - - def accumulate (self, target, axis=0): - return datawrap(self.f.accumulate(target, axis), target) - - def __str__ (self): - return "Masked version of " + str(self.f) - - -class TimeSeries(ma.MaskedArray): - - __array_priority__ = 10.2 - - def __init__(self, data, dtype=None, freq=None, start_date=None, observed=None, copy=True, order=False, mask=ma.nomask, fill_value=None): - - if isinstance(data, TimeSeries): - if freq is None: freq = data.freq - if start_date is None: start_date = data.start_date() - if observed is None: observed = data.observed - else: - if observed is None: observed = 'END' - - self.freq = corelib.fmtFreq(freq) - - if isinstance(start_date, tsdate.Date): - if start_date.freq != self.freq: raise ValueError("frequency of start_date must match frequency of series") - else: self.__start_date = start_date - else: - self.__start_date = tsdate.Date(freq=self.freq, value=start_date) - - self.observed = corelib.fmtObserv(observed) - - self.tstype = None - - if corelib.isDateType(dtype) or (isinstance(data, TimeSeries) and corelib.isDateType(data.tstype)): - self.tstype = dtype - dtype = numpy.int_ - - super(TimeSeries, self).__init__(data=data, dtype=dtype, copy=copy, order=order, mask=mask, fill_value=fill_value) - - if self.tstype is None: self.tstype = self.dtype - - - def __getitem__(self, key): - return super(TimeSeries, self).__getitem__(self.__prepKey(key)) - - def __setitem__(self, key, value): - super(TimeSeries, self).__setitem__(self.__prepKey(key), value) - - def __prepKey(self, key): - - if isinstance(key, tsdate.Date): - key = int(key - self.start_date()) - if key < 0: raise ValueError("Date out of bounds") - else: return key - - elif isinstance(key, TimeSeries): - if corelib.isDateType(key.tstype): - if key.tstype.freq != self.freq: - raise ValueError("series of frequency "+str(self.freq)+" given date expression of type "+str(key.tstype.freq)) - - if key.mask is ma.nomask: key = numpy.asarray(key) - int(self.start_date()) - else: key = numpy.asarray(key[key.mask == False]) - int(self.start_date()) - - if len(numpy.where(key < 0)[0]) > 0: raise ValueError("Indices out of bounds") - - return key - - else: - - # frequency, size, and start_date of key must all match self - # when the data type is note a date - ts_compatible(key, self) - - if key.tstype is numpy.bool_: - key = key.filled(False) - elif numpy.ravel(key.mask).any(): - raise ValueError("masked values cannot be used as indices!") - - return numpy.asarray(key) - - elif isinstance(key, ma.MaskedArray): - - if key.dtype is numpy.bool_: - key = key.filled(False) - elif numpy.ravel(key.mask).any(): - raise ValueError("masked values cannot be used as indices!") - - return numpy.asarray(key) - - else: return key - - - def convert(self, freq, func='auto', position='END', interp=None): - """ - return self converted to freq. - - 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 - appropriate function is determined based on the observed attribute - 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 - placed at the end of the month). Interp is the method that will be used - to fill in the gaps. Valid values are "CUBIC", "LINEAR", "CONSTANT", "DIVIDED", - and None. - - Note: interp currently not implemented - - """ - - if position.upper() not in ('END','START'): raise ValueError("invalid value for position argument: (%s)",str(position)) - - toFreq = corelib.fmtFreq(freq) - fromFreq = self.freq - - if fromFreq != toFreq: - - if func == 'auto': - func = corelib.obsDict[self.observed] - - if self.size == 0: - return TimeSeries(self, freq=toFreq, start_date=tsdate.dateOf(self.start_date(), toFreq)) - - tempData = self.filled() - - if self.mask is ma.nomask: - tempMask = numpy.empty(tempData.shape, dtype=numpy.bool_) - tempMask[:] = False - else: tempMask = self.mask - - cRetVal = cseries.convert(tempData, fromFreq, toFreq, position, int(self.start_date()), tempMask) - - _values = cRetVal['values'] - _mask = cRetVal['mask'] - startIndex = cRetVal['startindex'] - - tempData = ma.array(_values) - tempMask = ma.make_mask(_mask) - tempData[tempMask] = ma.masked - - if func is not None and tempData.ndim == 2: - tempData = corelib.apply_along_axis(func, 1, tempData) - - return TimeSeries(tempData, freq=toFreq, observed=self.observed, start_date=startIndex) - - else: - return copytools.deepcopy(self) - - - def adjust_endpoints(self, start_date=None, end_date=None): - self.__init__(adjust_endpoints(self, start_date=start_date, end_date=end_date)) - - - def __str__(self): - retVal = "" - - if self.shape[0] > 0: - for i in range(self.shape[0]): - index = str(self.start_date() + i) - index = index + (" " * (6-len(index))) - retVal += index + " --> " + str(self[i])+"\n" - return retVal - else: - return "" - - - def first_value(self, asDate=False): - firstIndex = corelib.first_unmasked(self) - if asDate: - return self.start_date() + firstIndex - else: - return firstIndex - - def last_value(self, asDate=False): - lastIndex = corelib.last_unmasked(self) - if asDate: - return self.start_date() + lastIndex - else: - return lastIndex - - def start_date(self): return self.__start_date - def end_date(self): return self.__start_date + (self.shape[0] - 1) - - def date_to_index(self, date): - if date.freq != self.freq: raise ValueError("date.freq != self.freq") - return date - self.start_date() - - - # built-in methods - - def __and__(self, other): return bitwise_and(self, other) - def __or__(self, other): return bitwise_or(self, other) - def __xor__(self, other): return bitwise_xor(self, other) - __rand__ = __and__ - __ror__ = __or__ - __rxor__ = __xor__ - def __abs__(self): return absolute(self) - def __neg__(self): return negative(self) - def __pos__(self): return TimeSeries(self) - def __add__(self, other): return add(self, other) - __radd__ = __add__ - def __mod__ (self, other): return remainder(self, other) - def __rmod__ (self, other): return remainder(other, self) - def __lshift__ (self, n): return left_shift(self, n) - def __rshift__ (self, n): return right_shift(self, n) - def __sub__(self, other): return subtract(self, other) - def __rsub__(self, other): return subtract(other, self) - def __mul__(self, other): return multiply(self, other) - __rmul__ = __mul__ - def __div__(self, other): return divide(self, other) - def __rdiv__(self, other): return divide(other, self) - def __truediv__(self, other): return true_divide(self, other) - def __rtruediv__(self, other): return true_divide(other, self) - def __floordiv__(self, other): return floor_divide(self, other) - def __rfloordiv__(self, other): return floor_divide(other, self) - def __pow__(self, other, third=None): return power(self, other, third) - def __sqrt__(self): return sqrt(self) - - def __iadd__(self, other): - return self + other - - def __imul__(self, other): - return self * other - - def __isub__(self, other): - return self - other - - def __idiv__(self, other): - return self / other - - def __eq__(self, other): return equal(self,other) - def __ne__(self, other): return not_equal(self,other) - def __lt__(self, other): return less(self,other) - def __le__(self, other): return less_equal(self,other) - def __gt__(self, other): return greater(self,other) - def __ge__(self, other): return greater_equal(self,other) - - def astype (self, tc): - "return self as array of given type." - d = self._data.astype(tc) - return datawrap(ma.array(d, mask=self._mask), self) - - def filled (self, fill_value=None, ts=False): - d = super(TimeSeries, self).filled(fill_value) - if ts: return datawrap(d, self) - else: return d - - -def datawrap(data, ts): return TimeSeries(data, freq=ts.freq, observed=ts.observed, start_date=ts.start_date()) - -## wrappers for numpy.ma funcs - -sqrt = ts_unary_operation(ma.sqrt) -log = ts_unary_operation(ma.log) -log10 = ts_unary_operation(ma.log10) -exp = ts_unary_operation(ma.exp) -sin = ts_unary_operation(ma.sin) -cos = ts_unary_operation(ma.cos) -tan = ts_unary_operation(ma.tan) -arcsin = ts_unary_operation(ma.arcsin) -arccos = ts_unary_operation(ma.arccos) -arctan = ts_unary_operation(ma.arctan) - -def cumprod(self, axis=0, dtype=None, out=None): return datawrap(ma._cumprod(self, axis, dtype, out), self) -def cumsum(self, axis=0, dtype=None, out=None): return datawrap(ma._cumsum(self, axis, dtype, out), self) - -arcsinh = ts_unary_operation(ma.arcsinh) -arccosh = ts_unary_operation(ma.arccosh) -arctanh = ts_unary_operation(ma.arctanh) -sinh = ts_unary_operation(ma.sinh) -cosh = ts_unary_operation(ma.cosh) -tanh = ts_unary_operation(ma.tanh) -absolute = ts_unary_operation(ma.absolute) -fabs = ts_unary_operation(ma.fabs) -negative = ts_unary_operation(ma.negative) -nonzero = ts_unary_operation(ma.nonzero) - -around = ts_unary_operation(ma.around) -floor = ts_unary_operation(ma.floor) -ceil = ts_unary_operation(ma.ceil) -logical_not = ts_unary_operation(ma.logical_not) - -def zeros(shape, dtype=float, freq=None, start_date=None, observed=None): - return TimeSeries(ma.zeros(shape, dtype), freq=freq, start_date=start_date, observed=observed) -def ones(shape, dtype=float, freq=None, start_date=None, observed=None): - return TimeSeries(ma.ones(shape, dtype), freq=freq, start_date=start_date, observed=observed) - - -# functions from ma that we want to return scalars or masked arrays -count = ma.count -sum = ma.sum -product = ma.product -average = ma.average -compress = ma.compress -minimum = ma.minimum -maximum = ma.maximum -alltrue = ma.alltrue -allclose = ma.allclose -allequal = ma.allequal -sometrue = ma.sometrue -std = ma._std -var = ma._var - -def argmin (x, axis = -1, out=None, fill_value=None): - # same as argmin for ma, but returns a date instead of integer - return x.start_date() + ma.argmin(x, axis, out, fill_value) - -def argmax (x, axis = -1, out=None, fill_value=None): - # same as argmax for ma, but returns a date instead of integer - return x.start_date() + ma.argmax(x, axis, out, fill_value) - - -# binary operators -add = ts_binary_operation(ma.add) -subtract = ts_binary_operation(ma.subtract) -multiply = ts_binary_operation(ma.multiply) -divide = ts_binary_operation(ma.divide) -power = ts_binary_operation(ma.power) -true_divide = ts_binary_operation(ma.true_divide) -floor_divide = ts_binary_operation(ma.floor_divide) -remainder = ts_binary_operation(ma.remainder) -fmod = ts_binary_operation(ma.fmod) -hypot = ts_binary_operation(ma.hypot) -arctan2 = ts_binary_operation(ma.arctan2) -equal = ts_binary_operation(ma.equal) -not_equal = ts_binary_operation(ma.not_equal) -less_equal = ts_binary_operation(ma.less_equal) -greater_equal = ts_binary_operation(ma.greater_equal) -less = ts_binary_operation(ma.less) -greater = ts_binary_operation(ma.greater) -logical_and = ts_binary_operation(ma.logical_and) -logical_or = ts_binary_operation(ma.logical_or) -logical_xor = ts_binary_operation(ma.logical_xor) -bitwise_and = ts_binary_operation(ma.bitwise_and) -bitwise_or = ts_binary_operation(ma.bitwise_or) -bitwise_xor = ts_binary_operation(ma.bitwise_xor) - -def left_shift (a, n): return datawrap(ma.left_shift(a, n), a) -def right_shift (a, n): return datawrap(ma.right_shift(a, n), a) - -def masked_where(condition, x, copy=1): return datawrap(ma.masked_where(condition, x, copy), x) -def masked_greater(x, value, copy=1): return datawrap(ma.masked_greater(x, value, copy), x) -def masked_greater_equal(x, value, copy=1): return datawrap(ma.masked_greater_equal(x, value, copy), x) -def masked_less(x, value, copy=1): return datawrap(ma.masked_less(x, value, copy), x) -def masked_less_equal(x, value, copy=1): return datawrap(ma.masked_less_equal(x, value, copy), x) -def masked_not_equal(x, value, copy=1): return datawrap(ma.masked_not_equal(x, value, copy), x) -def masked_equal(x, value, copy=1): return datawrap(ma.masked_equal(x, value, copy), x) -def masked_inside(x, v1, v2, copy=1): return datawrap(ma.masked_inside(x, v1, v2, copy), x) -def masked_outside(x, v1, v2, copy=1): return datawrap(ma.masked_outside(x, v1, v2, copy), x) - -def clip(self,a_min,a_max,out=None): return datawrap(ma._clip(self, a_min, a_max, out=None), self) - - -array = TimeSeries - -def _m(f): - return MethodType(f, None, array) - -array.clip = _m(clip) -array.argmax = _m(argmax) -array.argmin = _m(argmin) -array.cumprod = _m(cumprod) -array.cumsum = _m(cumsum) - - -# time series specific functions - -def tser(start, end): - if start.freq != end.freq: - raise ValueError("start and end dates must have same frequency!") - return TimeSeries(numpy.arange(int(start), int(end)+1), dtype=corelib.freqTypeMapping[start.freq], freq=start.freq, start_date=start) - -def year(dateSer): - return __getDateInfo(dateSer,'Y') - -def quarter(dateSer): - return __getDateInfo(dateSer,'Q') - -def month(dateSer): - return __getDateInfo(dateSer,'M') - -def day(dateSer): - return __getDateInfo(dateSer,'D') - -def day_of_week(dateSer): - return __getDateInfo(dateSer,'W') - -def __getDateInfo(dateSer,infoCode): - newData = ma.array(cseries.getDateInfo(dateSer.filled(), dateSer.tstype.freq, infoCode)) - if dateSer.mask is not ma.nomask: - newData[dateSer.mask] = ma.masked - return datawrap(newData, dateSer) - - -def adjust_endpoints(a, start_date=None, end_date=None): - """adjust_endpoints(a, start_date=None, end_date=None) returns a new - TimeSeries going from start_date to end_date""" - - if start_date is None: start_date = a.start_date() - if end_date is None: end_date = a.end_date() - - tmpShape = list(a.shape) - tmpShape[0] = max(end_date - start_date + 1, 0) - tmpShape = tuple(tmpShape) - - tmpSer = TimeSeries(ma.resize(a, tmpShape), freq=a.freq, observed=a.observed, start_date=start_date) - - setStart, setEnd = max(start_date, a.start_date()), min(end_date, a.end_date()) - setLen = setEnd - setStart - - tmpSer[:] = ma.masked - - if setLen >= 0: - tmpSer[tmpSer.date_to_index(setStart):tmpSer.date_to_index(setEnd)+1] = a[a.date_to_index(setStart):a.date_to_index(setEnd)+1] - - return tmpSer - - -def aligned(*series, **kwargs): - - if len(series) < 2: - return series - - freq = series[0].freq - - if len(set([x.freq for x in series])) > 1: raise ValueError("All series must have same frequency!") - - if 'start_date' in kwargs: start_date = kwargs['start_date'] - else: start_date = min([x.start_date() for x in series]) - - if 'end_date' in kwargs: end_date = kwargs['end_date'] - else: end_date = max([x.end_date() for x in series]) - - return [adjust_endpoints(x, start_date=start_date, end_date=end_date) for x in series] - \ No newline at end of file Deleted: trunk/Lib/sandbox/timeseries/tsdate.py =================================================================== --- trunk/Lib/sandbox/timeseries/tsdate.py 2007-01-14 21:25:20 UTC (rev 2551) +++ trunk/Lib/sandbox/timeseries/tsdate.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -1,197 +0,0 @@ -import corelib -import cseries -import numpy as np -import mx.DateTime - -class Date: - def __init__(self, freq, year=None, month=None, day=None, seconds=None, quarter=None, mxDate=None, value=None): - - if hasattr(freq, 'freq'): - self.freq = corelib.fmtFreq(freq.freq) - else: - self.freq = corelib.fmtFreq(freq) - self.type = corelib.freqToType(self.freq) - - if value is not None: - if self.freq == 'D': - self.mxDate = mx.DateTime.DateTimeFromAbsDays(value-1) - elif self.freq == 'B': - value = value - 1 - self.mxDate = mx.DateTime.DateTimeFromAbsDays(value + (value//5)*7 - (value//5)*5) - elif self.freq == 'S': - self.mxDate = secondlyOriginDate + mx.DateTime.DateTimeDeltaFromSeconds(value) - elif self.freq == 'M': - self.mxDate = (mx.DateTime.Date(0)) + mx.DateTime.RelativeDateTime(months=value-1, day=-1) - elif self.freq == 'A': - self.mxDate = mx.DateTime.Date(value, -1, -1) - elif self.freq == 'Q': - self.mxDate = (mx.DateTime.Date(0)) + mx.DateTime.RelativeDateTime(years=(value // 4), month=((value * 3) % 12), day=-1) - elif mxDate is not None: - self.mxDate = mxDate - else: - error = ValueError("Insufficient parameters given to create a date at the given frequency") - - if year is None: - raise error - - if self.freq in ('B', 'D'): - if month is None or day is None: raise error - elif self.freq == 'M': - if month is None: raise error - day = -1 - elif self.freq == 'Q': - if quarter is None: raise error - month = quarter * 3 - day = -1 - elif self.freq == 'A': - month = -1 - day = -1 - elif self.freq == 'S': - if month is None or day is None or seconds is None: raise error - - if self.freq != 'S': - self.mxDate = mx.DateTime.Date(year, month, day) - if self.freq == 'B': - if self.mxDate.day_of_week == 5 or self.mxDate.day_of_week == 6: - raise ValueError("Weekend passed as business day") - else: - _hours = int(seconds/3600) - _minutes = int((seconds - _hours*3600)/60) - _seconds = seconds % 60 - - self.mxDate = mx.DateTime.Date(year, month, day, _hours, _minutes, _seconds) - - self.value = self.__value() - - def day(self): return self.mxDate.day - def day_of_week(self): return self.mxDate.day_of_week - def month(self): return self.mxDate.month - def quarter(self): return monthToQuarter(self.mxDate.month) - def year(self): return self.mxDate.year - def seconds(self): return int(self.mxDate.second) - def minute(self): return int(self.mxDate.minute) - def hour(self): return int(self.mxDate.hour) - - def strfmt(self, fmt): - qFmt = fmt.replace("%q", "XXXX") - tmpStr = self.mxDate.strftime(qFmt) - return tmpStr.replace("XXXX", str(self.quarter())) - - def __str__(self): - return self.strfmt(self.default_fmtstr()) - - def default_fmtstr(self): - if self.freq in ("B", "D"): - return "%d-%b-%y" - elif self.freq == "S": - return "%d-%b-%Y %H:%M:%S" - elif self.freq == "M": - return "%b-%Y" - elif self.freq == "Q": - return "%Yq%q" - elif self.freq == "A": - return "%Y" - else: - return "%d-%b-%y" - - def __add__(self, other): - if isinstance(other, Date): - raise TypeError("Cannot add dates") - 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 ValueError("Cannont subtract dates of different frequency (" + str(self.freq) + " != " + str(other.freq) + ")") - else: - return int(self) - int(other) - else: - return self + (-1) * int(other) - - - def __repr__(self): return "<" + str(self.freq) + ":" + str(self) + ">" - - def __eq__(self, other): - if self.freq != other.freq: - raise TypeError("frequencies are not equal!") - return int(self) == int(other) - - def __cmp__(self, other): - if self.freq != other.freq: - raise TypeError("frequencies are not equal!") - return int(self)-int(other) - - def __hash__(self): return hash(int(self)) ^ hash(self.freq) - - def __int__(self): - return self.value - - def __value(self): - - if self.freq == 'D': - return self.mxDate.absdate - elif self.freq == 'B': - days = self.mxDate.absdate - weeks = days // 7 - return int((weeks*5) + (days - weeks*7)) - elif self.freq == 'M': - return self.mxDate.year*12 + self.mxDate.month - elif self.freq == 'S': - return int((self.mxDate - secondlyOriginDate).seconds) - elif self.freq == 'A': - return int(self.mxDate.year) - elif self.freq == 'Q': - return int(self.mxDate.year*4 + self.mxDate.month/3) - - -secondlyOriginDate = mx.DateTime.Date(1980) - mx.DateTime.DateTimeDeltaFromSeconds(1) - - -####################### -# FUNCTIONS -####################### -def monthToQuarter(monthNum): - return int((monthNum-1)/3)+1 - -def thisday(freq): - - freq = corelib.fmtFreq(freq) - - tempDate = mx.DateTime.now() - - # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freq == 'B' and tempDate.day_of_week >= 5: - tempDate -= (tempDate.day_of_week - 4) - if freq == 'B' or freq == 'D' or freq == 'S': - return Date(freq, mxDate=tempDate) - elif freq == 'M': - return Date(freq, year=tempDate.year, month=tempDate.month) - elif freq == 'Q': - return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freq == 'A': - return Date(freq, year=tempDate.year) - - -def prevbusday(day_end_hour=18, day_end_min=0): - tempDate = mx.DateTime.localtime() - - 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') - - -# returns date converted to a date of toFreq according to relation -# relation = "BEFORE" or "AFTER" (not case sensitive) -def dateOf(date, toFreq, relation="BEFORE"): - - toFreq = corelib.fmtFreq(toFreq) - _rel = relation.upper()[0] - - if date.freq == toFreq: - return date - else: - return Date(freq=toFreq, value=cseries.asfreq(np.asarray(date.value), date.freq, toFreq, _rel)) Copied: trunk/Lib/sandbox/timeseries/tseries.py (from rev 2488, trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py) =================================================================== --- trunk/Lib/sandbox/timeseries/mtimeseries/tseries.py 2007-01-04 16:42:30 UTC (rev 2488) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-14 22:39:15 UTC (rev 2552) @@ -0,0 +1,1242 @@ +# 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. + +These two classes were liberally adapted from `MaskedArray` class. + + + +: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 logging +import weakref + + +import numpy +from numpy import ndarray +from numpy.core import bool_, complex_, float_, int_, object_ +import numpy.core.fromnumeric as fromnumeric +import numpy.core.numeric as numeric +import numpy.core.umath as umath +#from numpy.core.records import recarray +from numpy.core.records import fromarrays as recfromarrays + +import maskedarray as MA +#reload(MA) +#MaskedArray = MA.MaskedArray +from maskedarray.core import MaskedArray, MAError, masked, nomask, \ + filled, getmask, getmaskarray, make_mask_none, mask_or, make_mask, \ + masked_array + +import tcore as corelib +#reload(corelib) +from tcore import * + +import tdates +#reload(tdates) +from tdates import DateError, InsufficientDateError +from tdates import Date, isDate, DateArray, isDateArray, \ + date_array, date_array_fromlist, date_array_fromrange, thisday + +import cseries +#reload(cseries) + +#............................................................................... +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) +talog = logging.getLogger('log.TimeArray') +tslog = logging.getLogger('TimeSeries') +btslog = logging.getLogger('BaseTimeSeries') + +ufunc_domain = {} +ufunc_fills = {} + +#### -------------------------------------------------------------------------- +#--- ... TimeSeriesError class ... +#### -------------------------------------------------------------------------- +class TimeSeriesError(Exception): + "Class for TS related errors." + def __init__ (self, args=None): + "Creates an exception." + Exception.__init__(self) + self.args = args + def __str__(self): + "Calculates the string representation." + return str(self.args) + __repr__ = __str__ + +class TimeSeriesCompatibilityError(TimeSeriesError): + """Defines the exception raised when series are incompatible.""" + def __init__(self, mode, first, second): + if mode == 'freq': + msg = "Incompatible time steps! (%s <> %s)" + elif mode == 'start_date': + msg = "Incompatible starting dates! (%s <> %s)" + elif mode == 'size': + msg = "Incompatible sizes! (%s <> %s)" + msg = msg % (first, second) + TimeSeriesError.__init__(self, msg) + + +#def _compatibilitycheck(a, b): +def _timeseriescompat(a, b): + """Checks the date compatibility of two TimeSeries object. + Returns True if everything's fine, or raises an exception.""" + if not (hasattr(a,'freq') and hasattr(b, 'freq')): + return True + if a.freq != b.freq: + raise TimeSeriesCompatibilityError('freq', a.freq, b.freq) + elif a.start_date() != b.start_date(): + raise TimeSeriesCompatibilityError('start_date', + a.start_date(), b.start_date()) + elif (a._dates.get_steps() != b._dates.get_steps()).any(): + 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), + "2: %s" % str(b.shape)) + return True + +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.""" + # If there's only 1 element, the date is a Date object, which has no size... + tsize = numeric.size(dates) + dsize = data.size + # Only one data + if dsize == tsize: + return True + elif data.ndim > 1: + dsize = numeric.asarray(data.shape)[:-1].prod() + if dsize == tsize: + return True + raise TimeSeriesCompatibilityError('size', "data: %s" % dsize, + "dates: %s" % tsize) + +def _getdatalength(data): + "Estimates the length of a series (size/nb of variables)." + if numeric.ndim(data) >= 2: + return numeric.asarray(numeric.shape(data))[:-1].prod() + else: + return numeric.size(data) + +##### -------------------------------------------------------------------------- +##--- ... Time Series ... +##### -------------------------------------------------------------------------- +#if oldma: +# parentclass = ndarray +#else: +# parentclass = MaskedArray +# +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. + """ + def __new__(cls, data, dates=None, mask=nomask, + freq=None, observed=None, start_date=None, + dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False): + #tslog.info("__new__: received data types %s, %s" % (type(data), data)) + options = dict(copy=copy, dtype=dtype, fill_value=fill_value, + keep_mask=keep_mask, small_mask=small_mask, + hard_mask=hard_mask, ) + if isinstance(data, TimeSeries): + # Check dates ........ + if dates is None: + newdates = data._dates + else: + if not hasattr(dates,'freq'): + raise DateError, "Invalid Dates!" + newdates = dates + data._dates = newdates + if hasattr(data, '_data') and hasattr(data._data, '_dates'): + data._data._dates = newdates + cls._defaultdates = newdates + # Check frequency...... + if freq is not None: + freq = corelib.fmtFreq(freq) + if freq != newdates.freq: + _dates = newdates.tofreq(freq) + else: + freq = newdates.freq + # Check observed....... + if observed is not None: + observed = data._observed + cls._defaultobserved = observed + _data = data._series + else: + # Check dates ........ + if dates is None: + length = _getdatalength(data) + newdates = date_array(start_date=start_date, length=length, + freq=freq) + elif not hasattr(dates, 'freq'): + newdates = date_array(dlist=dates, freq=freq) + else: + newdates = dates + _data = data + if hasattr(data, '_mask') : + mask = mask_or(data._mask, mask) + cls._defaultdates = newdates + cls._defaultobserved = observed +# if oldma: +# newdata = MaskedArray(data, mask=mask, dtype=dtype, +# copy=copy,fill_value=fill_value) +# cls._defaultmask = newdata._mask +# cls._defaulthardmask = True +# cls._fill_value = newdata._fill_value +# assert(_datadatescompat(newdata,dates)) +# return ndarray.__new__(cls,shape=newdata.shape,dtype=newdata.dtype, +# buffer=newdata._data) +# _data = data +# newdata = MaskedArray.__new__(cls, data=_data, mask=mask, **options) + newdata = super(TimeSeries,cls).__new__(cls, _data, mask=mask, + **options) + assert(_datadatescompat(data,newdates)) + return newdata + + #.................................. + def __array_wrap__(self, obj, context=None): +# if oldma: +# tmpself = MaskedArray(self._data, mask=self._mask) +# return TimeSeries(MaskedArray.__array_wrap__(tmpself, obj, context), +# dates=self._dates) +# print "__array_wrap__" + return TimeSeries(super(TimeSeries,self).__array_wrap__(obj, context), + dates=self._dates) + #............................................ + def __array_finalize__(self,obj): + #tslog.info("__array_finalize__ received %s" % type(obj)) + if isinstance(obj, TimeSeries): + self._dates = obj._dates + self._data = obj._series._data + self._mask = obj._series._mask + self._series = obj._series + self._hardmask = obj._series._hardmask + self.observed = obj.observed + self._fill_value = obj._fill_value + else: + self._dates = self._defaultdates + self.observed = self._defaultobserved + self._series = MA.array(obj, mask=self._defaultmask, + copy=False, hard_mask=self._defaulthardmask) + self._mask = self._defaultmask + self._data = obj + self._hardmask = self._defaulthardmask + self.fill_value = self._fill_value + self._mask = self._series._mask + self._data = self._series._data + self._hardmask = self._series._hardmask + #tslog.info("__array_finalize__ sends %s" % type(self)) + return + #............................................ + def __getattribute__(self,attr): + "Returns a given attribute." + # Here, we need to be smart: _mask should call _series._mask... + if attr in ['_data','_mask','_hardmask']: + return getattr(self._series,attr) + return super(TimeSeries, self).__getattribute__(attr) + + def __setattribute__(self,attr, value): + """Sets an attribute to a given value.""" + # Same thing here: if we modify ._mask, we need to modify _series._mask + # ...as well + super(TimeSeries, self).__setattribute__(attr, value) + if attr in ['_data','_mask','_hardmask']: + super(self._series.__class__, self._series).__setattribute__(attr, value) + setattr(self._series, attr, value) + #............................................ + def __checkindex(self, index): + "Checks the validity of an index." + if isinstance(index, int): + return index + if isinstance(index, str): + return self._dates.date_to_index(Date(self._dates.freq, string=index)) + elif isDate(index) or isDateArray(index): + return self._dates.date_to_index(index) + elif isinstance(index,slice): + slice_start = self.__checkindex(index.start) + slice_stop = self.__checkindex(index.stop) + return slice(slice_start, slice_stop, index.step) + elif isTimeSeries(index): + index = index._series + if getmask(index) is not nomask: + msg = "Masked arrays must be filled before they can be used as indices!" + raise IndexError, msg + return index + + def __getitem__(self, index): + """x.__getitem__(y) <==> x[y] +Returns the item described by i. Not a copy as in previous versions. + """ + index = self.__checkindex(index) + data = self._series[index] + date = self._dates[index] + m = self._mask + scalardata = (len(numeric.shape(data))==0) + # + if m is nomask: + if scalardata: + return TimeSeries(data, dates=date) + else: + return TimeSeries(data, dates=date, mask=nomask, keep_mask=True, + copy=False) + #.... + mi = m[index] + if mi.size == 1: + if mi: + return TimeSeries(data, dates=date, mask=True) + return TimeSeries(data, dates=date, mask=nomask) + else: + return TimeSeries(data, dates=date, mask=mi) + #........................ + def __setitem__(self, index, value): + """x.__setitem__(i, y) <==> x[i]=y +Sets item described by index. If value is masked, masks those locations. + """ + if self is masked: + raise MAError, 'Cannot alter the masked element.' + index = self.__checkindex(index) + #.... + if isinstance(value, TimeSeries): + assert(_timeseriescompat(self[index], value)) + self._series[index] = value._series + else: + self._series[index] = value + # Don't forget to update the mask ! + self._mask = self._series._mask + + #........................ + def __getslice__(self, i, j): + "Gets slice described by i, j" + i = self.__checkindex(i) + j = self.__checkindex(j) + (data, date) = (self._series[i:j], self._dates[i:j]) + return TimeSeries(data, dates=date, copy=False) + #.... + def __setslice__(self, i, j, value): + "Gets item described by i. Not a copy as in previous versions." + i = self.__checkindex(i) + j = self.__checkindex(j) + #.... + data = self._series[i:j] + if isinstance(value, TimeSeries): + assert(_timeseriescompat(self[i:j], value)) + self._series[i:j] = value._series + else: + self._series[i:j] = value + # Don't forget to update the mask ! + self._mask = self._series._mask + #...................................................... + def __len__(self): + if self.ndim == 0: + return 0 + return ndarray.__len__(self) + #...................................................... + def __str__(self): + """Returns a string representation of self (w/o the dates...)""" + return str(self._series) + def __repr__(self): + """Calculates the repr representation, using masked for fill if + it is enabled. Otherwise fill with fill value. + """ + desc = """\ +timeseries(data = + %(data)s, + dates = + %(time)s, + freq = %(freq)s) +""" + desc_short = """\ +timeseries(data = %(data)s, + dates = %(time)s, + freq = %(freq)s) +""" + if numeric.size(self._dates) > 2 and self.isvalid(): + timestr = "[%s ... %s]" % (str(self._dates[0]),str(self._dates[-1])) + else: + timestr = str(self.dates) + + if self.ndim <= 1: + return desc_short % {'data': str(self._series), + 'time': timestr, + 'freq': self.freq, } + return desc % {'data': str(self._series), + 'time': timestr, + 'freq': self.freq, } + #............................................ + def _get_mask(self): + """Returns the current mask.""" + return self._series._mask + def _set_mask(self, mask): + """Sets the mask to `mask`.""" + mask = make_mask(mask, copy=False, small_mask=True) + if mask is not nomask: + if mask.size != self._data.size: + raise ValueError, "Inconsistent shape between data and mask!" + if mask.shape != self._data.shape: + mask.shape = self._data.shape + self._series._mask = mask + else: + self._series._mask = nomask + mask = property(fget=_get_mask, fset=_set_mask, doc="Mask") + + def ids (self): + """Return the ids of the data, dates and mask areas""" + return (id(self._series), id(self.dates),) + + def copy(self): + "Returns a copy of the TimeSeries." + return TimeSeries(self, copy=True) + + #------------------------------------------------------ + @property + def series(self): + "Returns the series." + return self._series + @property + def dates(self): + """Returns the dates""" + return self._dates + @property + def freq(self): + """Returns the corresponding frequency.""" + return self._dates.freq +# @property + def years(self): + """Returns the corresponding years.""" + return self._dates.years +# @property + def months(self): + """Returns the corresponding months.""" + return self._dates.months +# @property + def yeardays(self): + """Returns the corresponding days of year.""" + return self._dates.yeardays + day_of_year = yeardays +# @property + def weekdays(self): + """Returns the corresponding days of weeks.""" + return self._dates.day_of_week + day_of_week = weekdays + + def start_date(self): + """Returns the first date of the series.""" + return self._dates[0] +# + def end_date(self): + """Returns the last date of the series.""" + return self._dates[-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) + #..................................................... + 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', interp=None): + "Converts the dates to another frequency, and adapt the data." + return convert(self, freq, func=func, position=position, interp=interp) + +##### -------------------------------------------------------------------------- +##--- ... Additional methods ... +##### -------------------------------------------------------------------------- +class _inplacemethod(object): + """Defines a wrapper for inplace arithmetic array methods (iadd, imul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + self.obj = None + # + def __get__(self, obj, objtype=None): + "Gets the calling object." + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + assert(_timeseriescompat(instance,other)) + func = getattr(instance._series, self.f) + func(other, *args) + return instance +#...................................... +TimeSeries.__iadd__ = _inplacemethod('__iadd__') +TimeSeries.__iand__ = _inplacemethod('__iand__') +TimeSeries.__idiv__ = _inplacemethod('__idiv__') +TimeSeries.__isub__ = _inplacemethod('__isub__') +TimeSeries.__imul__ = _inplacemethod('__imul__') + + +class _tsmathmethod(object): + """Defines a wrapper for arithmetic array methods (add, mul...). +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +The `_dates` part remains unchanged. + """ + def __init__ (self, binop): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self.f = binop + # + def __get__(self, obj, objtype=None): + "Gets the calling object." + self.obj = obj + return self + # + def __call__ (self, other, *args): + "Execute the call behavior." + instance = self.obj + _dates = instance._dates + #tslog.info("_tsmathmethod: series: %s" % instance,) + #tslog.info("_tsmathmethod: other : %s" % other,) + func = getattr(instance._series, self.f) + if isinstance(other, TimeSeries): + assert(_timeseriescompat(instance, other)) + return instance.__class__(func(other, *args), dates=_dates,) +#...................................... +TimeSeries.__add__ = _tsmathmethod('__add__') +TimeSeries.__radd__ = _tsmathmethod('__add__') +TimeSeries.__sub__ = _tsmathmethod('__sub__') +TimeSeries.__rsub__ = _tsmathmethod('__rsub__') +TimeSeries.__pow__ = _tsmathmethod('__pow__') +TimeSeries.__mul__ = _tsmathmethod('__mul__') +TimeSeries.__rmul__ = _tsmathmethod('__mul__') +TimeSeries.__div__ = _tsmathmethod('__div__') +TimeSeries.__rdiv__ = _tsmathmethod('__rdiv__') +TimeSeries.__truediv__ = _tsmathmethod('__truediv__') +TimeSeries.__rtruediv__ = _tsmathmethod('__rtruediv__') +TimeSeries.__floordiv__ = _tsmathmethod('__floordiv__') +TimeSeries.__rfloordiv__ = _tsmathmethod('__rfloordiv__') +TimeSeries.__eq__ = _tsmathmethod('__eq__') +TimeSeries.__ne__ = _tsmathmethod('__ne__') +TimeSeries.__lt__ = _tsmathmethod('__lt__') +TimeSeries.__le__ = _tsmathmethod('__le__') +TimeSeries.__gt__ = _tsmathmethod('__gt__') +TimeSeries.__ge__ = _tsmathmethod('__ge__') +#................................................ +class _tsarraymethod(object): + """Defines a wrapper for basic array methods. +When called, returns a new TimeSeries object, with the new series the result of +the method applied on the original series. +If `ondates` is True, the same operation is performed on the `_dates`. +If `ondates` is False, the `_dates` part remains unchanged. + """ + def __init__ (self, methodname, ondates=False): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + self._ondates = ondates + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args): + "Execute the call behavior." + _name = self._name + instance = self.obj + func_series = getattr(instance._series, _name) + if self._ondates: + func_dates = getattr(instance._dates, _name) + return instance.__class__(func_series(*args), + dates=func_dates(*args)) + else: + return instance.__class__(func_series(*args), + dates=instance._dates) +#TimeSeries.astype = _tsarraymethod('astype') +TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) +TimeSeries.copy = _tsarraymethod('copy', ondates=True) +TimeSeries.compress = _tsarraymethod('compress', ondates=True) +TimeSeries.ravel = _tsarraymethod('ravel', ondates=True) +TimeSeries.filled = _tsarraymethod('filled', ondates=False) +TimeSeries.cumsum = _tsarraymethod('cumsum',ondates=False) +TimeSeries.cumprod = _tsarraymethod('cumprod',ondates=False) +TimeSeries.anom = _tsarraymethod('anom',ondates=False) + +#...................................... +class _tsaxismethod(object): + """Defines a wrapper for array methods working on an axis (mean...). +When called, returns a ndarray, as the result of the method applied on the series. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + "Execute the call behavior." + (_dates, _series) = (self.obj._dates, self.obj._series) + func = getattr(_series, self._name) + result = func(*args, **params) + if _series.ndim < 2 or _dates.size == _series.size: + return result + else: + try: + axis = params.get('axis', args[0]) + if axis in [-1, _series.ndim-1]: + result = TimeSeries(result, dates=_dates) + except IndexError: + pass + return result +#....................................... +TimeSeries.sum = _tsaxismethod('sum') +TimeSeries.prod = _tsaxismethod('prod') +TimeSeries.mean = _tsaxismethod('mean') +TimeSeries.var = _tsaxismethod('var') +TimeSeries.varu = _tsaxismethod('varu') +TimeSeries.std = _tsaxismethod('std') +TimeSeries.stdu = _tsaxismethod('stdu') + +class _tsblockedmethods(object): + """Defines a wrapper for array methods that should be temporarily disabled. + """ + def __init__ (self, methodname): + """abfunc(fillx, filly) must be defined. + abinop(x, filly) = x for all x to enable reduce. + """ + self._name = methodname + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, *args, **params): + raise NotImplementedError +TimeSeries.transpose = _tsarraymethod('transpose', ondates=True) +TimeSeries.swapaxes = _tsarraymethod('swapaxes', ondates=True) + + +#####--------------------------------------------------------------------------- +#---- --- 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(TimeSeries, self._methodname).__doc__ + except: + 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') +# +##### --------------------------------------------------------------------------- +#---- ... Additional methods ... +##### --------------------------------------------------------------------------- +def tofile(self, output, sep='\t', format_dates=None): + """Writes the TimeSeries to a file. + +:Parameters: + - `output` (String) : Name or handle of the output file. + - `sep` (String) : Column separator *['\t']*. + - `format` (String) : Data format *['%s']*. + """ + if not hasattr(output, 'writeline'): + ofile = open(output,'w') + else: + ofile = output + 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(), + filled(self)): + ofile.write('%s\n' % sep.join([oformat % (_dates, _data) ])) + ofile.close() +TimeSeries.tofile = tofile + +#............................................ +def asrecords(series): + """Returns the masked time series as a recarray. +Fields are `_dates`, `_data` and _`mask`. + """ + desctype = [('_dates',int_), ('_series',series.dtype), ('_mask', bool_)] + flat = series.ravel() + _dates = numeric.asarray(flat._dates) + if flat.size > 0: + return recfromarrays([_dates, flat._data, getmaskarray(flat)], + dtype=desctype, + shape = (flat.size,), + ) + else: + return recfromarrays([[], [], []], dtype=desctype, + shape = (flat.size,), + ) +TimeSeries.asrecords = asrecords + +def flatten(series): + """Flattens a (multi-) time series to 1D series.""" + shp_ini = series.shape + # Already flat time series.... + if len(shp_ini) == 1: + return series + # Folded single time series .. + newdates = series._dates.ravel() + if series._dates.size == series._series.size: + newshape = (series._series.size,) + else: + newshape = (numeric.asarray(shp_ini[:-1]).prod(), shp_ini[-1]) + newseries = series._series.reshape(newshape) + return time_series(newseries, newdates) +TimeSeries.flatten = flatten + + + +#####--------------------------------------------------------------------------- +#---- --- Archiving --- +#####--------------------------------------------------------------------------- +def _tsreconstruct(baseclass, datesclass, baseshape, basetype, fill_value): + """Internal function that builds a new TimeSeries from the information stored +in a pickle.""" +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + _series = ndarray.__new__(ndarray, baseshape, basetype) + _dates = ndarray.__new__(datesclass, baseshape, int_) + _mask = ndarray.__new__(ndarray, baseshape, bool_) + return baseclass.__new__(baseclass, _series, dates=_dates, mask=_mask, + dtype=basetype, fill_value=fill_value) +# +def _tsgetstate(a): + "Returns the internal state of the TimeSeries, for pickling purposes." +# raise NotImplementedError,"Please use timeseries.archive/unarchive instead.""" + records = a.asrecords() + state = (1, + a.shape, + a.dtype, + a.freq, + records.flags.fnc, + a.fill_value, + records + ) + return state +# +def _tssetstate(a, 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 + - a binary string for the data + - a binary string for the mask. + """ + (ver, shp, typ, frq, isf, flv, rec) = state + a.fill_value = flv + a._dates = a._dates.__class__(rec['_dates'], freq=frq) + (a._dates).__tostr = None + _data = rec['_series'].view(typ) + _mask = rec['_mask'].view(MA.MaskType) + a._series = masked_array(_data, mask=_mask) +# a._data.shape = shp +# a._dates.shape = shp +# a._mask = rec['_mask'].view(MA.MaskType) +# a._mask.shape = shp +# +def _tsreduce(a): + """Returns a 3-tuple for pickling a MaskedArray.""" + return (_tsreconstruct, + (a.__class__, a.dates.__class__, (0,), 'b', -9999), + a.__getstate__()) +# +TimeSeries.__getstate__ = _tsgetstate +TimeSeries.__setstate__ = _tssetstate +TimeSeries.__reduce__ = _tsreduce +#TimeSeries.__dump__ = dump +#TimeSeries.__dumps__ = dumps + + +##### ------------------------------------------------------------------------- +#---- --- TimeSeries creator --- +##### ------------------------------------------------------------------------- +def time_series(data, dates=None, freq=None, observed=None, + start_date=None, end_date=None, length=None, include_last=True, + mask=nomask, + 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` : + Array of data. + """ + if dates is None: + length = _getdatalength(data) + dates = date_array(start_date=start_date, end_date=end_date, + length=length, include_last=include_last, 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, + hard_mask=hard_mask,) + + +def isTimeSeries(series): + "Returns whether the series is a valid TimeSeries object." + return isinstance(series, TimeSeries) + +##### -------------------------------------------------------------------------- +#---- ... Additional functions ... +##### -------------------------------------------------------------------------- +def mask_period(data, start_date=None, end_date=None, + inside=True, include_edges=True, inplace=True): + """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 + `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]* + Whether the dates inside the range should be masked. If not, masks outside. + `include_edges` : Boolean *[True]* + Whether the starting and ending dates should be masked. + `inplace` : Boolean *[True]* + Whether the data mask should be modified in place. If not, returns a new + TimeSeries. +""" + if not isTimeSeries(data): + raise ValueError,"Data should be a valid TimeSeries!" + # Check the starting date .............. + if start_date is None: + start_date = data._dates[0] + elif isinstance(start_date, str): + start_date = Date(data.freq, string=start_date) + elif not isDateType(start_date): + raise DateError,"Starting date should be a valid date!" + start_date = max(start_date, data.dates[0]) + # Check the ending date ................ + if end_date is None: + end_date = data._dates[-1] + elif isinstance(end_date, str): + end_date = Date(data.freq, string=end_date) + elif not isDateType(end_date): + raise DateError,"Starting date should be a valid date!" + end_date = min(end_date, data.dates[-1]) + # Constructs the selection mask ......... + if inside: + if include_edges: + selection = (data.dates >= start_date) & (data.dates <= end_date) + else: + selection = (data.dates > start_date) & (data.dates < end_date) + else: + if include_edges: + selection = (data.dates <= start_date) | (data.dates >= end_date) + 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 + else: + return TimeSeries(data, mask=selection, keep_mask=True) + return data + +def mask_inside_period(data, start_date=None, end_date=None, + include_edges=True, inplace=True): + """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): + """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) +#.......................................................... +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, + the new series is NOT a copy. + """ + # Series validity tests ..................... + if not isinstance(a, TimeSeries): + raise TypeError,"Argument should be a valid TimeSeries object!" + if a.freq == 'U': + raise TimeSeriesError, \ + "Cannot adjust a series with 'Undefined' frequency." + if not a.dates.isvalid(): + raise TimeSeriesError, \ + "Cannot adjust a series with missing or duplicated dates." + # Flatten the series if needed .............. + a = a.flatten() + shp_flat = a.shape + # Dates validity checks .,................... + msg = "%s should be a valid Date instance! (got %s instead)" + (dstart, dend) = a.dates[[0,-1]] + if start_date is None: + start_date = dstart + start_lag = 0 + else: + if not isDateType(start_date): + raise TypeError, msg % ('start_date', type(start_date)) + start_lag = start_date - dstart + #.... + if end_date is None: + end_date = dend + end_lag = 0 + else: + if not isDateType(end_date): + raise TypeError, msg % ('end_date', type(end_date)) + end_lag = end_date - dend + # Check if the new range is included in the old one + if start_lag >= 0: + if end_lag == 0: + return a[start_lag:] + elif end_lag < 0: + 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) + + newdata = masked_array(numeric.empty(newshape, dtype=a.dtype), mask=True) + newseries = TimeSeries(newdata, newdates) + start_date = max(start_date, dstart) + end_date = min(end_date, dend) + 1 + newseries[start_date:end_date] = a[start_date:end_date] + return newseries +#.................................................................... +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. + """ + if len(series) < 2: + return series + unique_freqs = numpy.unique([x.freq for x in series]) + try: + common_freq = unique_freqs.item() + except ValueError: + raise TimeSeriesError, \ + "All series must have same frequency!" + if common_freq == 'U': + raise TimeSeriesError, \ + "Cannot adjust a series with 'Undefined' frequency." + 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])) + if isinstance(start_date,str): + start_date = Date(common_freq, string=start_date) + end_date = kwargs.pop('end_date', max([x.end_date() for x in series])) + 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', interp=None): + """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 + appropriate function is determined based on the observed attribute + 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 + placed at the end of the month). Interp is the method that will be used + to fill in the gaps. Valid values are "CUBIC", "LINEAR", "CONSTANT", "DIVIDED", + and None. + + Note: interp currently not implemented + """ + if not isinstance(series,TimeSeries): + raise TypeError, "The argument should be a valid TimeSeries!" + if not series.isvalid(): + raise TimeSeriesError, \ + "Cannot adjust a series with missing or duplicated dates." + + if position.upper() not in ('END','START'): + raise ValueError("invalid value for position argument: (%s)",str(position)) + + toFreq = corelib.fmtFreq(freq) + fromFreq = series.freq + start_date = series._dates[0] + + if fromFreq == toFreq: + return series.copy() + + if series.size == 0: + return TimeSeries(series, freq=toFreq, + start_date=start_date.asfreq(toFreq)) + if func == 'auto': + func = corelib.obs_dict[series.observed] + + tempData = series._series.filled() + tempMask = getmaskarray(series) + + cRetVal = cseries.reindex(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: + tempData = MA.apply_along_axis(func, -1, tempData) + +# newEnd = series._dates[-1].asfreq(toFreq, "AFTER") + + newseries = TimeSeries(tempData, freq=toFreq, + observed=series.observed, + start_date=start_date) + return newseries +# return adjust_endpoints(newseries, end_date=newEnd) +TimeSeries.convert = convert +#.................................................................... +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 +`fill_value`. + +:Parameters: + `data` + Initial array of data. + `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 = corelib.fmtFreq(freq) + if freq == 'U': + raise ValueError,\ + "Unable to define a proper date resolution (found %s)." % freq + if dates is None: + if not isTimeSeries(data): + raise InsufficientDateError + dates = data._dates + freq = dates.freq + datad = data._series._data + datam = data._series._mask +# if fill_value is None: +# fill_value = data._fill_value + elif not isinstance(dates, DateArray): + dates = DateArray(dates, freq) + if isinstance(data, MaskedArray): + datad = data._data + datam = data._mask + else: + datad = data + datam = nomask + dflat = dates.asfreq(freq).ravel() + n = len(dflat) + if not dflat.has_missing_dates(): + return time_series(data, dflat) + + # ...and now, fill it ! ...... + (tstart, tend) = dflat[[0,-1]] + newdates = date_array(start_date=tstart, end_date=tend, include_last=True) + nsize = newdates.size + #............................. + # 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) for (i,e) in numpy.broadcast(slcid[:-1],slcid[1:])]) + addidx = delta[gap].astype(int_).cumsum() + newslc = numpy.r_[[oldslc[0]], + [slice(i+d,e+d) for (i,e,d) in \ + numpy.broadcast(slcid[1:-1],slcid[2:],addidx)] + ] + #............................. + # Just a quick check + vdflat = numeric.asarray(dflat) + vnewdates = numeric.asarray(newdates) + for (osl,nsl) in zip(oldslc,newslc): + assert numpy.equal(vdflat[osl],vnewdates[nsl]).all(),\ + "Slicing mishap ! Please check %s (old) and %s (new)" % (osl,nsl) + #............................. + data = MA.asarray(data) + newdatad = numeric.empty(nsize, data.dtype) + newdatam = numeric.ones(nsize, bool_) +# if fill_value is None: +# if hasattr(data,'fill_value'): +# fill_value = data.fill_value +# else: +# fill_value = MA.default_fill_value(data) + #data = data.filled(fill_value) + #.... + if datam is nomask: + for (new,old) in zip(newslc,oldslc): + newdatad[new] = datad[old] + newdatam[new] = False + else: + 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) + # Get new shape .............. + if data.ndim == 1: + nshp = (newdates.size,) + else: + nshp = tuple([-1,] + list(data.shape[1:])) + return time_series(newdata.reshape(nshp), newdates) + + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + from maskedarray.testutils import assert_equal + if 0: + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array(dlist) + data = masked_array(numeric.arange(15, dtype=float_), mask=[1,0,0,0,0]*3) +# btseries = BaseTimeSeries(data._data, dates) + tseries = time_series(data, dlist) + dseries = numpy.log(tseries) + if 1: + mlist = ['2005-%02i' % i for i in range(1,13)] + mlist += ['2006-%02i' % i for i in range(1,13)] + mdata = numpy.arange(24) + mser1 = time_series(mdata, mlist, observed='SUMMED') + # + mlist2 = ['2004-%02i' % i for i in range(1,13)] + mlist2 += ['2005-%02i' % i for i in range(1,13)] + mser2 = time_series(mdata, mlist2, observed='SUMMED') + # + today = thisday('m') + (malg1,malg2) = aligned(mser1, mser2) + + C = convert(mser2,'A') + D = convert(mser2,'A',func=None) + + if 0: + dlist = ['2007-01-%02i' % i for i in range(1,16)] + dates = date_array(dlist) + print "."*50+"\ndata" + data = masked_array(numeric.arange(15)-6, mask=[1,0,0,0,0]*3) + print "."*50+"\nseries" + tseries = time_series(data, dlist) + + if 1: + dlist_1 = ['2007-01-%02i' % i for i in range(1,8)] + dlist_2 = ['2007-01-%02i' % i for i in numpy.arange(1,28)[::4]] + data = masked_array(numeric.arange(7), mask=[1,0,0,0,0,0,0]) + tseries_1 = time_series(data, dlist_1) + tseries_2 = time_series(data, dlist_2) + tseries_3 = time_series(data[::-1], dlist_2) + + try: + tseries = tseries_1 + tseries_2 + except TimeSeriesCompatibilityError: + print "I knew it!" + tseries = tseries_2 + tseries_3 + assert_equal(tseries._dates, tseries_3._dates) + assert_equal(tseries._mask, [1,0,0,0,0,0,1]) + + if 1: + mser3 = time_series(MA.mr_[malg1._series, 100+malg2._series].reshape(2,-1).T, + dates=malg1.dates) + data = mser3._series._data + Property changes on: trunk/Lib/sandbox/timeseries/tseries.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Sun Jan 14 17:42:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 16:42:38 -0600 (CST) Subject: [Scipy-svn] r2553 - trunk/Lib/sandbox/timeseries Message-ID: <20070114224238.3DD1039C049@new.scipy.org> Author: pierregm Date: 2007-01-14 16:42:36 -0600 (Sun, 14 Jan 2007) New Revision: 2553 Removed: trunk/Lib/sandbox/timeseries/build/ trunk/Lib/sandbox/timeseries/old/ Log: oops, a build dir was still around... From scipy-svn at scipy.org Sun Jan 14 17:48:14 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 16:48:14 -0600 (CST) Subject: [Scipy-svn] r2554 - trunk/Lib/sandbox/timeseries/archived_version Message-ID: <20070114224814.A171339C049@new.scipy.org> Author: pierregm Date: 2007-01-14 16:48:12 -0600 (Sun, 14 Jan 2007) New Revision: 2554 Added: trunk/Lib/sandbox/timeseries/archived_version/shiftingarray.py Log: moved shiftingarray from old to archived_version Copied: trunk/Lib/sandbox/timeseries/archived_version/shiftingarray.py (from rev 2551, trunk/Lib/sandbox/timeseries/old/shiftingarray.py) From scipy-svn at scipy.org Sun Jan 14 19:24:06 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 14 Jan 2007 18:24:06 -0600 (CST) Subject: [Scipy-svn] r2555 - in trunk/Lib/sandbox/spline: . tests Message-ID: <20070115002406.8407E39C049@new.scipy.org> Author: jtravs Date: 2007-01-14 18:23:52 -0600 (Sun, 14 Jan 2007) New Revision: 2555 Added: trunk/Lib/sandbox/spline/tests/dierckx_test_data.py trunk/Lib/sandbox/spline/tests/test_fitpack.py trunk/Lib/sandbox/spline/tests/test_spline.py Removed: trunk/Lib/sandbox/spline/tests/demos_xplt.py trunk/Lib/sandbox/spline/tests/test_fitpack.py trunk/Lib/sandbox/spline/tests/test_interpolate.py Modified: trunk/Lib/sandbox/spline/README.txt trunk/Lib/sandbox/spline/fitpack.py trunk/Lib/sandbox/spline/fitpack.pyf trunk/Lib/sandbox/spline/info.py trunk/Lib/sandbox/spline/spline.py Log: Added unit test suite. Fully converted to f2py. Modified: trunk/Lib/sandbox/spline/README.txt =================================================================== --- trunk/Lib/sandbox/spline/README.txt 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/README.txt 2007-01-15 00:23:52 UTC (rev 2555) @@ -1,16 +1,19 @@ This module is meant to replace the spline functionality of scipy.interpolate. -At the moment the code base is identical with a few minor cosmetic changes. -It does not compile yet! +Changes so far: + 1. removed c wrappers - only usig f2py interface now + 2. several bugs fixed (interface to percur, size of c array in tck) + 3. added 11 unit tests - now fully covered + 3. basic cleanup of the module files and docs + Planned changes are: + 1. possibly rationalise the interface to spline + 2. add further functions from fitpack fortran routines + 3. broaden documentation + 4. more tests -1. remove dependence of f2c generated interface (use only f2py) -2. cleanup! -3. rationalise the interface (particularly the new spline/fitpack2 interface) -4. build comprehensive unit test suite - Hopefully this module will end up in scipy, with scipy.interpolate only then containing the interpolation functions interp1d, interp2d etc. which may depend on the spline module and the new delaunay module (for scattered data). -John Travers +John Travers \ No newline at end of file Modified: trunk/Lib/sandbox/spline/fitpack.py =================================================================== --- trunk/Lib/sandbox/spline/fitpack.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/fitpack.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -18,7 +18,7 @@ NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. Pearu Peterson -Modified by John Travers +Modified by John Travers January 2007 Running test programs: $ python fitpack.py 1 3 # run test programs 1, and 3 @@ -32,39 +32,44 @@ __all__ = ['splrep', 'splprep', 'splev', 'splint', 'sproot', 'spalde', 'bisplrep', 'bisplev'] __version__ = "$Revision$"[10:-1] -import _fitpack + from numpy import atleast_1d, array, ones, zeros, sqrt, ravel, transpose, \ - dot, sin, cos, pi, arange, empty, int32 + dot, sin, cos, pi, arange, empty, int32, where myasarray = atleast_1d -# Try to replace _fitpack interface with -# f2py-generated version +# f2py-generated interface to fitpack import dfitpack +# new class based interface to fitpack +import spline _iermess = {0:["""\ - The spline has a residual sum of squares fp such that abs(fp-s)/s<=0.001""",None], - -1:["""\ + The spline has a residual sum of squares fp such that abs(fp-s)/ + s<=0.001""",None], + -1:["""\ The spline is an interpolating spline (fp=0)""",None], - -2:["""\ + -2:["""\ The spline is weighted least-squares polynomial of degree k. fp gives the upper bound fp0 for the smoothing factor s""",None], - 1:["""\ + 1:["""\ The required storage space exceeds the available storage space. - Probable causes: data (x,y) size is too small or smoothing parameter s is too small (fp>s).""",ValueError], - 2:["""\ + Probable causes: data (x,y) size is too small or smoothing parameter + s is too small (fp>s).""",ValueError], + 2:["""\ A theoretically impossible results when finding a smoothin spline - with fp = s. Probably causes: s too small. (abs(fp-s)/s>0.001)""",ValueError], - 3:["""\ + with fp = s. Probably causes: s too small. + (abs(fp-s)/s>0.001)""",ValueError], + 3:["""\ The maximal number of iterations (20) allowed for finding smoothing spline with fp=s has been reached. Probably causes: s too small. (abs(fp-s)/s>0.001)""",ValueError], - 10:["""\ + 10:["""\ Error on input data""",ValueError], 'unknown':["""\ An error occured""",TypeError]} _iermess2 = {0:["""\ - The spline has a residual sum of squares fp such that abs(fp-s)/s<=0.001""",None], + The spline has a residual sum of squares fp such that + abs(fp-s)/s<=0.001""",None], -1:["""\ The spline is an interpolating spline (fp=0)""",None], -2:["""\ @@ -75,7 +80,8 @@ norm least-squares solution of a rank deficient system.""",None], 1:["""\ The required storage space exceeds the available storage space. - Probably causes: nxest or nyest too small or s is too small. (fp>s)""",ValueError], + Probably causes: nxest or nyest too small or s is too small. + (fp>s)""",ValueError], 2:["""\ A theoretically impossible results when finding a smoothin spline with fp = s. Probably causes: s too small or badly chosen eps. @@ -101,21 +107,19 @@ 'unknown':["""\ An error occured""",TypeError]} -_parcur_cache = {'t': array([],float), 'wrk': array([],float), - 'iwrk':array([],int32), 'u': array([],float),'ub':0,'ue':1} +_parcur_cache = {} def splprep(x,w=None,u=None,ub=None,ue=None,k=3,task=0,s=None,t=None, full_output=0,nest=None,per=0,quiet=1): """Find the B-spline representation of an N-dimensional curve. Description: - - Given a list of N rank-1 arrays, x, which represent a curve in N-dimensional - space parametrized by u, find a smooth approximating spline curve g(u). + Given a list of N rank-1 arrays, x, which represent a curve in + N-dimensional space parametrized by u, find a smooth approximating + spline curve g(u). Uses the FORTRAN routine parcur from FITPACK Inputs: - x -- A list of sample vector arrays representing the curve. u -- An array of parameter values. If not given, these values are calculated automatically as (M = len(x[0])): @@ -124,15 +128,15 @@ u[i] = v[i] / v[M-1] ub, ue -- The end-points of the parameters interval. Defaults to u[0] and u[-1]. - k -- Degree of the spline. Cubic splines are recommended. Even values of - k should be avoided especially with a small s-value. + k -- Degree of the spline. Cubic splines are recommended. Even values + of k should be avoided especially with a small s-value. 1 <= k <= 5. task -- If task==0 find t and c for a given smoothing factor, s. - If task==1 find t and c for another value of the smoothing factor, - s. There must have been a previous call with task=0 or task=1 - for the same set of data. - If task=-1 find the weighted least square spline for a given set of - knots, t. + If task==1 find t and c for another value of the smoothing + factor, s. There must have been a previous call with task=0 + or task=1 for the same set of data. + If task=-1 find the weighted least square spline for a given + set of knots, t. s -- A smoothing condition. The amount of smoothness is determined by satisfying the conditions: sum((w * (y - g))**2,axis=0) <= s where g(x) is the smoothed interpolation of (x,y). The user can use s to @@ -148,12 +152,12 @@ help in determining the storage space. By default nest=m/2. Always large enough is nest=m+k+1. per -- If non-zero, data points are considered periodic with period - x[m-1] - x[0] and a smooth periodic spline approximation is returned. + x[m-1] - x[0] and a smooth periodic spline approximation is + returned. Values of y[m-1] and w[m-1] are not used. quiet -- Non-zero to suppress messages. Outputs: (tck, u, {fp, ier, msg}) - tck -- (t,c,k) a tuple containing the vector of knots, the B-spline coefficients, and the degree of the spline. u -- An array of the values of the parameter. @@ -165,19 +169,14 @@ msg -- A message corresponding to the integer flag, ier. Remarks: - SEE splev for evaluation of the spline and its derivatives. See also: splrep, splev, sproot, spalde, splint - evaluation, roots, integral bisplrep, bisplev - bivariate splines - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ - if task<=0: - _parcur_cache = {'t': array([],float), 'wrk': array([],float), - 'iwrk':array([],int32),'u': array([],float), - 'ub':0,'ue':1} x=myasarray(x) idim,m=x.shape if per: @@ -190,48 +189,56 @@ else: w=myasarray(w) ipar=(u is not None) if ipar: - _parcur_cache['u']=u - if ub is None: _parcur_cache['ub']=u[0] - else: _parcur_cache['ub']=ub - if ue is None: _parcur_cache['ue']=u[-1] - else: _parcur_cache['ue']=ue - else: _parcur_cache['u']=zeros(m,float) + if ub is None: ub=u[0] + if ue is None: ue=u[-1] + else: u=zeros(m,float); ub=ue=0.0 if not (1<=k<=5): raise TypeError, '1<=k=%d<=5 must hold'%(k) if not (-1<=task<=1): raise TypeError, 'task must be either -1,0, or 1' if (not len(w)==m) or (ipar==1 and (not len(u)==m)): raise TypeError,'Mismatch of input dimensions' if s is None: s=m-sqrt(2*m) - if t is None and task==-1: raise TypeError, 'Knots must be given for task=-1' - if t is not None: - _parcur_cache['t']=myasarray(t) - n=len(_parcur_cache['t']) - if task==-1 and n<2*k+2: - raise TypeError, 'There must be at least 2*k+2 knots for task=-1' + if task==-1: + if t is None: raise TypeError, 'Knots must be given for task=-1' + t=myasarray(t) + n=len(t) + if n<2*k+2: + raise TypeError, 'There must be at least 2*k+2 knots for task=-1' if m<=k: raise TypeError, 'm>k must hold' if nest is None: nest=m+2*k - if (task>=0 and s==0) or (nest<0): if per: nest=m+2*k else: nest=m+k+1 nest=max(nest,2*k+3) - u=_parcur_cache['u'] - ub=_parcur_cache['ub'] - ue=_parcur_cache['ue'] - t=_parcur_cache['t'] - wrk=_parcur_cache['wrk'] - iwrk=_parcur_cache['iwrk'] - t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, - nest,wrk,iwrk,per) - _parcur_cache['u']=o['u'] - _parcur_cache['ub']=o['ub'] - _parcur_cache['ue']=o['ue'] - _parcur_cache['t']=t - _parcur_cache['wrk']=o['wrk'] - _parcur_cache['iwrk']=o['iwrk'] - ier,fp,n=o['ier'],o['fp'],len(t) - u=o['u'] - c.shape=idim,n-k-1 - tcku = [t,list(c),k],u + if task==0: + u,ub,ue,n,t,c,fp,wrk,iwrk,ier=dfitpack.parcur_smth0(ipar,idim,u,x, + w,ub,ue,nest,k=k,s=s) + if task==1: + try: + u=_parcur_cache['u'] + ub=_parcur_cache['ub'] + ue=_parcur_cache['ue'] + t=_parcur_cache['t'] + wrk=_parcur_cache['wrk'] + iwrk=_parcur_cache['iwrk'] + n=_parcur_cache['n'] + except KeyError: + raise ValueError, 'task=1 can only be called after task=0' + u,ub,ue,n,t,c,fp,wrk,iwrk,ier=dfitpack.parcur_smth1(ipar,idim,u,x,w, + ub,ue,nest,n,t,wrk,iwrk,k=k,s=s) + if task==-1: + u,ub,ue,n,t,c,fp,ier=dfitpack.parcur_lsq(ipar,idim,u,x,w,ub,ue, + nest,n,t,k=k) + if task>=0: + _parcur_cache['n']=n + _parcur_cache['u']=u + _parcur_cache['ub']=ub + _parcur_cache['ue']=ue + _parcur_cache['t']=t + _parcur_cache['wrk']=wrk + _parcur_cache['iwrk']=iwrk + c.shape=idim,nest + c = c[:][:n-k-1] + tcku = [t[:n],list(c),k],u if ier<=0 and not quiet: print _iermess[ier][0] print "\tk=%d n=%d m=%d fp=%f s=%f"%(k,len(t),m,fp,s) @@ -251,21 +258,20 @@ else: return tcku -_curfit_cache = {'t': array([],float), 'wrk': array([],float), - 'iwrk':array([],int32)} +_splrep_cache = {} +_percur_cache = {} + def splrep(x,y,w=None,xb=None,xe=None,k=3,task=0,s=1e-3,t=None, full_output=0,per=0,quiet=1): """Find the B-spline representation of 1-D curve. Description: - Given the set of data points (x[i], y[i]) determine a smooth spline approximation of degree k on the interval xb <= x <= xe. The coefficients, c, and the knot points, t, are returned. Uses the FORTRAN routine curfit from FITPACK. Inputs: - x, y -- The data points defining a curve y = f(x). w -- Strictly positive rank-1 array of weights the same length as x and y. The weights are used in computing the weighted least-squares spline @@ -303,7 +309,6 @@ quiet -- Non-zero to suppress messages. Outputs: (tck, {fp, ier, msg}) - tck -- (t,c,k) a tuple containing the vector of knots, the B-spline coefficients, and the degree of the spline. @@ -314,36 +319,35 @@ msg -- A message corresponding to the integer flag, ier. Remarks: + See splev for evaluation of the spline and its derivatives. - See splev for evaluation of the spline and its derivatives. - Example: - x = linspace(0, 10, 10) y = sin(x) tck = splrep(x, y) x2 = linspace(0, 10, 200) y2 = splev(x2, tck) plot(x, y, 'o', x2, y2) - + See also: splprep, splev, sproot, spalde, splint - evaluation, roots, integral bisplrep, bisplev - bivariate splines - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ - if task<=0: - _curfit_cache = {} x,y=map(myasarray,[x,y]) m=len(x) if w is None: w=ones(m,float) else: w=myasarray(w) - if not len(w) == m: raise TypeError,' len(w)=%d is not equal to m=%d'%(len(w),m) + if not len(w) == m: + raise TypeError,' len(w)=%d is not equal to m=%d'%(len(w),m) if (m != len(y)) or (m != len(w)): - raise TypeError, 'Lengths of the first three arguments (x,y,w) must be equal' + raise TypeError, 'Lengths of the first three arguments'\ + ' (x,y,w) must be equal' if not (1<=k<=5): - raise TypeError, 'Given degree of the spline (k=%d) is not supported. (1<=k<=5)'%(k) - if m<=k: raise TypeError, 'm>k must hold' + raise TypeError, 'Given degree of the spline (k=%d) is not supported.'\ + ' (1<=k<=5)'%(k) + if m<=k: raise TypeError, 'm>k must hold' if xb is None: xb=x[0] if xe is None: xe=x[-1] if not (-1<=task<=1): raise TypeError, 'task must be either -1,0, or 1' @@ -352,31 +356,41 @@ task = -1 if task == -1: if t is None: raise TypeError, 'Knots must be given for task=-1' - numknots = len(t) - _curfit_cache['t'] = empty((numknots + 2*k+2,),float) - _curfit_cache['t'][k+1:-k-1] = t - nest = len(_curfit_cache['t']) - elif task == 0: - if per: - nest = max(m+2*k,2*k+3) - else: - nest = max(m+k+1,2*k+3) - t = empty((nest,),float) - _curfit_cache['t'] = t - if task <= 0: - _curfit_cache['wrk'] = empty((m*(k+1)+nest*(7+3*k),),float) - _curfit_cache['iwrk'] = empty((nest,),int32) - try: - t=_curfit_cache['t'] - wrk=_curfit_cache['wrk'] - iwrk=_curfit_cache['iwrk'] - except KeyError: - raise TypeError, "must call with task=1 only after"\ - " call with task=0,-1" - if not per: - n,c,fp,ier = dfitpack.curfit(task, x, y, w, t, wrk, iwrk, xb, xe, k, s) - else: - n,c,fp,ier = dfitpack.percur(task, x, y, w, t, wrk, iwrk, k, s) + if per: + if task == 0: + n,t,c,fp,wrk,iwrk,ier = dfitpack.percur_smth0(x,y,w,k=k,s=s) + elif task ==1: + try: + t=_percur_cache['t'] + wrk=_percur_cache['wrk'] + iwrk=_percur_cache['iwrk'] + n=_percur_cache['n'] + except KeyError: + raise ValueError, 'task=1 can only be called after task=0' + n,t,c,fp,wrk,iwrk,ier = dfitpack.percur_smth1(x,y,w,n,t,wrk,iwrk, + k=k,s=s) + elif task==-1: + n,t,c,fp,ier = dfitpack.percur_lsq(x,y,w,n,t,k=k) + if task>=0: + _percur_cache['t']=t + _percur_cache['wrk']=wrk + _percur_cache['iwrk']=iwrk + _percur_cache['n']=n + if task == 0: + spl = spline.UnivariateSpline(x,y,w,[xb,xe],k=k,s=s) + elif task == 1: + try: + spl = _splrep_cache['spl'] + except KeyError: + raise ValueError, 'task=1 can only be called after task=0' + spl.set_smoothing_factor(s) + elif task == -1: + t = t[where(t>xb)] + t = t[where(t=0: + _splrep_cache['spl'] = spl + x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = spl._data tck = (t[:n],c[:n-k-1],k) if ier<=0 and not quiet: print _iermess[ier][0] @@ -397,22 +411,15 @@ else: return tck -def _ntlist(l): # return non-trivial list - return l - #if len(l)>1: return l - #return l[0] - def splev(x,tck,der=0): """Evaulate a B-spline and its derivatives. Description: - Given the knots and coefficients of a B-spline representation, evaluate the value of the smoothing polynomial and it's derivatives. This is a wrapper around the FORTRAN routines splev and splder of FITPACK. Inputs: - x (u) -- a 1-D array of points at which to return the value of the smoothed spline or its derivatives. If tck was returned from splprep, then the parameter values, u should be given. @@ -422,7 +429,6 @@ or equal to k). Outputs: (y, ) - y -- an array of values representing the spline function or curve. If tck was returned from splrep, then this is a list of arrays representing the curve in N-dimensional space. @@ -430,54 +436,59 @@ See also: splprep, splrep, sproot, spalde, splint - evaluation, roots, integral bisplrep, bisplev - bivariate splines - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ t,c,k=tck try: - c[0][0] + c[0][0] # check if c is >1-d return map(lambda c,x=x,t=t,k=k,der=der:splev(x,[t,c,k],der),c) - except: pass + except TypeError: pass # c is 1-d if not (0<=der<=k): raise ValueError,"0<=der=%d<=k=%d must hold"%(der,k) x=myasarray(x) - y,ier=_fitpack._spl_(x,der,t,c,k) + c = c.copy() + c.resize(len(t)) + if (der>0): + y,ier=dfitpack.splder(t,c,k,x,der) + else: + y,ier=dfitpack.splev(t,c,k,x) if ier==10: raise ValueError,"Invalid input data" - if ier: raise TypeError,"An error occurred" + if ier: raise TypeError,"An unkown error occurred" if len(y)>1: return y return y[0] -def splint(a,b,tck,full_output=0): +def splint(a,b,tck,full_output=False): """Evaluate the definite integral of a B-spline. Description: - Given the knots and coefficients of a B-spline, evaluate the definite integral of the smoothing polynomial between two given points. Inputs: - a, b -- The end-points of the integration interval. tck -- A length 3 sequence describing the given spline (See splev). - full_output -- Non-zero to return optional output. + full_output -- True to return optional output. Outputs: (integral, {wrk}) - integral -- The resulting integral. - wrk -- An array containing the integrals of the normalized B-splines defined - on the set of knots. + wrk -- An array containing the integrals of the normalized B-splines + defined on the set of knots. - See also: splprep, splrep, sproot, spalde, splev - evaluation, roots, integral bisplrep, bisplev - bivariate splines - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ t,c,k=tck - try: c[0][0];return _ntlist(map(lambda c,a=a,b=b,t=t,k=k:splint(a,b,[t,c,k]),c)) - except: pass - aint,wrk=_fitpack._splint(t,c,k,a,b) + try: + c[0][0] # check if c is >1-d + return map(lambda c,a=a,b=b,t=t,k=k:splint(a,b,[t,c,k]),c) + except TypeError: pass # c is 1-d + c = c.copy() + c.resize(len(t)) + aint,wrk = dfitpack.splint(t,c,k,a,b) if full_output: return aint,wrk else: return aint @@ -485,38 +496,40 @@ """Find the roots of a cubic B-spline. Description: - Given the knots (>=8) and coefficients of a cubic B-spline return the roots of the spline. Inputs: - tck -- A length 3 sequence describing the given spline (See splev). - The number of knots must be >= 8. The knots must be a montonically - increasing sequence. + The number of knots must be >= 8. The knots must be a + montonically increasing sequence. mest -- An estimate of the number of zeros (Default is 10). Outputs: (zeros, ) - zeros -- An array giving the roots of the spline. See also: splprep, splrep, splint, spalde, splev - evaluation, roots, integral bisplrep, bisplev - bivariate splines - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ t,c,k=tck - if k==4: t=t[1:-1] - if k==5: t=t[2:-2] - try: c[0][0];return _ntlist(map(lambda c,t=t,k=k,mest=mest:sproot([t,c,k],mest),c)) - except: pass + if k != 3: + raise ValueError, "Sproot only valid for cubic bsplines" + try: + c[0][0] # check if c is >1-d + return map(lambda c,t=t,k=k,mest=mest:sproot([t,c,k],mest),c) + except TypeError: pass # c is 1-d if len(t)<8: - raise TypeError,"The number of knots %d>=8"%(len(t)) - z,ier=_fitpack._sproot(t,c,k,mest) + raise TypeError,"The number of knots be >=8" + c = c.copy() + c.resize(len(t)) + z,m,ier=dfitpack.sproot(t,c,mest) if ier==10: - raise TypeError,"Invalid input data. t1<=..<=t41-d + return map(lambda c,x=x,t=t,k=k:spalde(x,[t,c,k]),c) + except TypeError: pass # c is 1-d try: x=x.tolist() except: try: x=list(x) except: x=[x] if len(x)>1: return map(lambda x,tck=tck:spalde(x,tck),x) - d,ier=_fitpack._spalde(t,c,k,x[0]) + c = c.copy() + c.resize(len(t)) + d,ier=dfitpack.spalde(t,c,k,x[0]) if ier==0: return d if ier==10: raise TypeError,"Invalid input data. t(k)<=x<=t(n-k+1) must hold." raise TypeError,"Unknown error" -#def _curfit(x,y,w=None,xb=None,xe=None,k=3,task=0,s=None,t=None, -# full_output=0,nest=None,per=0,quiet=1): -_surfit_cache = {'tx': array([],float),'ty': array([],float), - 'wrk': array([],float), 'iwrk':array([],int32)} +_surfit_cache = {} + def bisplrep(x,y,z,w=None,xb=None,xe=None,yb=None,ye=None,kx=3,ky=3,task=0, s=None,eps=1e-16,tx=None,ty=None,full_output=0, nxest=None,nyest=None,quiet=1): """Find a bivariate B-spline representation of a surface. Description: - Given a set of data points (x[i], y[i], z[i]) representing a surface z=f(x,y), compute a B-spline representation of the surface. Inputs: - x, y, z -- Rank-1 arrays of data points. w -- Rank-1 array of weights. By default w=ones(len(x)). xb, xe -- End points of approximation interval in x. @@ -609,7 +617,6 @@ quiet -- Non-zero to suppress printing of messages. Outputs: (tck, {fp, ier, msg}) - tck -- A list [tx, ty, c, kx, ky] containing the knots (tx, ty) and coefficients (c) of the bivariate B-spline representation of the surface along with the degree of the spline. @@ -621,40 +628,41 @@ msg -- A message corresponding to the integer flag, ier. Remarks: - SEE bisplev to evaluate the value of the B-spline given its tck representation. See also: splprep, splrep, splint, sproot, splev - evaluation, roots, integral - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ x,y,z=map(myasarray,[x,y,z]) x,y,z=map(ravel,[x,y,z]) # ensure 1-d arrays. m=len(x) - if not (m==len(y)==len(z)): raise TypeError, 'len(x)==len(y)==len(z) must hold.' + if not (m==len(y)==len(z)): + raise TypeError, 'len(x)==len(y)==len(z) must hold.' if w is None: w=ones(m,float) else: w=myasarray(w) - if not len(w) == m: raise TypeError,' len(w)=%d is not equal to m=%d'%(len(w),m) + if not len(w) == m: + raise TypeError,' len(w)=%d is not equal to m=%d'%(len(w),m) if xb is None: xb=x.min() if xe is None: xe=x.max() if yb is None: yb=y.min() if ye is None: ye=y.max() if not (-1<=task<=1): raise TypeError, 'task must be either -1,0, or 1' if s is None: s=m-sqrt(2*m) - if tx is None and task==-1: raise TypeError, 'Knots_x must be given for task=-1' - if tx is not None: _surfit_cache['tx']=myasarray(tx) - nx=len(_surfit_cache['tx']) - if ty is None and task==-1: raise TypeError, 'Knots_y must be given for task=-1' - if ty is not None: _surfit_cache['ty']=myasarray(ty) - ny=len(_surfit_cache['ty']) - if task==-1 and nx<2*kx+2: - raise TypeError, 'There must be at least 2*kx+2 knots_x for task=-1' - if task==-1 and ny<2*ky+2: - raise TypeError, 'There must be at least 2*ky+2 knots_x for task=-1' + if task==-1: + if tx is None: raise TypeError, 'Knots_x must be given for task=-1' + _surfit_cache['tx']=myasarray(tx) + if ty is None: raise TypeError, 'Knots_y must be given for task=-1' + _surfit_cache['ty']=myasarray(ty) + if nx<2*kx+2: + raise TypeError,'There must be at least 2*kx+2 knots_x for task=-1' + if ny<2*ky+2: + raise TypeError,'There must be at least 2*ky+2 knots_y for task=-1' if not ((1<=kx<=5) and (1<=ky<=5)): - raise TypeError, 'Given degree of the spline (kx,ky=%d,%d) is not supported. (1<=k<=5)'%(kx,ky) + raise TypeError, 'Given degree of the spline (kx,ky=%d,%d) is not \ + supported. (1<=k<=5)'%(kx,ky) if m<(kx+1)*(ky+1): raise TypeError, 'm>=(kx+1)(ky+1) must hold' if nxest is None: nxest=kx+sqrt(m/2) if nyest is None: nyest=ky+sqrt(m/2) @@ -662,25 +670,39 @@ if task>=0 and s==0: nxest=int(kx+sqrt(3*m)) nyest=int(ky+sqrt(3*m)) - if task==-1: - _surfit_cache['tx']=myasarray(tx) - _surfit_cache['ty']=myasarray(ty) - tx,ty=_surfit_cache['tx'],_surfit_cache['ty'] - wrk=_surfit_cache['wrk'] - iwrk=_surfit_cache['iwrk'] - u,v,km,ne=nxest-kx-1,nyest-ky-1,max(kx,ky)+1,max(nxest,nyest) - bx,by=kx*v+ky+1,ky*u+kx+1 - b1,b2=bx,bx+v-ky - if bx>by: b1,b2=by,by+u-kx - lwrk1=u*v*(2+b1+b2)+2*(u+v+km*(m+ne)+ne-kx-ky)+b2+1 - lwrk2=u*v*(b2+1)+b2 - tx,ty,c,o = _fitpack._surfit(x,y,z,w,xb,xe,yb,ye,kx,ky,task,s,eps, - tx,ty,nxest,nyest,wrk,lwrk1,lwrk2) - _curfit_cache['tx']=tx - _curfit_cache['ty']=ty - _curfit_cache['wrk']=o['wrk'] - ier,fp=o['ier'],o['fp'] - tck=[tx,ty,c,kx,ky] + if task == 0: + nx,tx,ny,ty,c,fp,wrk1,ier = dfitpack.surfit_smth0(x,y,z,w,xb,xe,yb,ye, + kx,ky,s=s,eps=eps, + nxest=nxest,nyest=nyest) + elif task==1: + try: + tx,ty=_surfit_cache['tx'],_surfit_cache['ty'] + nx,ny= _surfit_cache['nx'],_surfit_cache['ny'] + wrk1 = _surfit_cache['wrk1'] + except KeyError: + raise ValueError, 'task=1 can only be called after task=0' + nx,tx,ny,ty,c,fp,wrk1,ier=dfitpack.surfit_smth1(x,y,z,nx,tx,ny,ty,wrk1, + w,xb,xe,yb,ye,kx,ky,s=s,eps=eps, + nxest=nxest,nyest=nyest) + elif task==-1: + tx = myasarray(tx) + ty = myasarray(ty) + tx,ty,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx,ty,w, + xb,xe,yb,ye, + kx,ky,eps, + nxest=nxest,nyest=nyest) + if ier>10: + tx,ty,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx,ty,w,\ + xb,xe,yb,ye,\ + kx,ky,eps,\ + nxest=nxest,nyest=nyest) + if task>=0: + _surfit_cache['tx']=tx + _surfit_cache['ty']=ty + _surfit_cache['nx']=nx + _surfit_cache['ny']=ny + _surfit_cache['wrk1']=wrk1 + tck=[tx[:nx],ty[:ny],c[:(nx-kx-1)*(ny-ky-1)],kx,ky] if ier<=0 and not quiet: print _iermess2[ier][0] print "\tkx,ky=%d,%d nx,ny=%d,%d m=%d fp=%f s=%f"%(kx,ky,len(tx), @@ -708,14 +730,12 @@ """Evaluate a bivariate B-spline and its derivatives. Description: - Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or both are floats. Inputs: - x, y -- Rank-1 arrays specifying the domain over which to evaluate the spline or its derivative. tck -- A sequence of length 5 returned by bisplrep containing the knot @@ -724,17 +744,15 @@ dx, dy -- The orders of the partial derivatives in x and y respectively. Outputs: (vals, ) - vals -- The B-pline or its derivative evaluated over the set formed by the cross-product of x and y. Remarks: - SEE bisprep to generate the tck representation. See also: splprep, splrep, splint, sproot, splev - evaluation, roots, integral - UnivariateSpline, BivariateSpline - an alternative wrapping + UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ tx,ty,c,kx,ky=tck @@ -743,7 +761,10 @@ x,y=map(myasarray,[x,y]) if (len(x.shape) != 1) or (len(y.shape) != 1): raise ValueError, "First two entries should be rank-1 arrays." - z,ier=_fitpack._bispev(tx,ty,c,kx,ky,x,y,dx,dy) + if (dx>0 or dy>0): + z,ier=dfitpack.parder(tx,ty,c,kx,ky,dx,dy,x,y) + else: + z,ier=dfitpack.bispev(tx,ty,c,kx,ky,x,y) if ier==10: raise ValueError,"Invalid input data" if ier: raise TypeError,"An error occurred" z.shape=len(x),len(y) @@ -751,7 +772,6 @@ if len(z[0])>1: return z[0] return z[0][0] - if __name__ == "__main__": import sys,string runtest=range(10) @@ -782,7 +802,7 @@ v,v1=f(x),f(x1) nk=[] for k in range(1,6): - tck=splrep(x,v,s=s,per=per,k=k,nest=-1,xe=xe) + tck=splrep(x,v,s=s,per=per,k=k,xe=xe) if at:t=tck[0][k:-k] else: t=x1 nd=[] @@ -811,7 +831,7 @@ v=f(x) nk=[] for k in range(1,6): - tck=splrep(x,v,s=s,per=per,k=k,nest=-1,xe=xe) + tck=splrep(x,v,s=s,per=per,k=k,xe=xe) nk.append([splint(ia,ib,tck),spalde(dx,tck)]) print "\nf = %s s=S_k(x;t,c) x in [%s, %s] > [%s, %s]"%(f(None), `round(xb,3)`,`round(xe,3)`, @@ -839,9 +859,9 @@ nk=[] print " k : Roots of s(x) approx %s x in [%s,%s]:"%\ (f(None),`round(a,3)`,`round(b,3)`) - for k in range(1,6): - tck=splrep(x,v,s=s,per=per,k=k,nest=-1,xe=xe) - print ' %d : %s'%(k,`sproot(tck).tolist()`) + k=3 + tck=splrep(x,v,s=s,per=per,k=k,xe=xe) + print ' %d : %s'%(k,`sproot(tck).tolist()`) def test4(f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None, ia=0,ib=2*pi,dx=0.2*pi): if xb is None: xb=a @@ -853,8 +873,8 @@ print " u = %s N = %d"%(`round(dx,3)`,N) print " k : [x(u), %s(x(u))] Error of splprep Error of splrep "%(f(0,None)) for k in range(1,6): - tckp,u=splprep([x,v],s=s,per=per,k=k,nest=-1) - tck=splrep(x,v,s=s,per=per,k=k,nest=-1) + tckp,u=splprep([x,v],s=s,per=per,k=k) + tck=splrep(x,v,s=s,per=per,k=k) uv=splev(dx,tckp) print " %d : %s %.1e %.1e"%\ (k,`map(lambda x:round(x,3),uv)`, @@ -862,7 +882,7 @@ abs(splev(uv[0],tck)-f(uv[0]))) print "Derivatives of parametric cubic spline at u (first function):" k=3 - tckp,u=splprep([x,v],s=s,per=per,k=k,nest=-1) + tckp,u=splprep([x,v],s=s,per=per,k=k) for d in range(1,k+1): uv=splev(dx,tckp,d) put(" %s "%(`uv[0]`)) Modified: trunk/Lib/sandbox/spline/fitpack.pyf =================================================================== --- trunk/Lib/sandbox/spline/fitpack.pyf 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/fitpack.pyf 2007-01-15 00:23:52 UTC (rev 2555) @@ -43,7 +43,6 @@ static int imax(int i1,int i2) { return MAX(i1,i2); } - static int calc_surfit_lwrk1(int m, int kx, int ky, int nxest, int nyest) { int u = nxest-kx-1; int v = nyest-ky-1; @@ -64,8 +63,7 @@ int b2 = (bx<=by?bx+v-ky:by+u-kx); return u*v*(b2+1)+b2; } - -static int calc_regrid_lwrk(int mx, int my, int kx, int ky, +static int calc_regrid_lwrk(int mx, int my, int kx, int ky, int nxest, int nyest) { int u = MAX(my, nxest); return 4+nxest*(my+2*kx+5)+nyest*(2*ky+5)+mx*(kx+1)+my*(ky+1)+u; @@ -77,7 +75,7 @@ !!!!!!!!!! Univariate spline !!!!!!!!!!! subroutine splev(t,n,c,k,x,y,m,ier) - ! y = splev(t,c,k,x) + ! y,ier = splev(t,c,k,x) real*8 dimension(n),intent(in) :: t integer intent(hide),depend(t) :: n=len(t) real*8 dimension(n),depend(n,k),check(len(c)==n),intent(in) :: c @@ -85,32 +83,32 @@ real*8 dimension(m),intent(in) :: x real*8 dimension(m),depend(m),intent(out) :: y integer intent(hide),depend(x) :: m=len(x) - integer intent(hide) :: ier + integer intent(out) :: ier end subroutine splev subroutine splder(t,n,c,k,nu,x,y,m,wrk,ier) - ! dy = splder(t,c,k,x,[nu]) + ! dy,ier = splder(t,c,k,x,[nu]) real*8 dimension(n) :: t integer depend(t),intent(hide) :: n=len(t) real*8 dimension(n),depend(n,k),check(len(c)==n),intent(in) :: c integer :: k - integer depend(k),check(0<=nu && nu<=k) :: nu = 1 + integer optional,depend(k),check(0<=nu && nu<=k) :: nu = 1 real*8 dimension(m) :: x real*8 dimension(m),depend(m),intent(out) :: y integer depend(x),intent(hide) :: m=len(x) real*8 dimension(n),depend(n),intent(cache,hide) :: wrk - integer intent(hide) :: ier + integer intent(out) :: ier end subroutine splder function splint(t,n,c,k,a,b,wrk) - ! iy = splint(t,c,k,a,b) + ! iy,wrk = splint(t,c,k,a,b,wrk) real*8 dimension(n),intent(in) :: t integer intent(hide),depend(t) :: n=len(t) real*8 dimension(n),depend(n),check(len(c)==n) :: c integer intent(in) :: k real*8 intent(in) :: a real*8 intent(in) :: b - real*8 dimension(n),depend(n),intent(cache,hide) :: wrk + real*8 dimension(n),intent(out) :: wrk real*8 :: splint end function splint @@ -127,10 +125,8 @@ subroutine spalde(t,n,c,k,x,d,ier) ! d,ier = spalde(t,c,k,x) - callprotoargument double*,int*,double*,int*,double*,double*,int* callstatement {int k1=k+1; (*f2py_func)(t,&n,c,&k1,&x,d,&ier); } - real*8 dimension(n) :: t integer intent(hide),depend(t) :: n=len(t) real*8 dimension(n),depend(n),check(len(c)==n) :: c @@ -140,84 +136,162 @@ integer intent(out) :: ier end subroutine spalde - subroutine curfit(iopt,m,x,y,w,xb,xe,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) - ! in curfit.f - integer :: iopt + subroutine percur_lsq(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! n,t,c,fp,ier = percur_lsq(x,y,w,n,t,[k]) + fortranname percur + integer intent(hide):: iopt=-1 integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) real*8 dimension(m) :: x real*8 dimension(m),depend(m),check(len(y)==m) :: y real*8 dimension(m),depend(m),check(len(w)==m) :: w - real*8 optional,depend(x),check(xb<=x[0]) :: xb = x[0] - real*8 optional,depend(x,m),check(xe>=x[m-1]) :: xe = x[m-1] integer optional,check(1<=k && k <=5),intent(in) :: k=3 + real*8 intent(hide),check(s>=0.0) :: s = 0.0 + integer intent(hide),depend(m,k) :: nest=m+2*k + integer intent(in,out) :: n + real*8 dimension(n),intent(in,out) :: t + real*8 dimension(n),intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk),intent(hide,cache) :: wrk + integer intent(hide),depend(m,k,nest) :: lwrk=m*(k+1)+nest*(8+5*k) + integer dimension(nest),intent(hide,cache) :: iwrk + integer intent(out) :: ier + end subroutine percur_lsq + + subroutine percur_smth1(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! n,t,c,fp,wrk,iwrk,ier = percur_smth1(x,y,w,n,t,wrk,iwrk,[k,s]) + fortranname percur + integer intent(hide):: iopt=1 + integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(w)==m) :: w + integer optional,check(1<=k && k <=5),intent(in) :: k=3 real*8 optional,check(s>=0.0) :: s = 0.0 - integer intent(hide),depend(t) :: nest=len(t) - integer intent(out), depend(nest) :: n=nest - real*8 dimension(nest),intent(inout) :: t + integer intent(hide),depend(m,k) :: nest=m+2*k + integer intent(in,out),depend(nest) :: n=nest + real*8 dimension(nest),intent(in,out) :: t real*8 dimension(n),intent(out) :: c real*8 intent(out) :: fp - real*8 dimension(lwrk),intent(inout) :: wrk - integer intent(hide),depend(wrk) :: lwrk=len(wrk) - integer dimension(nest),intent(inout) :: iwrk + real*8 dimension(lwrk),intent(in,out) :: wrk + integer intent(hide),depend(m,k,nest) :: lwrk=m*(k+1)+nest*(8+5*k) + integer dimension(nest),intent(in,out) :: iwrk integer intent(out) :: ier - end subroutine curfit + end subroutine percur_smth1 - subroutine percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) - ! in percur.f - integer :: iopt + subroutine percur_smth0(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk,iwrk,ier) + ! n,t,c,fp,wrk,iwrk,ier = percur_smth0(x,y,w,[k,s]) + fortranname percur + integer intent(hide):: iopt=0 integer intent(hide),depend(x),check(m>k),depend(k) :: m=len(x) real*8 dimension(m) :: x real*8 dimension(m),depend(m),check(len(y)==m) :: y real*8 dimension(m),depend(m),check(len(w)==m) :: w integer optional,check(1<=k && k <=5),intent(in) :: k=3 real*8 optional,check(s>=0.0) :: s = 0.0 - integer intent(hide),depend(t) :: nest=len(t) - integer intent(out), depend(nest) :: n=nest - real*8 dimension(nest),intent(inout) :: t + integer intent(hide),depend(m,k) :: nest=m+2*k + integer intent(out),depend(nest) :: n=nest + real*8 dimension(nest),intent(out) :: t real*8 dimension(n),intent(out) :: c real*8 intent(out) :: fp - real*8 dimension(lwrk),intent(inout) :: wrk - integer intent(hide),depend(wrk) :: lwrk=len(wrk) - integer dimension(nest),intent(inout) :: iwrk + real*8 dimension(lwrk),intent(out) :: wrk + integer intent(hide),depend(m,k,nest) :: lwrk=m*(k+1)+nest*(8+5*k) + integer dimension(nest),intent(out) :: iwrk integer intent(out) :: ier - end subroutine percur - + end subroutine percur_smth0 - subroutine parcur(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,c,fp,wrk,lwrk,iwrk,ier) - ! in parcur.f - integer check(iopt>=-1 && iopt <= 1):: iopt + subroutine parcur_lsq(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,c,& + fp,wrk,lwrk,iwrk,ier) + !u,ub,ue,n,t,c,fp,ier=parcur_lsq(ipar,idim,u,x,w,ub,ue,nest,n,t,[k]) + fortranname parcur + integer intent(hide) :: iopt = -1 integer check(ipar == 1 || ipar == 0) :: ipar integer check(idim > 0 && idim < 11) :: idim integer intent(hide),depend(u,k),check(m>k) :: m=len(u) - real*8 dimension(m), intent(inout) :: u + real*8 dimension(m), intent(in,out) :: u integer intent(hide),depend(x,idim,m),check(mx>=idim*m) :: mx=len(x) real*8 dimension(mx) :: x real*8 dimension(m) :: w - real*8 :: ub - real*8 :: ue - integer optional, check(1<=k && k<=5) :: k=3.0 - real*8 optional, check(s>=0.0) :: s = 0.0 - integer intent(hide), depend(t) :: nest=len(t) - integer intent(out), depend(nest) :: n=nest - real*8 dimension(nest), intent(inout) :: t - integer intent(hide), depend(c,nest,idim), check(nc>=idim*nest) :: nc=len(c) + real*8 intent(in,out) :: ub + real*8 intent(in,out) :: ue + integer check(1<=k && k<=5) :: k=3.0 + real*8 intent(hide),check(s>=0.0) :: s = 0.0 + integer intent(in) :: nest + integer intent(in,out) :: n + real*8 dimension(nest), intent(in,out) :: t + integer intent(hide), depend(nest,idim) :: nc=idim*nest real*8 dimension(nc), intent(out) :: c real*8 intent(out) :: fp - real*8 dimension(lwrk), intent(inout) :: wrk - integer intent(hide),depend(wrk) :: lwrk=len(wrk) - integer dimension(nest), intent(inout) :: iwrk + real*8 dimension(lwrk), intent(cache) :: wrk + integer intent(hide),depend(m,k,nest,idim) :: lwrk=m*(k+1)+nest*(6+idim+3*k) + integer dimension(nest), intent(cache) :: iwrk integer intent(out) :: ier - end subroutine parcur + end subroutine parcur_lsq + subroutine parcur_smth1(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,& + c,fp,wrk,lwrk,iwrk,ier) + !u,ub,ue,n,t,c,fp,wrk,iwrk,ier=parcur_smth1(ipar,idim,u,x,w,ub,ue,nest, + ! n,t,wrk,iwrk,[k,s]) + fortranname parcur + integer intent(hide) :: iopt = 1 + integer check(ipar == 1 || ipar == 0) :: ipar + integer check(idim > 0 && idim < 11) :: idim + integer intent(hide),depend(u,k),check(m>k) :: m=len(u) + real*8 dimension(m), intent(in,out) :: u + integer intent(hide),depend(x,idim,m),check(mx>=idim*m) :: mx=len(x) + real*8 dimension(mx) :: x + real*8 dimension(m) :: w + real*8 intent(in,out) :: ub + real*8 intent(in,out) :: ue + integer check(1<=k && k<=5) :: k=3.0 + real*8 check(s>=0.0) :: s = 0.0 + integer intent(in) :: nest + integer intent(in,out) :: n + real*8 dimension(nest), intent(in,out) :: t + integer intent(hide), depend(nest,idim) :: nc=idim*nest + real*8 dimension(nc), intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk), intent(in,out) :: wrk + integer intent(hide),depend(m,k,nest,idim) :: lwrk=m*(k+1)+nest*(6+idim+3*k) + integer dimension(nest), intent(in,out) :: iwrk + integer intent(out) :: ier + end subroutine parcur_smth1 - subroutine fpcurf0(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + subroutine parcur_smth0(iopt,ipar,idim,m,u,mx,x,w,ub,ue,k,s,nest,n,t,nc,& + c,fp,wrk,lwrk,iwrk,ier) + !u,ub,ue,n,t,c,fp,wrk,iwrk,ier=parcur_smth0(ipar,idim,u,x,w, + ! ub,ue,nest,[k,s]) + fortranname parcur + integer intent(hide) :: iopt = 0 + integer check(ipar == 1 || ipar == 0) :: ipar + integer check(idim > 0 && idim < 11) :: idim + integer intent(hide),depend(u,k),check(m>k) :: m=len(u) + real*8 dimension(m), intent(in,out) :: u + integer intent(hide),depend(x,idim,m),check(mx>=idim*m) :: mx=len(x) + real*8 dimension(mx) :: x + real*8 dimension(m) :: w + real*8 intent(in,out) :: ub + real*8 intent(in,out) :: ue + integer check(1<=k && k<=5) :: k=3.0 + real*8 check(s>=0.0) :: s = 0.0 + integer intent(in) :: nest + integer intent(out) :: n + real*8 dimension(nest), intent(out) :: t + integer intent(hide), depend(nest,idim) :: nc=idim*nest + real*8 dimension(nc), intent(out) :: c + real*8 intent(out) :: fp + real*8 dimension(lwrk), intent(out) :: wrk + integer intent(hide),depend(m,k,nest,idim) :: lwrk=m*(k+1)+nest*(6+idim+3*k) + integer dimension(nest), intent(out) :: iwrk + integer intent(out) :: ier + end subroutine parcur_smth0 + + subroutine fpcurf_smth0(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,& + c,fp,fpint,wrk,nrdata,ier) ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ - ! fpcurf0(x,y,k,[w,xb,xe,s,nest]) - + ! fpcurf_smth0(x,y,k,[w,xb,xe,s,nest]) fortranname fpcurf callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) - integer intent(hide) :: iopt = 0 real*8 dimension(m),intent(in,out) :: x real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y @@ -240,16 +314,16 @@ real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk integer dimension(nest),depend(nest),intent(out,cache) :: nrdata integer intent(out) :: ier - end subroutine fpcurf0 + end subroutine fpcurf_smth0 - subroutine fpcurf1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + subroutine fpcurf_smth1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,& + c,fp,fpint,wrk,nrdata,ier) ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ - ! fpcurf1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier) + ! fpcurf_smth1(x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier) fortranname fpcurf callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) - integer intent(hide) :: iopt = 1 real*8 dimension(m),intent(in,out,overwrite) :: x real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out,overwrite) :: y @@ -272,16 +346,15 @@ real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk integer dimension(nest),depend(nest),check(len(nrdata)==nest),intent(in,out,cache,overwrite) :: nrdata integer intent(in,out) :: ier - end subroutine fpcurf1 + end subroutine fpcurf_smth1 - subroutine fpcurfm1(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,fp,fpint,wrk,nrdata,ier) + subroutine fpcurf_lsq(iopt,x,y,w,m,xb,xe,k,s,nest,tol,maxit,k1,k2,n,t,c,& + fp,fpint,wrk,nrdata,ier) ! x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = \ - ! fpcurfm1(x,y,k,t,[w,xb,xe]) - + ! fpcurf_lsq(x,y,k,t,[w,xb,xe]) fortranname fpcurf callprotoargument int*,double*,double*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int* callstatement (*f2py_func)(&iopt,x,y,w,&m,&xb,&xe,&k,&s,&nest,&tol,&maxit,&k1,&k2,&n,t,c,&fp,fpint,wrk,wrk+nest,wrk+nest*k2,wrk+nest*2*k2,wrk+nest*3*k2,nrdata,&ier) - integer intent(hide) :: iopt = -1 real*8 dimension(m),intent(in,out) :: x real*8 dimension(m),depend(m),check(len(y)==m),intent(in,out) :: y @@ -304,7 +377,7 @@ real*8 dimension(nest*3*k2+m*k1),intent(cache,hide),depend(nest,k1,k2,m) :: wrk integer dimension(nest),depend(nest),intent(out,cache) :: nrdata integer intent(out) :: ier - end subroutine fpcurfm1 + end subroutine fpcurfm_lsq !!!!!!!!!! Bivariate spline !!!!!!!!!!! @@ -330,13 +403,81 @@ integer intent(out) :: ier end subroutine bispev - subroutine surfit_smth(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest,& + subroutine parder(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk,iwrk,kwrk,ier) + ! z,ier = parder(tx,ty,c,kx,ky,nux,nuy,x,y) + real*8 dimension(nx),intent(in) :: tx + integer intent(hide),depend(tx) :: nx=len(tx) + real*8 dimension(ny),intent(in) :: ty + integer intent(hide),depend(ty) :: ny=len(ty) + real*8 intent(in),dimension((nx-kx-1)*(ny-ky-1)),depend(nx,ny,kx,ky),& + check(len(c)==(nx-kx-1)*(ny-ky-1)):: c + integer :: kx + integer :: ky + integer intent(in),depend(kx),check(0<=nux && nux=(kx+1)*(ky+1)) & + :: m=len(x) + real*8 dimension(m) :: x + real*8 dimension(m),depend(m),check(len(y)==m) :: y + real*8 dimension(m),depend(m),check(len(z)==m) :: z + real*8 optional,dimension(m),depend(m),check(len(w)==m) :: w = 1.0 + real*8 optional,depend(x,m) :: xb=dmin(x,m) + real*8 optional,depend(x,m) :: xe=dmax(x,m) + real*8 optional,depend(y,m) :: yb=dmin(y,m) + real*8 optional,depend(y,m) :: ye=dmax(y,m) + integer check(1<=kx && kx<=5) :: kx = 3 + integer check(1<=ky && ky<=5) :: ky = 3 + real*8 optional,check(0.0<=s) :: s = m + integer optional,depend(kx,m),check(nxest>=2*(kx+1)) & + :: nxest = imax(kx+1+sqrt(m/2),2*(kx+1)) + integer optional,depend(ky,m),check(nyest>=2*(ky+1)) & + :: nyest = imax(ky+1+sqrt(m/2),2*(ky+1)) + integer intent(hide),depend(nxest,nyest) :: nmax=MAX(nxest,nyest) + real*8 optional,check(0.0=(kx+1)*(ky+1)) & :: m=len(x) @@ -374,15 +515,13 @@ integer intent(hide),depend(m,nxest,nyest,kx,ky) & :: kwrk=m+(nxest-2*kx-1)*(nyest-2*ky-1) integer intent(out) :: ier - end subroutine surfit_smth + end subroutine surfit_smth0 subroutine surfit_lsq(iopt,m,x,y,z,w,xb,xe,yb,ye,kx,ky,s,nxest,nyest,& nmax,eps,nx,tx,ny,ty,c,fp,wrk1,lwrk1,wrk2,lwrk2,& iwrk,kwrk,ier) ! tx,ty,c,fp,ier = surfit_lsq(x,y,z,tx,ty,[w,xb,xe,yb,ye,kx,ky,eps,lwrk2]) - fortranname surfit - integer intent(hide) :: iopt=-1 integer intent(hide),depend(x,kx,ky),check(m>=(kx+1)*(ky+1)) & :: m=len(x) @@ -418,17 +557,15 @@ :: kwrk=m+(nx-2*kx-1)*(ny-2*ky-1) integer intent(out) :: ier end subroutine surfit_lsq - - subroutine regrid_smth(iopt,mx,x,my,y,z,xb,xe,yb,ye,kx,ky,s,& + + subroutine regrid_smth0(iopt,mx,x,my,y,z,xb,xe,yb,ye,kx,ky,s,& nxest,nyest,nx,tx,ny,ty,c,fp,wrk,lwrk,iwrk,kwrk,ier) - ! nx,tx,ny,ty,c,fp,ier = regrid_smth(x,y,z,[xb,xe,yb,ye,kx,ky,s]) - + ! nx,tx,ny,ty,c,fp,ier = regrid_smth0(x,y,z,[xb,xe,yb,ye,kx,ky,s]) fortranname regrid - integer intent(hide) :: iopt=0 integer intent(hide),depend(x,kx),check(mx>kx) :: mx=len(x) real*8 dimension(mx) :: x - integer intent(hide),depend(y,ky),check(my>ky) :: my=len(y) + integer intent(hide),depend(y,ky),check(my>ky) :: my=len(y) real*8 dimension(my) :: y real*8 dimension(mx*my),depend(mx,my),check(len(z)==mx*my) :: z real*8 optional,depend(x,mx) :: xb=dmin(x,mx) @@ -456,7 +593,7 @@ integer intent(hide),depend(mx,my,nxest,nyest) & :: kwrk=3+mx+my+nxest+nyest integer intent(out) :: ier - end subroutine regrid_smth + end subroutine regrid_smth0 end interface end python module dfitpack Modified: trunk/Lib/sandbox/spline/info.py =================================================================== --- trunk/Lib/sandbox/spline/info.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/info.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -2,27 +2,31 @@ Spline Tools =================== -Wrappers around FITPACK functions: +This package contains wrappers around the netlib Dierckx library for curve +and surface fitting with splines. +Two interfaces are provided. The prefered interface is an object orientated +interface defined in spline.spline: + + UnivariateSpline -- 1 dimensional, smoothing or interpolating spline + InterpolatedUnivariateSpline -- i dimensional interpolating spline + LSQUnivariateSpline -- 1 dimensional least squares fitted spline + SmoothBivariateSpline -- 2 dimensional smoothing spline on scattered data + LSQBivariateSpline -- a least scquares fitted spline for scattered data + RectBivariateSpline -- a 2 dimensional smoothing or interpolating spline + on regular gridded rectangular data + +An alternative interface is a more direct wrapping of the fortran rountines: + splrep -- find smoothing spline given (x,y) points on curve. splprep -- find smoothing spline given parametrically defined curve. splev -- evaluate the spline or its derivatives. splint -- compute definite integral of a spline. sproot -- find the roots of a cubic spline. spalde -- compute all derivatives of a spline at given points. - bisplrep -- find bivariate smoothing spline representation. + bisplrep -- find bivariate smoothing spline representation. bisplev -- evaluate bivariate smoothing spline. - UnivariateSpline -- A more recent, object-oriented wrapper; - finds a (possibly smoothed) interpolating - spline. - InterpolatedUnivariateSpline - LSQUnivariateSpline - BivariateSpline -- A more recent, object-oriented wrapper; - finds a interpolating spline for a - bivariate function. - - SmoothBivariateSpline """ postpone_import = 1 Modified: trunk/Lib/sandbox/spline/spline.py =================================================================== --- trunk/Lib/sandbox/spline/spline.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/spline.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -6,7 +6,7 @@ to double routines by Pearu Peterson. """ # Created by Pearu Peterson, June,August 2003 -# Modified by John Travers, October 2006 +# Modified by John Travers, October-January 2006 __all__ = [ 'UnivariateSpline', @@ -84,7 +84,7 @@ deviation of y[i]. """ #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier - data = dfitpack.fpcurf0(x,y,k,w=w, + data = dfitpack.fpcurf_smth0(x,y,k,w=w, xb=bbox[0],xe=bbox[1],s=s) if data[-1]==1: # nest too small, setting to maximum bound @@ -130,7 +130,7 @@ fpint.resize(nest) nrdata.resize(nest) args = data[:8] + (t,c,n,fpint,nrdata,data[13]) - data = dfitpack.fpcurf1(*args) + data = dfitpack.fpcurf_smth1(*args) return data def set_smoothing_factor(self, s): @@ -144,7 +144,7 @@ 'LSQ spline with fixed knots') return args = data[:6] + (s,) + data[7:] - data = dfitpack.fpcurf1(*args) + data = dfitpack.fpcurf_smth1(*args) if data[-1]==1: # nest too small, setting to maximum bound data = self._reset_nest(data) @@ -158,8 +158,10 @@ """ if nu is None: - return dfitpack.splev(*(self._eval_args+(x,))) - return dfitpack.splder(nu=nu,*(self._eval_args+(x,))) + sp,ier = dfitpack.splev(*(self._eval_args+(x,))) + return sp + sp,ier = dfitpack.splder(nu=nu,*(self._eval_args+(x,))) + return sp def get_knots(self): """ Return the positions of (boundary and interior) @@ -186,7 +188,8 @@ """ Return definite integral of the spline between two given points. """ - return dfitpack.splint(*(self._eval_args+(a,b))) + iy, wrk = dfitpack.splint(*(self._eval_args+(a,b))) + return iy def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" @@ -205,11 +208,10 @@ assert ier==0,`ier` return z[:m] raise NotImplementedError,\ - 'finding roots unsupported for non-cubic splines' + 'finding roots not supported for non-cubic splines' class InterpolatedUnivariateSpline(UnivariateSpline): - """ Interpolated univariate spline approximation. Identical to - UnivariateSpline with less error checking. + """ Interpolated univariate spline approximation. """ @@ -227,14 +229,12 @@ k=3 - degree of the univariate spline. """ #_data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier - self._data = dfitpack.fpcurf0(x,y,k,w=w, + self._data = dfitpack.fpcurf_smth0(x,y,k,w=w, xb=bbox[0],xe=bbox[1],s=0) self._reset_class() class LSQUnivariateSpline(UnivariateSpline): - """ Weighted least-squares univariate spline - approximation. Appears to be identical to UnivariateSpline with - more error checking. + """ Weighted least-squares univariate spline approximation. """ @@ -264,7 +264,7 @@ if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0,axis=0): raise ValueError,\ 'Interior knots t must satisfy Schoenberg-Whitney conditions' - data = dfitpack.fpcurfm1(x,y,k,t,w=w,xb=xb,xe=xe) + data = dfitpack.fpcurf_lsq(x,y,k,t,w=w,xb=xb,xe=xe) self._data = data[:-3] + (None,None,data[-1]) self._reset_class() @@ -363,7 +363,6 @@ LSQUnivariateSpline - to create a BivariateSpline using weighted least-squares fitting """ - def __init__(self, x, y, z, w=None, bbox = [None]*4, kx=3, ky=3, s=None, eps=None): """ @@ -388,7 +387,7 @@ equations. 0 < eps < 1, default is 1e-16. """ xb,xe,yb,ye = bbox - nx,tx,ny,ty,c,fp,wrk1,ier = dfitpack.surfit_smth(x,y,z,w, + nx,tx,ny,ty,c,fp,wrk1,ier = dfitpack.surfit_smth0(x,y,z,w, xb,xe,yb,ye, kx,ky,s=s, eps=eps,lwrk2=1) @@ -411,7 +410,6 @@ SmoothUnivariateSpline - to create a BivariateSpline through the given points """ - def __init__(self, x, y, z, tx, ty, w=None, bbox = [None]*4, kx=3, ky=3, eps=None): @@ -471,7 +469,6 @@ bisplrep, bisplev - an older wrapping of FITPACK UnivariateSpline - a similar class for univariate spline interpolation """ - def __init__(self, x, y, z, bbox = [None]*4, kx=3, ky=3, s=0): """ @@ -506,7 +503,7 @@ 'y dimension of z must have same number of elements as y' z = ravel(z) xb,xe,yb,ye = bbox - nx,tx,ny,ty,c,fp,ier = dfitpack.regrid_smth(x,y,z, + nx,tx,ny,ty,c,fp,ier = dfitpack.regrid_smth0(x,y,z, xb,xe,yb,ye, kx,ky,s) if ier in [0,-1,-2]: # normal return @@ -518,4 +515,3 @@ self.fp = fp self.tck = tx[:nx],ty[:ny],c[:(nx-kx-1)*(ny-ky-1)] self.degrees = kx,ky - Deleted: trunk/Lib/sandbox/spline/tests/demos_xplt.py =================================================================== --- trunk/Lib/sandbox/spline/tests/demos_xplt.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/tests/demos_xplt.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# Created by Pearu Peterson, Aug 2003 -""" Test xplt based demos for interpolate.fitpack2 module -""" -__usage__ = """ -Build interpolate: - python setup_interpolate.py build -Run demos (assumes that scipy is installed): - python -i tests/demos_xplt.py -""" - -import sys -from numpy.test.testing import set_package_path -set_package_path() -from interpolate.fitpack2 import UnivariateSpline,LSQUnivariateSpline,\ - InterpolatedUnivariateSpline -from interpolate.fitpack2 import LSQBivariateSpline, SmoothBivariateSpline -del sys.path[0] - -from scipy import * - -def demo1(): - x = arange(0,2*pi+pi/4,2*pi/8) - xnew = arange(-pi/10,2*pi+pi/4+pi/10,pi/50) - y = sin(x) - - - def make_plot(): - xplt.plot(x,y,'x',xnew,spline(xnew),x,y,'b',xnew,sin(xnew), - spline.get_knots(),spline(spline.get_knots()),'o') - - spline = UnivariateSpline(x,y,k=1) - assert isinstance(spline,LSQUnivariateSpline) - print 'Linear LSQ approximation of sin(x):',spline.__class__.__name__ - make_plot() - print 'Residual=',spline.get_residual() - raw_input('Press any key to continue..') - - spline.set_smoothing_factor(0) - assert isinstance(spline,InterpolatedUnivariateSpline) - print 'Linear interpolation of sin(x):',spline.__class__.__name__ - make_plot() - print 'Residual=',spline.get_residual() - raw_input('Press any key to continue..') - - spline = UnivariateSpline(x,y,k=1,s=0.1) - print 'Linear smooth approximation of sin(x):',spline.__class__.__name__ - assert isinstance(spline,UnivariateSpline) - make_plot() - print 'Residual=',spline.get_residual() - raw_input('Press any key to continue..') - -if __name__ == "__main__": - demo1() Added: trunk/Lib/sandbox/spline/tests/dierckx_test_data.py =================================================================== --- trunk/Lib/sandbox/spline/tests/dierckx_test_data.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/tests/dierckx_test_data.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -0,0 +1,184 @@ +from numpy import arange, array, sin, cos, atleast_1d, transpose, dot + +curfit_test = { +#inputs: +'y' : array([1.0,1.0,1.4,1.1,1.0,1.0,4.0,9.0,13.0, + 13.4,12.8,13.1,13.0,14.0,13.0,13.5,10.0, + 2.0,3.0,2.5,2.5,2.5,3.0,4.0,3.5]), +'x' : arange(25.0)} + +curfit_test_smth = { +#inputs: +'k' : [3, 3, 3, 5, 5, 5], +'s' : [1000, 60, 0, 60, 10, 0], +'iopt' : [0, 1, 1, 0, 1, 1], +# results: +'fp' : array([0.265483E+03, 0.600380E+02, 0.000000E+00, 0.600201E+02, + 0.100002E+02, 0.000000E+00]), +'ier' : array([-2, 0, -1, 0, 0, -1]), +'n' : array([8, 11, 29, 13, 21, 31]), +'t' : [array([0.0, 0.0, 0.0, 0.0, 24.0, 24.0, 24.0, 24.0]), + array([0.0, 0.0, 0.0, 0.0, 12.0, 15.0, 18.0, 24.0, + 24.0, 24.0, 24.0]), + array([0.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, + 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, + 22.0, 24.0, 24.0, 24.0, 24.0]), + array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.0, 24.0, + 24.0, 24.0, 24.0, 24.0, 24.0]), + array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 8.0, + 9.0, 12.0, 14.0, 15.0, 16.0, 17.0, 18.0, 24.0, + 24.0, 24.0, 24.0, 24.0, 24.0]), + array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, + 21.0, 24.0, 24.0, 24.0, 24.0, 24.0, 24.0])], +'c' : [array([-3.5307, 19.6679, 10.0310, 0.5226]), + array([1.7450, -6.1367, 21.0990, 11.1564, -0.1060, 2.0998, + 4.3288]), + array([1.0000, 0.4704, 1.8592, 0.9446, 1.1911, 0.2910, + 3.6448, 9.1297, 13.8362, 13.5254, 12.4622, 13.4258, + 12.4346, 14.8358, 12.2222, 14.2755, 11.6757, -0.9783, + 4.2375, 2.0285, 2.6486, 2.3770, 2.9986, 4.8757, + 3.5000]), + array([1.9049, -2.6240, 0.5773, 45.0508, -10.0998, 2.7788, + 4.2385]), + array([1.0179, -1.2191, 9.2752, -12.6640, 17.3909, 13.0655, + 11.7046, 14.2824, 14.9330, 8.7780, -2.6436, 5.4611, + 0.5460, 4.9279, 3.5774]), + array([1.0000, -0.7624, 3.5842, -0.4712, 2.4346, -0.3988, + 3.6292, 9.0283, 14.4832, 13.6084, 11.9251, 14.2042, + 11.3359, 16.1291, 11.2375, 14.3636, 14.1766, -4.8942, + 6.9048, 0.5376, 4.5146, 0.4259, 4.7049, 4.4036, + 3.5000])], +'sp' : [array([-3.5, -0.8, 1.6, 3.7, 5.5, 7.0, 8.2, 9.2, 9.9, 10.5, + 10.8, 10.8, 10.8, 10.5, 10.1, 9.5, 8.9, 8.1, 7.2, 6.2, + 5.1, 4.0, 2.9, 1.7, 0.5]), + array([1.7, 0.4, 0.0, 0.6, 1.8, 3.6, 5.6, 7.8, 10.0, 12.0, + 13.5, 14.5, 14.7, 14.0, 12.6, 10.6, 8.2, 5.9, 3.9, 2.6, + 2.1, 2.1, 2.5, 3.3, 4.3]), + array([1.0, 1.0, 1.4, 1.1, 1.0, 1.0, 4.0, 9.0, 13.0, 13.4, + 12.8, 13.1, 13.0, 14.0, 13.0, 13.5, 10.0, 2.0, 3.0, 2.5, + 2.5, 2.5, 3.0, 4.0, 3.5]), + array([1.9, 0.5, -0.1, 0.3, 1.5, 3.4, 5.6, 8.0, 10.3, 12.3, + 13.8, 14.5, 14.5, 13.7, 12.3, 10.3, 8.2, 6.0, 4.1, 2.8, + 2.0, 2.0, 2.5, 3.4, 4.2]), + array([1.0, 0.9, 1.5, 1.2, 0.6, 1.2, 4.2, 8.9, 12.6, 13.6, + 13.2, 12.7, 12.9, 13.7, 14.2, 12.9, 8.6, 4.1, 2.3, 2.2, + 2.4, 2.7, 3.2, 3.7, 3.6]), + array([1.0, 1.0, 1.4, 1.1, 1.0, 1.0, 4.0, 9.0, 13.0, 13.4, + 12.8, 13.1, 13.0, 14.0, 13.0, 13.5, 10.0, 2.0, 3.0, 2.5, + 2.5, 2.5, 3.0, 4.0, 3.5])] +} + +curfit_test_lsq = { +#inputs: +'k' : [3, 5], +# results: +'fp' : array([0.234182E+02, 0.155243E+02]), +'ier' : array([0, 0]), +'t' : [array([3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0]), + array([3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0])], +'c' : [array([0.8505, 2.4795, -0.9480, 2.8341, 17.4216, 10.3854, + 17.1927, -2.9343, 5.6395, 2.4292, 3.7180]), + array([1.0199, -1.6630, 6.3167, -4.5892, 1.6163, 22.6478, + 3.5130, 27.5439, -16.2085, 15.0884, -5.3102, 8.6487, + 3.4724])], +'sp' : [array([0.9, 1.5, 1.1, 0.5, 0.8, 2.2, 4.6, 8.1, 11.6, 13.8, + 14.1, 13.3, 12.7, 13.2, 13.7, 12.7, 9.3, 5.0, 1.8, 1.3, + 2.3, 3.4, 3.5, 3.2, 3.7]), + array([1.0, 0.8, 1.8, 0.9, 0.3, 1.6, 4.7, 8.6, 12.0, 13.7, + 13.7, 12.8, 12.7, 13.5, 14.2, 12.8, 8.9, 4.4, 1.8, 1.9, + 3.0, 3.0, 2.4, 4.2, 3.5])] +} + +def f1(x,d=0): + if d is None: return "sin" + if x is None: return "sin(x)" + if d%4 == 0: return sin(x) + if d%4 == 1: return cos(x) + if d%4 == 2: return -sin(x) + if d%4 == 3: return -cos(x) + +def f2(x,y=0,dx=0,dy=0): + if x is None: return "sin(x+y)" + d=dx+dy + if d%4 == 0: return sin(x+y) + if d%4 == 1: return cos(x+y) + if d%4 == 2: return -sin(x+y) + if d%4 == 3: return -cos(x+y) + +myasarray = atleast_1d + +def norm2(x): + return dot(transpose(x),x) +def makepairs(x,y): + x,y=map(myasarray,[x,y]) + xy=array(map(lambda x,y:map(None,len(y)*[x],y),x,len(x)*[y])) + sh=xy.shape + xy.shape=sh[0]*sh[1],sh[2] + return transpose(xy) + +# very simple script to test interpolation with regrid and surfit +# based on example data from netlib->dierckx->regrid + +#from numpy import * +#from scipy.interpolate.fitpack2 import SmoothBivariateSpline, \ + #RectBivariateSpline +#import matplotlib +#matplotlib.use('Agg') +#import pylab + +## x,y coordinates +#x = linspace(-1.5,1.5,11) +#y = x +## data taken from daregr +#z = array([ +#[-0.0325, 0.0784, 0.0432, 0.0092, 0.1523, 0.0802, 0.0925, -0.0098, \ + #0.0810, -0.0146, -0.0019], +#[0.1276, 0.0223, 0.0357, 0.1858, 0.2818, 0.1675, 0.2239, 0.1671, \ + #0.0843, 0.0151, 0.0427], +#[0.0860, 0.1267, 0.1839, 0.3010, 0.5002, 0.4683, 0.4562, 0.2688, \ + #0.1276, 0.1244, 0.0377], +#[0.0802, 0.1803, 0.3055, 0.4403, 0.6116, 0.7178, 0.6797, 0.5218, \ + #0.2624, 0.1341, -0.0233], +#[0.1321, 0.2023, 0.4446, 0.7123, 0.7944, 0.9871, 0.8430, 0.6440, \ + #0.4682, 0.1319, 0.1075], +#[0.2561, 0.1900, 0.4614, 0.7322, 0.9777, 1.0463, 0.9481, 0.6649, \ + #0.4491, 0.2442, 0.1341], +#[0.0981, 0.2009, 0.4616, 0.5514, 0.7692, 0.9831, 0.7972, 0.5937, \ + #0.4190, 0.1436, 0.0995], +#[0.0991, 0.1545, 0.3399, 0.4940, 0.6328, 0.7168, 0.6886, 0.3925, \ + #0.3015, 0.1758, 0.0928], +#[-0.0197, 0.1479, 0.1225, 0.3254, 0.3847, 0.4767, 0.4324, 0.2827, \ + #0.2287, 0.0999, 0.0785], +#[0.0032, 0.0917, 0.0246, 0.1780, 0.2394, 0.1765, 0.1642, 0.2081, \ + #0.1049, 0.0493, -0.0502], +#[0.0101, 0.0297, 0.0468, 0.0221, 0.1074, 0.0433, 0.0626, 0.1436, \ + #0.1092, -0.0232, 0.0132]]) + +## plot original data +#pylab.subplot(1,3,1) +#pylab.imshow(z) +#pylab.title('orig') + +## check regrid +#mrs = RectBivariateSpline(x,y,z) +#zr = mrs(x,y) +#print sum(abs(zr-z)) +#pylab.subplot(1,3,2) +#pylab.imshow(zr) +#pylab.title('regrid') + +## check surfit +## x increases in columns, y increases along rows +#ym,xm = meshgrid(y,x) # deal with meshgrid badness +#mrs = SmoothBivariateSpline(ravel(xm),ravel(ym),ravel(z),kx=3,ky=3,s=0) +#zr = mrs(x,y) +#print sum(abs(zr-z)) +#pylab.subplot(1,3,3) +#pylab.imshow(zr) +#pylab.title('surfit') + +#pylab.savefig('intplot.png') +#pylab.close() Deleted: trunk/Lib/sandbox/spline/tests/test_fitpack.py =================================================================== --- trunk/Lib/sandbox/spline/tests/test_fitpack.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/tests/test_fitpack.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -1,87 +0,0 @@ -#!/usr/bin/env python -# Created by Pearu Peterson, June 2003 -""" Test functions for interpolate.fitpack2 module -""" -__usage__ = """ -Build interpolate: - python setup_interpolate.py build -Run tests if scipy is installed: - python -c 'import scipy;scipy.interpolate.test()' -Run tests if interpolate is not installed: - python tests/test_fitpack.py [] -""" -#import libwadpy - -import sys -from numpy.testing import * -from numpy import array -set_package_path() -from interpolate.fitpack2 import UnivariateSpline,LSQUnivariateSpline,\ - InterpolatedUnivariateSpline -from interpolate.fitpack2 import LSQBivariateSpline, SmoothBivariateSpline,\ - RectBivariateSpline -restore_path() - -class test_UnivariateSpline(NumpyTestCase): - def check_linear_constant(self): - x = [1,2,3] - y = [3,3,3] - lut = UnivariateSpline(x,y,k=1) - assert_array_almost_equal(lut.get_knots(),[1,3]) - assert_array_almost_equal(lut.get_coeffs(),[3,3]) - assert_almost_equal(lut.get_residual(),0.0) - assert_array_almost_equal(lut([1,1.5,2]),[3,3,3]) - - def check_linear_1d(self): - x = [1,2,3] - y = [0,2,4] - lut = UnivariateSpline(x,y,k=1) - assert_array_almost_equal(lut.get_knots(),[1,3]) - assert_array_almost_equal(lut.get_coeffs(),[0,4]) - assert_almost_equal(lut.get_residual(),0.0) - assert_array_almost_equal(lut([1,1.5,2]),[0,1,2]) - -class test_LSQBivariateSpline(NumpyTestCase): - def check_linear_constant(self): - x = [1,1,1,2,2,2,3,3,3] - y = [1,2,3,1,2,3,1,2,3] - z = [3,3,3,3,3,3,3,3,3] - s = 0.1 - tx = [1+s,3-s] - ty = [1+s,3-s] - lut = LSQBivariateSpline(x,y,z,tx,ty,kx=1,ky=1) - #print lut.get_knots() - #print lut.get_coeffs() - #print lut.get_residual() - -class test_SmoothBivariateSpline(NumpyTestCase): - def check_linear_constant(self): - x = [1,1,1,2,2,2,3,3,3] - y = [1,2,3,1,2,3,1,2,3] - z = [3,3,3,3,3,3,3,3,3] - lut = SmoothBivariateSpline(x,y,z,kx=1,ky=1) - assert_array_almost_equal(lut.get_knots(),([1,1,3,3],[1,1,3,3])) - assert_array_almost_equal(lut.get_coeffs(),[3,3,3,3]) - assert_almost_equal(lut.get_residual(),0.0) - assert_array_almost_equal(lut([1,1.5,2],[1,1.5]),[[3,3],[3,3],[3,3]]) - - def check_linear_1d(self): - x = [1,1,1,2,2,2,3,3,3] - y = [1,2,3,1,2,3,1,2,3] - z = [0,0,0,2,2,2,4,4,4] - lut = SmoothBivariateSpline(x,y,z,kx=1,ky=1) - assert_array_almost_equal(lut.get_knots(),([1,1,3,3],[1,1,3,3])) - assert_array_almost_equal(lut.get_coeffs(),[0,0,4,4]) - assert_almost_equal(lut.get_residual(),0.0) - assert_array_almost_equal(lut([1,1.5,2],[1,1.5]),[[0,0],[1,1],[2,2]]) - -class test_RectBivariateSpline(NumpyTestCase): - def check_defaults(self): - x = array([1,2,3,4,5]) - y = array([1,2,3,4,5]) - z = array([[1,2,1,2,1],[1,2,1,2,1],[1,2,3,2,1],[1,2,2,2,1],[1,2,1,2,1]]) - lut = RectBivariateSpline(x,y,z) - assert_array_almost_equal(lut(x,y),z) - -if __name__ == "__main__": - NumpyTest().run() Added: trunk/Lib/sandbox/spline/tests/test_fitpack.py =================================================================== --- trunk/Lib/sandbox/spline/tests/test_fitpack.py 2007-01-14 22:48:12 UTC (rev 2554) +++ trunk/Lib/sandbox/spline/tests/test_fitpack.py 2007-01-15 00:23:52 UTC (rev 2555) @@ -0,0 +1,144 @@ +#!/usr/bin/env python +# Created by John Travers, January 2007 +""" Test functions for spline.fitpack module +""" +__usage__ = """ +Build spline: + python setup_spline.py build +Run tests if scipy is installed: + python -c 'import scipy;scipy.spline.test()' +Run tests if spline is not installed: + python tests/test_fitpack.py [] +""" + +import sys +from numpy.testing import * +from numpy import array, arange, around, pi, sin, ravel + +set_package_path() +from spline.fitpack import splrep, splev, sproot, splint, spalde +from spline.fitpack import bisplev, bisplrep, splprep +restore_path() + +set_local_path() +from dierckx_test_data import * +restore_path() + +class test_splrep_slev(NumpyTestCase): + def check_curfit_against_dierckx_smth(self): + x,y = curfit_test['x'],curfit_test['y'] + k,s = curfit_test_smth['k'],curfit_test_smth['s'] + iopt = curfit_test_smth['iopt'] + for i in range(len(k)): + tck = splrep(x,y,k=k[i],task=iopt[i],s=s[i]) + out = splrep(x,y,k=k[i],task=iopt[i],s=s[i],full_output=1) + tck,fp=out[0],out[1] + sp = splev(x,tck) + assert_almost_equal(fp, curfit_test_smth['fp'][i], decimal=2) + assert_array_almost_equal(around(tck[0],1), + curfit_test_smth['t'][i]) + assert_array_almost_equal(around(tck[1],4), + curfit_test_smth['c'][i], decimal=3) + assert_array_almost_equal(around(sp,1), + curfit_test_smth['sp'][i]) + + def check_curfit_against_dierckx_lsq(self): + """ Test against results obtined from the pure fortran routines. + + Here we check simple spline creation and evaluation. + """ + x,y = curfit_test['x'],curfit_test['y'] + k = curfit_test_lsq['k'] + for i in range(len(k)): + t = curfit_test_lsq['t'][i] + out = splrep(x,y,t=t,k=k[i],full_output=1) + tck,fp=out[0],out[1] + sp = splev(x,tck) + assert_almost_equal(fp, curfit_test_lsq['fp'][i], decimal=2) + assert_array_almost_equal(around(tck[1],4), + curfit_test_lsq['c'][i], decimal=3) + assert_array_almost_equal(around(sp,1), + curfit_test_lsq['sp'][i]) + +class test_splint_spalde(NumpyTestCase): + def check_splint_spalde(self): + per = [0, 1, 0] + N = [20, 20, 50] + ia = [0, 0, 0.2*pi] + ib = [0, 0, pi] + a,b = 0,2*pi + dx = 0.2*pi + k = range(1,6) + for i in range(len(per)): + x=a+(b-a)*arange(N[i]+1,dtype=float)/float(N[i]) + v=f1(x) + for j in range(len(k)): + tck = splrep(x,v,k=k[j],s=0,per=per[i]) + ir = splint(ia[i],ib[i],tck) + dr = spalde(dx,tck) + assert_almost_equal(ir, f1(ib[i],-1)-f1(ia[i],-1), decimal=2) + d=0 + for ddr in dr: + if d)' +Run tests if spline is not installed: + python tests/test_spline.py [] +""" + +import sys +from numpy.testing import * +from numpy import array, arange, around, pi, sin, cos + +set_package_path() +from spline.spline import UnivariateSpline,LSQUnivariateSpline,\ + InterpolatedUnivariateSpline +from spline.spline import LSQBivariateSpline, SmoothBivariateSpline,\ + RectBivariateSpline +restore_path() + +set_local_path() +from dierckx_test_data import * +restore_path() + +class test_UnivariateSpline(NumpyTestCase): + def check_linear_constant(self): + x = [1,2,3] + y = [3,3,3] + lut = UnivariateSpline(x,y,k=1) + assert_array_almost_equal(lut.get_knots(),[1,3]) + assert_array_almost_equal(lut.get_coeffs(),[3,3]) + assert_almost_equal(lut.get_residual(),0.0) + assert_array_almost_equal(lut([1,1.5,2]),[3,3,3]) + + def check_linear_1d(self): + x = [1,2,3] + y = [0,2,4] + lut = UnivariateSpline(x,y,k=1) + assert_array_almost_equal(lut.get_knots(),[1,3]) + assert_array_almost_equal(lut.get_coeffs(),[0,4]) + assert_almost_equal(lut.get_residual(),0.0) + assert_array_almost_equal(lut([1,1.5,2]),[0,1,2]) + + def check_curfit_against_dierckx(self): + """ Test against results obtined from the pure fortran routines. + + Here we check simple spline creation and evaluation. + """ + x,y = curfit_test['x'],curfit_test['y'] + k,s = curfit_test_smth['k'],curfit_test_smth['s'] + iopt = curfit_test_smth['iopt'] + for i in range(len(k)): + if iopt[i] == 0: + uspl = UnivariateSpline(x,y,k=k[i],s=s[i]) + elif iopt[i] == 1: + uspl.set_smoothing_factor(s[i]) + assert_almost_equal(uspl.get_residual(), + curfit_test_smth['fp'][i], decimal=2) + n = uspl._data[7] + assert_equal(n,curfit_test_smth['n'][i]) + assert_array_almost_equal(around(uspl.get_knots(),1), + curfit_test_smth['t'][i][k[i]:n-k[i]]) + assert_array_almost_equal(around(uspl.get_coeffs(),4), + curfit_test_smth['c'][i], decimal=3) + assert_array_almost_equal(around(uspl(x),1), + curfit_test_smth['sp'][i]) + + def check_spint_spalde(self): + per = [0, 0, 0] + N = [20, 20, 50] + ia = [0, 0, 0.2*pi] + ib = [0, 0, pi] + a,b = 0,2*pi + dx = 0.2*pi + k = range(1,6) + for i in range(len(per)): + x=a+(b-a)*arange(N[i]+1,dtype=float)/float(N[i]) + v=f1(x) + for j in range(len(k)): + uspl = UnivariateSpline(x,v,k=k[j],s=0) + ir = uspl.integral(ia[i],ib[i]) + dr = uspl.derivatives(dx) + assert_almost_equal(ir, f1(ib[i],-1)-f1(ia[i],-1), decimal=2) + d=0 + for ddr in dr: + if d Author: pierregm Date: 2007-01-15 01:44:41 -0600 (Mon, 15 Jan 2007) New Revision: 2556 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/mrecords.py Log: cf changelog Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-15 00:23:52 UTC (rev 2555) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-15 07:44:41 UTC (rev 2556) @@ -1,3 +1,6 @@ +#2007-01-14 : Mrecords +# : - Slices are now properly supported +# : - `filled` is now properly supported #2007-01-12 : Mrecords # : - Complete reorganization... #2007-01-10 : Mrecords Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-01-15 00:23:52 UTC (rev 2555) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-15 07:44:41 UTC (rev 2556) @@ -140,6 +140,7 @@ 'i' : 999999, 'O' : '?', 'S' : 'N/A', + 'V' : '???', } max_filler = {'b': False, 'f' : -numeric.inf, @@ -574,7 +575,7 @@ except AttributeError: return False # -def make_mask(m, copy=False, small_mask=False): +def make_mask(m, copy=False, small_mask=True, flag=None): """make_mask(m, copy=0, small_mask=0) Returns `m` as a mask, creating a copy if necessary or requested. The function can accept any sequence of integers or `nomask`. @@ -586,6 +587,10 @@ - `copy` (boolean, *[False]*) : Returns a copy of `m` if true. - `small_mask` (boolean, *[False]*): Flattens mask to `nomask` if `m` is all false. """ + if flag is not None: + warnings.warn("The flag 'flag' is now called 'small_mask'!", + DeprecationWarning) + small_mask = flag if m is nomask: return nomask elif isinstance(m, ndarray): @@ -807,14 +812,20 @@ The fill_value is not used for computation within this module. """ __array_priority__ = 10.1 + _defaultmask = nomask + _defaulthardmask = False #TODO: There some reorganization to do round here def __new__(cls, data=None, mask=nomask, dtype=None, copy=False, fill_value=None, - keep_mask=True, small_mask=True, hard_mask=False): + keep_mask=True, small_mask=True, hard_mask=False, flag=None): """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. """ # logging.debug("__new__ received %s" % type(data)) + if flag is not None: + warnings.warn("The flag 'flag' is now called 'small_mask'!", + DeprecationWarning) + small_mask = flag # 1. Argument is MA ........... if isinstance(data, MaskedArray) or\ (hasattr(data,"_mask") and hasattr(data,"_data")) : @@ -881,11 +892,8 @@ cls._defaulthardmask = hard_mask cls._defaultmask = mask # logging.debug("__new__ returned %s as %s" % (type(_data), cls)) -# data = numeric.ndarray.__new__(cls, shape=_data.shape,dtype=_data.dtype, -# buffer=_data.data, offset=0) -# print type(data), data.shape -# return data return numeric.asanyarray(_data).view(cls) + #.................................. def __array_wrap__(self, obj, context=None): """Special hook for ufuncs. @@ -926,16 +934,29 @@ # # logging.debug("__finalize__ received %s" % type(obj)) if isinstance(obj, MaskedArray): -# if isMaskedArray(obj): + # We came here from a MaskedArray self._data = obj._data self._mask = obj._mask self._hardmask = obj._hardmask self._fill_value = obj._fill_value else: - self._data = obj - self._mask = self._defaultmask + # We came here from a .view() + if hasattr(obj,'_data') and hasattr(obj, '_mask'): + # obj is an old masked array or a smart record + self._data = obj._data + self._mask = obj._mask + else: + # obj is anything but... + self._data = obj + self._mask = self._defaultmask + # Set the instance default self._hardmask = self._defaulthardmask self.fill_value = self._fill_value + # Reset the class default + MaskedArray._defaultmask = nomask + MaskedArray._defaulthardmask = False + MaskedArray._fill_value = None +# logging.debug("__finalize__: obj has _mask %s" % hasattr(obj,'_data')) # # # logging.debug("__finalize__ returned %s" % type(self)) return @@ -1146,13 +1167,13 @@ return with_mask1 % { 'name': name, 'data': str(self), - 'mask': str(self.mask), + 'mask': str(self._mask), 'fill': str(self.fill_value), } return with_mask % { 'name': name, 'data': str(self), - 'mask': str(self.mask), + 'mask': str(self._mask), 'fill': str(self.fill_value), } #............................................ @@ -1265,8 +1286,9 @@ try: return self.__class__(self, mask=self._mask, dtype=tc, copy=True) except: - d = self._data.astype(tc) - return self.__class__(d, mask=self._mask, dtype=tc) +# d = self._data.astype(tc) + return self.__class__(self._data.astype(tc), mask=self._mask, + dtype=tc) # # #............................................ Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-15 00:23:52 UTC (rev 2555) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-15 07:44:41 UTC (rev 2556) @@ -13,7 +13,7 @@ import sys import types -import numpy as N +import numpy from numpy import bool_, complex_, float_, int_, str_, object_ import numpy.core.numeric as numeric import numpy.core.numerictypes as ntypes @@ -24,7 +24,7 @@ from numpy.core.records import fromarrays as recfromarrays ndarray = numeric.ndarray -_byteorderconv = N.core.records._byteorderconv +_byteorderconv = numpy.core.records._byteorderconv _typestr = ntypes._typestr import maskedarray as MA @@ -39,8 +39,8 @@ logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) +reserved_fields = ['_data','_mask','_fieldmask', 'dtype'] - def _getformats(data): """Returns the formats of each array of arraylist as a comma-separated string.""" @@ -66,7 +66,6 @@ """ ndescr = len(descr) default_names = ['f%i' % i for i in range(ndescr)] - reserved = ['_data','_mask','_fieldmask', 'dtype'] if names is None: new_names = default_names else: @@ -81,8 +80,8 @@ new_names += default_names[nnames:] ndescr = [] for (n, d, t) in zip(new_names, default_names, descr.descr): - if n in reserved: - if t[0] in reserved: + if n in reserved_fields: + if t[0] in reserved_fields: ndescr.append((d,t[1])) else: ndescr.append(t) @@ -246,7 +245,6 @@ return elif attr == '_mask': if self._hardmask: -# logging.debug("setattr: object has hardmask") if val is not nomask: mval = getmaskarray(val) for k in _names: @@ -272,6 +270,45 @@ return MaskedRecords(_localdict['_data'][indx], mask=_localdict['_fieldmask'][indx], dtype=self.dtype) + + def __getslice__(self, i, j): + """Returns the slice described by [i,j].""" + _localdict = self.__dict__ + return MaskedRecords(_localdict['_data'][i:j], + mask=_localdict['_fieldmask'][i:j], + dtype=self.dtype) + + def __setslice__(self, i, j, value): + """Sets the slice described by [i,j] to `value`.""" + _localdict = self.__dict__ + d = _localdict['_data'] + m = _localdict['_fieldmask'] + names = self.dtype.names + if value is masked: + for n in names: + m[i:j][n] = masked + elif not self._hardmask: + fval = filled(value) + mval = getmaskarray(value) + for n in names: + d[n][i:j] = fval + m[n][i:j] = mval + else: + mindx = getmaskarray(self)[i:j] + val = masked_array(value, mask=mindx, keep_mask=True) + valmask = getmask(value) + if valmask is nomask: + for n in names: + mval = mask_or(m[n][i:j], valmask) + d[n][i:j][~mval] = filled(value) + elif valmask.size > 1: + for n in names: + mval = mask_or(m[n][i:j], valmask) + d[n][i:j][~mval] = fval[~mval] + m[n][i:j] = mask_or(m[n][i:j], mval) + + return MaskedRecords(d, mask=m, dtype=self.dtype) + #...................................................... def __str__(self): """x.__str__() <==> str(x) @@ -312,6 +349,35 @@ if dtype.fields is None: return self.__array__().view(dtype) return ndarray.view(self, obj) + #...................................................... + def filled(self, fill_value=None): + """Returns an array of the same class as `_data`, + with masked values filled with `fill_value`. +Subclassing is preserved. + +If `fill_value` is None, uses self.fill_value. + """ + _localdict = self.__dict__ + d = _localdict['_data'] + fm = _localdict['_fieldmask'] + if not numeric.asarray(fm, dtype=bool_).any(): + return d + # + if fill_value is None: + value = _localdict['fill_value'] + else: + value = fill_value + if numeric.size(value) == 1: + value = [value,] * len(self.dtype) + # + if self is masked: + result = numeric.asanyarray(value) + else: + result = d.copy() + for (n, v) in zip(d.dtype.names, value): + numpy.putmask(numeric.asarray(result[n]), + numeric.asarray(fm[n]), v) + return result #............................................ def harden_mask(self): "Forces the mask to hard" @@ -559,6 +625,43 @@ for (a,m,t) in zip(_variables.T, _mask, vartypes)] return MaskedRecords(_datalist, dtype=mdescr) - - ################################################################################ +if 1: + from maskedarray.testutils import assert_equal + import numpy as N + if 1: +# 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) + mrecord = fromarrays(base.T,) + self_data = [d, m, mrecord] + +# def test_get(self): +# "Tests fields retrieval" + [d, m, mrec] = self_data + mrec = mrec.copy() + 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[1], mrec[1].f0) + # + assert(isinstance(mrec[:2], MaskedRecords)) + assert_equal(mrec[:2]['f0'], d[:2]) + # + mrec[:2] = 5 + assert_equal(mrec.f0._data, [5,5,2,3,4]) + assert_equal(mrec.f1._data, [5,5,2,1,0]) + assert_equal(mrec.f0._mask, [0,0,0,1,1]) + assert_equal(mrec.f1._mask, [0,0,0,0,1]) + mrec.harden_mask() + mrec[-2:] = 5 + assert_equal(mrec.f0._data, [5,5,2,3,4]) + assert_equal(mrec.f1._data, [5,5,2,5,0]) + assert_equal(mrec.f0._mask, [0,0,0,1,1]) + assert_equal(mrec.f1._mask, [0,0,0,0,1]) + \ No newline at end of file From scipy-svn at scipy.org Mon Jan 15 04:57:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 03:57:22 -0600 (CST) Subject: [Scipy-svn] r2557 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070115095722.E235439C0CB@new.scipy.org> Author: pierregm Date: 2007-01-15 03:57:19 -0600 (Mon, 15 Jan 2007) New Revision: 2557 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/mrecords.py trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py Log: cf changelog Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-15 07:44:41 UTC (rev 2556) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-15 09:57:19 UTC (rev 2557) @@ -1,3 +1,5 @@ +#2007-01-15 : MRecords +# : - Add the addfield method #2007-01-14 : Mrecords # : - Slices are now properly supported # : - `filled` is now properly supported @@ -6,13 +8,12 @@ #2007-01-10 : Mrecords # : - Defines a class of records that support masked arrays #2007-01-08 : Core: -# : - Forced to reset the class defaults after initialization -# : - Forced the MaskedArray class defaults to be reset +# : - Force a reset of the class defaults after initialization # : - Modified __array_finallize__ to allow objects w/ _data and _mask fields to be recognized as MA #2007-01-04 : Core: # : - Fixed a but in masked_all_like #2007-01-02 : Extras -# : - Made sure that apply_along_axis output the proper fill_value +# : - Force apply_along_axis to output the proper fill_value # : Core # : - Can use dtypes for the definition of default_fill_value #2006-12-30 : Core Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-15 07:44:41 UTC (rev 2556) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-15 09:57:19 UTC (rev 2557) @@ -387,10 +387,41 @@ self._hardmask = False #............................................. def copy(self): + """Returns a copy of the masked record.""" _localdict = self.__dict__ return MaskedRecords(_localdict['_data'].copy(), mask=_localdict['_fieldmask'].copy(), dtype=self.dtype) + #............................................. + def addfield(self, newfield, newfieldname=None): + """Adds a new field to the masked record array, using `newfield` as data + and `newfieldname` as name. If `newfieldname` is None, the new field name is + set to 'fi', where `i` is the number of existing fields. + """ + _localdict = self.__dict__ + _data = _localdict['_data'] + _mask = _localdict['_fieldmask'] + if newfieldname is None or newfieldname in reserved_fields: + newfieldname = 'f%i' % len(_data.dtype) + newfield = MA.asarray(newfield) + # Get the enw data ............ + newdtype = numeric.dtype(_data.dtype.descr + \ + [(newfieldname, newfield.dtype)]) + newdata = recarray(_data.shape, newdtype) + [newdata.setfield(_data.getfield(*f),*f) + for f in _data.dtype.fields.values()] + newdata.setfield(newfield.filled(), *newdata.dtype.fields[newfieldname]) + # Get the new mask ............. + newmdtype = numeric.dtype([(n,N.bool_) for n in newdtype.names]) + newmask = recarray(_data.shape, newmdtype) + [newmask.setfield(_mask.getfield(*f),*f) + for f in _mask.dtype.fields.values()] + newmask.setfield(getmaskarray(newfield), + *newmask.dtype.fields[newfieldname]) + self.__dict__.update(_data=newdata, + _fieldmask=newmask) +# return MaskedRecords(newdata, mask=newmask, dtype=newdtype) + #####--------------------------------------------------------------------------- @@ -640,28 +671,5 @@ mrecord = fromarrays(base.T,) self_data = [d, m, mrecord] -# def test_get(self): -# "Tests fields retrieval" - [d, m, mrec] = self_data - mrec = mrec.copy() - 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[1], mrec[1].f0) - # - assert(isinstance(mrec[:2], MaskedRecords)) - assert_equal(mrec[:2]['f0'], d[:2]) - # - mrec[:2] = 5 - assert_equal(mrec.f0._data, [5,5,2,3,4]) - assert_equal(mrec.f1._data, [5,5,2,1,0]) - assert_equal(mrec.f0._mask, [0,0,0,1,1]) - assert_equal(mrec.f1._mask, [0,0,0,0,1]) - mrec.harden_mask() - mrec[-2:] = 5 - assert_equal(mrec.f0._data, [5,5,2,3,4]) - assert_equal(mrec.f1._data, [5,5,2,5,0]) - assert_equal(mrec.f0._mask, [0,0,0,1,1]) - assert_equal(mrec.f1._mask, [0,0,0,0,1]) + \ No newline at end of file Modified: trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py 2007-01-15 07:44:41 UTC (rev 2556) +++ trunk/Lib/sandbox/maskedarray/tests/test_mrecords.py 2007-01-15 09:57:19 UTC (rev 2557) @@ -26,9 +26,9 @@ #import maskedarray.mrecords ##reload(maskedarray.mrecords) #from maskedarray.mrecords import mrecarray, fromarrays, fromtextfile, fromrecords -import mrecords -reload(mrecords) -from mrecords import MaskedRecords, fromarrays, fromtextfile, fromrecords +import maskedarray.mrecords +reload(maskedarray.mrecords) +from maskedarray.mrecords import MaskedRecords, fromarrays, fromtextfile, fromrecords #.............................................................................. class test_mrecords(NumpyTestCase): @@ -56,6 +56,9 @@ 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[1], mrec[1].f0) + # + assert(isinstance(mrec[:2], MaskedRecords)) + assert_equal(mrec[:2]['f0'], d[:2]) def test_set(self): "Tests setting fields/attributes." @@ -73,7 +76,22 @@ assert_equal(mrecord['f0']._mask, mrecord['f1']._mask) mrecord._mask = MA.nomask assert_equal(getmaskarray(mrecord['f1']), [0]*5) - assert_equal(mrecord['f0']._mask, mrecord['f1']._mask) + assert_equal(mrecord['f0']._mask, mrecord['f1']._mask) + # + def test_setslices(self): + "Tests setting slices." + [d, m, mrec] = self.data + mrec[:2] = 5 + assert_equal(mrec.f0._data, [5,5,2,3,4]) + assert_equal(mrec.f1._data, [5,5,2,1,0]) + assert_equal(mrec.f0._mask, [0,0,0,1,1]) + assert_equal(mrec.f1._mask, [0,0,0,0,1]) + mrec.harden_mask() + mrec[-2:] = 5 + assert_equal(mrec.f0._data, [5,5,2,3,4]) + assert_equal(mrec.f1._data, [5,5,2,5,0]) + assert_equal(mrec.f0._mask, [0,0,0,1,1]) + assert_equal(mrec.f1._mask, [0,0,0,0,1]) def test_hardmask(self): "Test hardmask" @@ -127,6 +145,13 @@ 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_addfield(self): + "Tests addfield" + [d, m, mrec] = self.data + mrec.addfield(masked_array(d+10, mask=m[::-1])) + assert_equal(mrec.f2, d+10) + assert_equal(mrec.f2._mask, m[::-1]) ############################################################################### #------------------------------------------------------------------------------ From scipy-svn at scipy.org Mon Jan 15 05:05:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 04:05:15 -0600 (CST) Subject: [Scipy-svn] r2558 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070115100515.1F0F839C079@new.scipy.org> Author: pierregm Date: 2007-01-15 04:05:13 -0600 (Mon, 15 Jan 2007) New Revision: 2558 Added: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py Log: Added: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-15 09:57:19 UTC (rev 2557) +++ trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-15 10:05:13 UTC (rev 2558) @@ -0,0 +1,190 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for mrecarray. + +: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 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 +#reload(maskedarray.testutils) +from maskedarray.testutils import assert_equal, assert_array_equal + +import maskedarray.core as MA +import maskedarray.mrecords as MR + +from maskedarray.core import getmaskarray, nomask + +##reload(MA) +#import maskedarray.mrecords +##reload(maskedarray.mrecords) +#from maskedarray.mrecords import mrecarray, fromarrays, fromtextfile, fromrecords +import multitimeseries +reload(multitimeseries) +from multitimeseries import MultiTimeSeries, TimeSeries,\ + fromarrays, fromtextfile, fromrecords, \ + date_array, time_series + +#from timeseries.tseries import time_series, TimeSeries + +#.............................................................................. +class test_mrecords(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 = MR.fromarrays(base.T,) + dlist = ['2007-%02i' % (i+1) for i in d] + dates = date_array(dlist) + ts = time_series(mrec,dates) + mts = MultiTimeSeries(mrec,dates) + self.data = [d, m, mrec, dlist, dates, ts, mts] + + def test_get(self): + "Tests fields retrieval" + [d, m, mrec, dlist, dates, ts, mts] = self.data + assert(isinstance(mts['f0'], TimeSeries)) + assert_equal(mts['f0']._dates, dates) + assert_equal(mts['f0']._data, d) + assert_equal(mts['f0']._mask, m) + # + assert(isinstance(mts[0], MultiTimeSeries)) + assert_equal(mts[0]._data, mrec[0]) + assert_equal(mts[0]._dates, dates[0]) + # + assert(isinstance(mts['2007-01'], MultiTimeSeries)) + assert_equal(mts['2007-01']._data, mrec[0]) + assert_equal(mts['2007-01']._dates, dates[0]) + # + assert_equal(mts.f0, time_series(d, dates=dates, mask=m)) + assert_equal(mts.f1, time_series(d[::-1], dates=dates, mask=m[::-1])) + assert((mts._fieldmask == N.core.records.fromarrays([m, m[::-1]])).all()) + assert_equal(mts._mask, N.r_[[m,m[::-1]]].all(0)) + assert_equal(mts.f0[1], mts[1].f0) + # + assert(isinstance(mts[:2], MultiTimeSeries)) + assert_equal(mts[:2]._data.f0, mrec[:2].f0) + assert_equal(mts[:2]._data.f1, mrec[:2].f1) + assert_equal(mts[:2]._dates, dates[:2]) + + def test_set(self): + "Tests setting fields/attributes." + [d, m, mrec, dlist, dates, ts, mts] = self.data + mts.f0._data[:] = 5 + assert_equal(mts['f0']._data, [5,5,5,5,5]) + mts.f0 = 1 + assert_equal(mts['f0']._data, [1]*5) + assert_equal(getmaskarray(mts['f0']), [0]*5) + mts.f1 = MA.masked + assert_equal(mts.f1.mask, [1]*5) + assert_equal(getmaskarray(mts['f1']), [1]*5) + mts._mask = MA.masked + assert_equal(getmaskarray(mts['f1']), [1]*5) + assert_equal(mts['f0']._mask, mts['f1']._mask) + mts._mask = MA.nomask + assert_equal(getmaskarray(mts['f1']), [0]*5) + assert_equal(mts['f0']._mask, mts['f1']._mask) + + def test_setslices(self): + "Tests setting slices." + [d, m, mrec, dlist, dates, ts, mts] = self.data + # + mts[:2] = 5 + assert_equal(mts.f0._data, [5,5,2,3,4]) + assert_equal(mts.f1._data, [5,5,2,1,0]) + assert_equal(mts.f0._mask, [0,0,0,1,1]) + assert_equal(mts.f1._mask, [0,0,0,0,1]) + mts.harden_mask() + mts[-2:] = 5 + assert_equal(mts.f0._data, [5,5,2,3,4]) + assert_equal(mts.f1._data, [5,5,2,5,0]) + assert_equal(mts.f0._mask, [0,0,0,1,1]) + assert_equal(mts.f1._mask, [0,0,0,0,1]) + + def test_hardmask(self): + "Test hardmask" + [d, m, mrec, dlist, dates, ts, mts] = self.data + mts.harden_mask() + assert(mts._hardmask) + mts._mask = nomask + assert_equal(mts._mask, N.r_[[m,m[::-1]]].all(0)) + mts.soften_mask() + assert(not mts._hardmask) + mts._mask = nomask + assert(mts['f1']._mask is nomask) + assert_equal(mts['f0']._mask,mts['f1']._mask) + + def test_addfield(self): + "Tests addfield" + [d, m, mrec, dlist, dates, ts, mts] = self.data + mts.addfield(masked_array(d+10, mask=m[::-1])) + assert_equal(mts.f2, d+10) + assert_equal(mts.f2._mask, m[::-1]) + + def test_fromrecords(self): + "Test from recarray." + [d, m, mrec, dlist, dates, ts, mts] = self.data + nrec = N.core.records.fromarrays(N.r_[[d,d[::-1]]]) + mrecfr = fromrecords(nrec.tolist(), dates=dates) + assert_equal(mrecfr.f0, mrec.f0) + assert_equal(mrecfr.dtype, mrec.dtype) + #.................... + altrec = [tuple([d,]+list(r)) for (d,r) in zip(dlist,nrec)] + mrecfr = fromrecords(altrec, names='dates,f0,f1') + assert_equal(mrecfr.f0, mrec.f0) + assert_equal(mrecfr.dtype, mrec.dtype) + #.................... + tmp = MultiTimeSeries(mts._series[::-1], dates=mts.dates) + mrecfr = fromrecords(tmp) + assert_equal(mrecfr.f0, mrec.f0[::-1]) + + def test_fromtextfile(self): + "Tests reading from a text file." + fcontent = """# +'Dates', 'One (S)','Two (I)','Three (F)','Four (M)','Five (-)','Six (C)' +'2007-01', 'strings',1,1.0,'mixed column',,1 +'2007-02', 'with embedded "double quotes"',2,2.0,1.0,,1 +'2007-03', 'strings',3,3.0E5,3,,1 +'2007-05','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', + dates_column=0) + os.unlink(fname) + # + dlist = ['2007-%02i' % i for i in (1,2,3,5)] + assert(isinstance(mrectxt, MultiTimeSeries)) + assert_equal(mrectxt._dates, date_array(dlist,'M')) + assert_equal(mrectxt.dtype.names, ['B','C','D','E','F','G']) + assert_equal(mrectxt.G, [1,1,1,1]) + assert_equal(mrectxt.F._mask, [1,1,1,1]) + assert_equal(mrectxt.D, [1,2,3.e+5,-1e-10]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Property changes on: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Mon Jan 15 05:05:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 04:05:54 -0600 (CST) Subject: [Scipy-svn] r2559 - trunk/Lib/sandbox/timeseries Message-ID: <20070115100554.BD56839C079@new.scipy.org> Author: pierregm Date: 2007-01-15 04:05:51 -0600 (Mon, 15 Jan 2007) New Revision: 2559 Added: trunk/Lib/sandbox/timeseries/tmulti.py Modified: trunk/Lib/sandbox/timeseries/CHANGELOG Log: add support to multi-variable time series (thorugh masked record arrays) Modified: trunk/Lib/sandbox/timeseries/CHANGELOG =================================================================== --- trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-15 10:05:13 UTC (rev 2558) +++ trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-15 10:05:51 UTC (rev 2559) @@ -1,3 +1,4 @@ +#2007-01-15 : - Added tmulti and its tests, to support multi-variable series #2007-01-14 : Code reorganization: # : - Moved Matt's initial version to archived_version # : - Moved Pierre's version to base Added: trunk/Lib/sandbox/timeseries/tmulti.py =================================================================== --- trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-15 10:05:13 UTC (rev 2558) +++ trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-15 10:05:51 UTC (rev 2559) @@ -0,0 +1,622 @@ +# pylint: disable-msg=W0201, W0212 +""" +Support for multi-variable time series, through masked recarrays. + +: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 sys + +import numpy +from numpy import bool_, complex_, float_, int_, str_, object_ +import numpy.core.fromnumeric as fromnumeric +import numpy.core.numeric as numeric +import numpy.core.numerictypes as ntypes +import numpy.core.umath as umath +from numpy.core.defchararray import chararray +from numpy.core.records import find_duplicate +from numpy.core.records import format_parser, recarray, record +from numpy.core.records import fromarrays as recfromarrays + +import maskedarray as MA +#import numpy.core.ma as MA +#reload(MA) +#MaskedArray = MA.MaskedArray +from maskedarray.core import MaskedArray, MAError, default_fill_value, \ + masked_print_option +from maskedarray.core import masked, nomask, getmask, getmaskarray, make_mask,\ + make_mask_none, mask_or, masked_array, filled + +import maskedarray.mrecords as MR +reload(MR) +from maskedarray.mrecords import _checknames, _guessvartypes, openfile,\ + MaskedRecords +from maskedarray.mrecords import fromrecords as mrecfromrecords + +from tseries import TimeSeries, time_series, _getdatalength +from tdates import Date, DateArray, date_array + +ndarray = numeric.ndarray +_byteorderconv = numpy.core.records._byteorderconv +_typestr = ntypes._typestr + +reserved_fields = MR.reserved_fields + ['_dates'] + +import warnings +import logging +logging.basicConfig(level=logging.DEBUG, + format='%(name)-15s %(levelname)s %(message)s',) + + +def _getformats(data): + """Returns the formats of each array of arraylist as a comma-separated + string.""" + if isinstance(data, record): + return ",".join([desc[1] for desc in data.dtype.descr]) + + formats = '' + for obj in data: + obj = numeric.asarray(obj) +# if not isinstance(obj, ndarray): +## if not isinstance(obj, ndarray): +# raise ValueError, "item in the array list must be an ndarray." + formats += _typestr[obj.dtype.type] + if issubclass(obj.dtype.type, ntypes.flexible): + formats += `obj.itemsize` + formats += ',' + return formats[:-1] + + + + + +class MultiTimeSeries(TimeSeries, MaskedRecords, object): + """ + +:IVariables: + - `__localfdict` : Dictionary + Dictionary of local fields (`f0_data`, `f0_mask`...) + - `__globalfdict` : Dictionary + Dictionary of global fields, as the combination of a `_data` and a `_mask`. + (`f0`) + """ + _defaultfieldmask = nomask + _defaulthardmask = False + def __new__(cls, data, dates=None, mask=nomask, dtype=None, + freq=None, observed=None, start_date=None, + hard_mask=False, fill_value=None, +# offset=0, strides=None, + formats=None, names=None, titles=None, + byteorder=None, aligned=False): + tsoptions = dict(fill_value=fill_value, hard_mask=hard_mask,) + mroptions = dict(fill_value=fill_value, hard_mask=hard_mask, + formats=formats, names=names, titles=titles, + byteorder=byteorder, aligned=aligned) + logging.debug("__new__ received %s" % type(data)) + # + if isinstance(data, MultiTimeSeries): + cls._defaultfieldmask = data._series._fieldmask + cls._defaulthardmask = data._series._hardmask | hard_mask + cls._fill_value = data._series._fill_value + return data._data.view(cls) +# elif isinstance(data, TimeSeries): +# cls._defaultfieldmask = data._series._fieldmask +# cls._defaulthardmask = data._series._hardmask | hard_mask +# cls._fill_value = data._series._fill_value + + # ....................................... + _data = MaskedRecords(data, mask=mask, dtype=dtype, **mroptions) + if dates is None: + length = _getdatalength(data) + newdates = date_array(start_date=start_date, length=length, + freq=freq) + elif not hasattr(dates, 'freq'): + newdates = date_array(dlist=dates, freq=freq) + else: + newdates = dates +# _data = data +# if hasattr(data, '_mask') : +# mask = mask_or(data._mask, mask) + cls._defaultdates = newdates + cls._defaultobserved = observed + cls._defaultfieldmask = _data._fieldmask +# assert(_datadatescompat(data,newdates)) + # + return _data.view(cls) + + def __array_finalize__(self,obj): + logging.debug("__array_finalize__ received %s" % type(obj)) + if isinstance(obj, MultiTimeSeries): + self.__dict__.update(_dates=obj._dates, + _series=obj._series, + _data=obj._series._data, + _fieldmask=obj._series._fieldmask, + _hardmask=obj._series._hardmask, + _fill_value=obj._fill_value + ) + else: + logging.debug("__array_finalize__ dtype %s" % obj.dtype) + logging.debug("__array_finalize__ mask %s" % self._defaultfieldmask) + self.__dict__.update(_data = obj.view(recarray), + _dates = self._defaultdates, + _series = MaskedRecords(obj, dtype=obj.dtype), + _fieldmask = self._defaultfieldmask, + _hardmask = self._defaulthardmask, + fill_value = self._fill_value + ) + MultiTimeSeries._defaultfieldmask = nomask + MultiTimeSeries._defaulthardmask = False +# logging.debug("__array_finalize__ exit ") + return + #...................................................... + def __getattribute__(self, attr): +# logging.debug('__getattribute__ %s' % attr) + try: + # Returns a generic attribute + return object.__getattribute__(self,attr) + except AttributeError: + # OK, so attr must be a field name + pass + # Get the list of fields ...... +# logging.debug('__getattribute__ %s listfield' % attr) + _names = self.dtype.names + _local = self.__dict__ + _mask = _local['_fieldmask'] + if attr in _names: + _data = _local['_data'] + obj = numeric.asarray(_data.__getattribute__(attr)).view(MaskedArray) + obj._mask = make_mask(_mask.__getattribute__(attr)) + return obj + elif attr == '_mask': +# logging.debug('__getattribute__ return mask') + if self.size > 1: + return _mask.view((bool_, len(self.dtype))).all(1) + return _mask.view((bool_, len(self.dtype))) + raise AttributeError,"No attribute '%s' !" % attr + + def __setattr__(self, attr, val): +# logging.debug('__setattribute__ %s' % attr) + newattr = attr not in self.__dict__ + try: + # Is attr a generic attribute ? + ret = object.__setattr__(self, attr, val) + except: + # Not a generic attribute: exit if it's not a valid field +# logging.debug('__setattribute__ %s' % attr) + fielddict = self.dtype.names or {} + if attr not in fielddict: + exctype, value = sys.exc_info()[:2] + raise exctype, value + else: + if attr not in list(self.dtype.names) + ['_mask']: + return ret + if newattr: # We just added this one + try: # or this setattr worked on an internal + # attribute. + object.__delattr__(self, attr) + except: + return ret + # Case #1.: Basic field ............ + base_fmask = self._fieldmask + _names = self.dtype.names + if attr in _names: + fval = filled(val) + mval = getmaskarray(val) + if self._hardmask: + mval = mask_or(mval, base_fmask.__getattr__(attr)) + self._data.__setattr__(attr, fval) + base_fmask.__setattr__(attr, mval) + return + elif attr == '_mask': + if self._hardmask: + val = make_mask(val) + logging.debug("setattr: object has hardmask %s" % val) + logging.debug("setattr: val is nomask: %s" % (val is nomask)) + if val is not nomask: +# mval = getmaskarray(val) + for k in _names: + m = mask_or(val, base_fmask.__getattr__(k)) + logging.debug("setattr: %k to: %s" % (k,m)) + base_fmask.__setattr__(k, m) + else: + logging.debug("setattr: VAL IS NOMASK: %s" % (val is nomask)) + return + else: + mval = getmaskarray(val) + for k in _names: + base_fmask.__setattr__(k, mval) + return + #............................................ + def __getitem__(self, indx): + """Returns all the fields sharing the same fieldname base. + The fieldname base is either `_data` or `_mask`.""" + logging.debug('__getitem__(%s)' % indx) + _localdict = self.__dict__ + # We want a field ........ + if indx in self.dtype.names: + logging.debug('__getitem__ getfield %s' % indx) + obj = _localdict['_series'][indx].view(TimeSeries) + obj._mask = make_mask(_localdict['_fieldmask'][indx]) + logging.debug('__getitem__ field %s mask %s:' % (indx, obj._mask)) + return obj + # We want some elements .. + indx = super(MultiTimeSeries, self)._TimeSeries__checkindex(indx) + return MultiTimeSeries(_localdict['_series'][indx], + dates=_localdict['_dates'][indx], +# mask=_localdict['_fieldmask'][indx], + dtype=self.dtype) + + def __getslice__(self, i, j): + """Returns the slice described by [i,j].""" + logging.debug("__Getslice__ [%i,%i]" % (i,j)) + _localdict = self.__dict__ + return MultiTimeSeries(_localdict['_data'][i:j], + mask=_localdict['_fieldmask'][i:j], + dates=_localdict['_dates'][i:j], + dtype=self.dtype) + + def __setslice__(self, i, j, value): + """Sets the slice described by [i,j] to `value`.""" + _localdict = self.__dict__ + d = _localdict['_data'] + t = _localdict['_dates'] + m = _localdict['_fieldmask'] + names = self.dtype.names + if value is masked: + for n in names: + m[i:j][n] = masked + elif not self._hardmask: + fval = filled(value) + mval = getmaskarray(value) + for n in names: + d[n][i:j] = fval + m[n][i:j] = mval + else: + mindx = getmaskarray(self)[i:j] + val = masked_array(value, mask=mindx, keep_mask=True) + valmask = getmask(value) + if valmask is nomask: + for n in names: + mval = mask_or(m[n][i:j], valmask) + d[n][i:j][~mval] = filled(value) + elif valmask.size > 1: + for n in names: + mval = mask_or(m[n][i:j], valmask) + d[n][i:j][~mval] = fval[~mval] + m[n][i:j] = mask_or(m[n][i:j], mval) + + return MultiTimeSeries(d, mask=m, dates=t[i:j], dtype=self.dtype) + + + #...................................................... + def __str__(self): + """x.__str__() <==> str(x) +Calculates the string representation, using masked for fill if it is enabled. +Otherwise, fills with fill value. + """ + if self.size > 1: + mstr = ["(%s)" % ",".join([str(i) for i in s]) + for s in zip(*[getattr(self,f) for f in self.dtype.names])] + return "[%s]" % ", ".join(mstr) + else: + mstr = numeric.asarray(self._data.item(), dtype=object_) + mstr[list(self._fieldmask)] = masked_print_option + return str(mstr) + + def __repr__(self): + """x.__repr__() <==> repr(x) +Calculates the repr representation, using masked for fill if it is enabled. +Otherwise fill with fill value. + """ + _names = self.dtype.names + _dates = self._dates + if numeric.size(_dates) > 2 and self._dates.isvalid(): + timestr = "[%s ... %s]" % (str(_dates[0]),str(_dates[-1])) + else: + timestr = str(_dates) + fmt = "%%%is : %%s" % (max([len(n) for n in _names])+4,) + reprstr = [fmt % (f,getattr(self,f)) for f in self.dtype.names] + reprstr.insert(0,'multitimeseries(') + reprstr.extend([fmt % ('dates', timestr), + fmt % (' fill_value', self._fill_value), + ' )']) + return str("\n".join(reprstr)) + #...................................................... + def view(self, obj): + """Returns a view of the mrecarray.""" + try: + if issubclass(obj, ndarray): +# logging.debug('direct view as %s' % obj) + return ndarray.view(self, obj) + except TypeError: + pass + dtype = numeric.dtype(obj) + if dtype.fields is None: + return self.__array__().view(dtype) + return ndarray.view(self, obj) + #............................................ +# def harden_mask(self): +# "Forces the mask to hard" +# self._hardmask = True +# def soften_mask(self): +# "Forces the mask to soft" +# self._hardmask = False + #............................................. + def copy(self): + "Returns a copy of the argument." + _localdict = self.__dict__ + return MultiTimeSeries(_localdict['_data'].copy(), + dates=_localdict['_dates'].copy(), + mask=_localdict['_fieldmask'].copy(), + dtype=self.dtype) + #............................................. + def addfield(self, newfield, newfieldname=None): + MaskedRecords.addfield(self, newfield, newfieldname) + +#####--------------------------------------------------------------------------- +#---- --- Constructors --- +#####--------------------------------------------------------------------------- + +def fromarrays(arraylist, dates=None, + dtype=None, shape=None, formats=None, + names=None, titles=None, aligned=False, byteorder=None): + """Creates a mrecarray from a (flat) list of masked arrays. + +:Parameters: + - `arraylist` : Sequence + A list of (masked) arrays. Each element of the sequence is first converted + to a masked array if needed. If a 2D array is passed as argument, it is + processed line by line + - `dtype` : numeric.dtype + Data type descriptor. + - `shape` : Integer *[None]* + Number of records. If None, `shape` is defined from the shape of the first + array in the list. + - `formats` : + (Description to write) + - `names` : + (description to write) + - `titles`: + (Description to write) + - `aligned`: Boolen *[False]* + (Description to write, not used anyway) + - `byteorder`: Boolen *[None]* + (Description to write, not used anyway) + + + """ + arraylist = [MA.asarray(x) for x in arraylist] + # Define/check the shape..................... + if shape is None or shape == 0: + shape = arraylist[0].shape + if isinstance(shape, int): + shape = (shape,) + # Define formats from scratch ............... + if formats is None and dtype is None: + formats = _getformats(arraylist) +# logging.debug("fromarrays: formats",formats) + # Define the dtype .......................... + if dtype is not None: + descr = numeric.dtype(dtype) + _names = descr.names + else: + parsed = format_parser(formats, names, titles, aligned, byteorder) + _names = parsed._names + descr = parsed._descr + # Determine shape from data-type............. + if len(descr) != len(arraylist): + msg = "Mismatch between the number of fields (%i) and the number of "\ + "arrays (%i)" + raise ValueError, msg % (len(descr), len(arraylist)) + d0 = descr[0].shape + nn = len(d0) + if nn > 0: + shape = shape[:-nn] + # Make sure the shape is the correct one .... + for k, obj in enumerate(arraylist): + nn = len(descr[k].shape) + testshape = obj.shape[:len(obj.shape)-nn] + if testshape != shape: + raise ValueError, "Array-shape mismatch in array %d" % k + # Reconstruct the descriptor, by creating a _data and _mask version + return MultiTimeSeries(arraylist, dtype=descr) + +def __getdates(dates=None, newdates=None, length=None, freq=None, + start_date=None): + """Determines new dates (private function not meant to be used).""" + if dates is None: + if newdates is not None: + if not hasattr(newdates, 'freq'): + newdates = date_array(dlist=newdates, freq=freq) + else: + newdates = date_array(start_date=start_date, length=length, + freq=freq) + elif not hasattr(dates, 'freq'): + newdates = date_array(dlist=dates, freq=freq) + else: + newdates = dates + return newdates + +#.............................................................................. +def fromrecords(reclist, dates=None, freq=None, start_date=None, + dtype=None, shape=None, formats=None, names=None, + titles=None, aligned=False, byteorder=None): + """Creates a MaskedRecords from a list of records. + + The data in the same field can be heterogeneous, they will be promoted + to the highest data type. This method is intended for creating + smaller record arrays. If used to create large array without formats + defined, it can be slow. + + If formats is None, then this will auto-detect formats. Use a list of + tuples rather than a list of lists for faster processing. + """ + # reclist is in fact a mrecarray ................. + if isinstance(reclist, MultiTimeSeries): + mdescr = reclist.dtype + shape = reclist.shape + return MultiTimeSeries(reclist, dtype=mdescr) + # No format, no dtype: create from to arrays ..... + _data = mrecfromrecords(reclist, dtype=dtype, shape=shape, formats=formats, + names=names, titles=titles, aligned=aligned, + byteorder=byteorder) + _dtype = _data.dtype + # Check the names for a '_dates' ................. + newdates = None + _names = list(_dtype.names) + reserved = [n for n in _names if n.lower() in ['dates', '_dates']] + if len(reserved) > 0: + newdates = _data[reserved[-1]] + [_names.remove(n) for n in reserved] + _dtype = numeric.dtype([t for t in _dtype.descr \ + if t[0] not in reserved ]) + _data = [_data[n] for n in _names] + # + newdates = __getdates(dates=dates, newdates=newdates, length=len(_data), + freq=freq, start_date=start_date) + # + return MultiTimeSeries(_data, dates=newdates, dtype=_dtype, + names=_names) + + +def fromtextfile(fname, delimitor=None, commentchar='#', missingchar='', + dates_column=None, varnames=None, vartypes=None, + dates=None): + """Creates a multitimeseries from data stored in the file `filename`. + +:Parameters: + - `filename` : file name/handle + Handle of an opened file. + - `delimitor` : Character *None* + Alphanumeric character used to separate columns in the file. + If None, any (group of) white spacestring(s) will be used. + - `commentchar` : String *['#']* + Alphanumeric character used to mark the start of a comment. + - `missingchar` : String *['']* + String indicating missing data, and used to create the masks. + - `datescol` : Integer *[None]* + Position of the columns storing dates. If None, a position will be + estimated from the variable names. + - `varnames` : Sequence *[None]* + Sequence of the variable names. If None, a list will be created from + the first non empty line of the file. + - `vartypes` : Sequence *[None]* + Sequence of the variables dtypes. If None, the sequence will be estimated + from the first non-commented line. + + + Ultra simple: the varnames are in the header, one line""" + # Try to open the file ...................... + f = openfile(fname) + # Get the first non-empty line as the varnames + while True: + line = f.readline() + firstline = line[:line.find(commentchar)].strip() + _varnames = firstline.split(delimitor) +# logging.debug("_VARNAMES:%s-%s"% (_varnames,len(_varnames))) + if len(_varnames) > 1: + break + if varnames is None: + varnames = _varnames + # Get the data .............................. + _variables = MA.asarray([line.strip().split(delimitor) for line in f + if line[0] != commentchar and len(line) > 1]) + (nvars, nfields) = _variables.shape + # Check if we need to get the dates.......... + if dates_column is None: + dates_column = [i for (i,n) in enumerate(list(varnames)) + if n.lower() in ['_dates','dates']] + elif isinstance(dates_column,(int,float)): + if dates_column > nfields: + raise ValueError,\ + "Invalid column number: %i > %i" % (dates_column, nfields) + dates_column = [dates_column,] + if len(dates_column) > 0: + cols = range(nfields) + [cols.remove(i) for i in dates_column] + newdates = date_array(_variables[:,dates_column[-1]]) + _variables = _variables[:,cols] + varnames = [varnames[i] for i in cols] + if vartypes is not None: + vartypes = [vartypes[i] for i in cols] + nfields -= len(dates_column) + else: + newdates = None + # Try to guess the dtype .................... + if vartypes is None: + vartypes = _guessvartypes(_variables[0]) + else: + vartypes = [numeric.dtype(v) for v in vartypes] + if len(vartypes) != nfields: + msg = "Attempting to %i dtypes for %i fields!" + msg += " Reverting to default." + warnings.warn(msg % (len(vartypes), nfields)) + vartypes = _guessvartypes(_variables[0]) + # Construct the descriptor .................. + mdescr = [(n,f) for (n,f) in zip(varnames, vartypes)] +# logging.debug("fromtextfile: descr: %s" % mdescr) + # Get the data and the mask ................. + # We just need a list of masked_arrays. It's easier to create it like that: + _mask = (_variables.T == missingchar) + _datalist = [masked_array(a,mask=m,dtype=t) + for (a,m,t) in zip(_variables.T, _mask, vartypes)] + # + newdates = __getdates(dates=dates, newdates=newdates, length=nvars, + freq=None, start_date=None) + return MultiTimeSeries(_datalist, dates=newdates, dtype=mdescr) + + + +################################################################################ + + +################################################################################ +#if 1: +# from tseries import aligned +# import maskedarray.testutils +# from maskedarray.testutils import * +# +# if 1: +# mlist = ['2005-%02i' % i for i in range(1,13)] +# mlist += ['2006-%02i' % i for i in range(1,13)] +# mdata = numpy.arange(24) +# mser1 = time_series(mdata, mlist, observed='SUMMED') +# # +# if 1: +# mlist2 = ['2004-%02i' % i for i in range(1,13)] +# mlist2 += ['2005-%02i' % i for i in range(1,13)] +# mser2 = time_series(mdata, mlist2, observed='SUMMED') +# # +# (malg1,malg2) = aligned(mser1, mser2) +# if 1: +# mrec = MR.fromarrays([mser1]) +# descr = [('A',N.float_),('B',N.float_)] +# +#if 1: +# if 1: +## 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 = MR.fromarrays(base.T,) +# dlist = ['2007-%02i' % (i+1) for i in d] +# dates = date_array(dlist) +# ts = time_series(mrec,dates) +# mts = MultiTimeSeries(mrec,dates) +# self_data = [d, m, mrec, dlist, dates, ts, mts] +# # +# mts.addfield(masked_array(d+10, mask=m[::-1])) +# assert('f2' in mts.dtype.names) +# assert_equal(mts.f2, d+10) +# assert_equal(mts.f2._mask, m[::-1]) + Property changes on: trunk/Lib/sandbox/timeseries/tmulti.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Mon Jan 15 10:01:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 09:01:05 -0600 (CST) Subject: [Scipy-svn] r2560 - trunk/Lib/sandbox/timeseries/doc Message-ID: <20070115150105.D8C1A39C032@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 09:01:02 -0600 (Mon, 15 Jan 2007) New Revision: 2560 Modified: trunk/Lib/sandbox/timeseries/doc/todo.txt Log: Modified: trunk/Lib/sandbox/timeseries/doc/todo.txt =================================================================== --- trunk/Lib/sandbox/timeseries/doc/todo.txt 2007-01-15 10:05:51 UTC (rev 2559) +++ trunk/Lib/sandbox/timeseries/doc/todo.txt 2007-01-15 15:01:02 UTC (rev 2560) @@ -4,15 +4,9 @@ but would be nice to have none-the-less :) =================================================================== - - make the various Date data types actual numpy data types instead of - an ugly hack (this is probably beyond my ability) + - create an actual Date data type so dates can be stored in arrays without + resorting to object_ dtype - - add support for a few more frequency conversions that are missing - in the dateOf function in tsdate.py - - - support "secondly" frequency data in a more robust way. Frequency - conversion methods are not supported for this currently. - - add a "basis" option to the convert method. Possible values are 'business' or 'daily'. This would be used in determining the weights of the months, quarters, etc when converting things with @@ -21,21 +15,16 @@ This should also be an attribute of each TimeSeries object that would provide the default behaviour if the basis option was not specified. - - support for wider variety of standard numpy/ma functions - - add time series specific concepts/functions like moving averages, MACD, moving standard deviation, etc... - - add support for more frequencies: semi-annual, hourly, minutely, - decade, weekly, and maybe even sub-frequencies like quarterly with - quarters ending on months other than Mar/Jun/Sep/Dec, weekly ending - on different days of the the week, etc... - - - Decide how best to handle frequency conversion between frequencies that - don't have a nice relationship where the lower frequency strictly contains - whole periods of the higher frequency. For example, if converting weekly to - monthly, some weeks overlap more than one month. + - add support for more frequencies: semi-annual, decade, and maybe even + sub-frequencies like quarterly with quarters ending on months other than + Mar/Jun/Sep/Dec, weekly ending on different days of the the week, etc... + - additional unit-tests + + - documentation Wishlist: @@ -45,9 +34,10 @@ if the built in datetime module is up to the task though, particularly where the c-api is concerned. - - integration with pytables perhaps? Definitely a longer term thing, but eventually who knows? (I currently have my - own module for writing this stuff to FAME databases, but pytables would be cooler) + - pytables submodule for reading and writing timeseries objects directly + to/from HDF5 databases - - integration with matplotlib? + - plotting sub-module so timeseries objects can be easily plotted using + matplotlib - - report generation module? + - reporting sub-module From scipy-svn at scipy.org Mon Jan 15 13:55:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 12:55:22 -0600 (CST) Subject: [Scipy-svn] r2561 - trunk/Lib/sandbox/timeseries Message-ID: <20070115185522.CDEED39C03F@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 12:55:18 -0600 (Mon, 15 Jan 2007) New Revision: 2561 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: bug fixes Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-15 15:01:02 UTC (rev 2560) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-15 18:55:18 UTC (rev 2561) @@ -177,20 +177,20 @@ if self.mxDate.day_of_week in [5,6]: raise ValueError("Weekend passed as business day") elif self.freq in ['H','S','T']: - if not hours: - if not minutes: - if not seconds: + if hours is None: + if minutes is None: + if seconds is None: hours = 0 else: hours = seconds//3600 else: hours = minutes // 60 - if not minutes: - if not seconds: + if minutes is None: + if seconds is None: minutes = 0 else: minutes = (seconds-hours*3600)//60 - if not seconds: + if seconds is None: seconds = 0 else: seconds = seconds % 60 @@ -277,13 +277,12 @@ "Converts the date to an integer, depending on the current frequency." # Annual ....... if self.freq == 'A': - val = int(self.mxDate.year) + val = self.mxDate.year # Business days. elif self.freq == 'B': days = self.mxDate.absdate weeks = days // 7 -# val = (weeks*5) + (days - weeks*7) - val = days - weeks*2 + val = days - weeks*2 # (weeks*5) + (days - weeks*7) # Daily/undefined elif self.freq in ['D', 'U']: val = self.mxDate.absdate @@ -304,7 +303,6 @@ val = (self.mxDate - minutelyOriginDate).minutes # Weekly........ elif self.freq == 'W': - #val = int(self.mxDate.year*365.25/7.-1) + self.mxDate.iso_week[1] val = self.mxDate.absdate//7 return int(val) #...................................................... @@ -382,7 +380,7 @@ return mxD.Date(mxDate.year, mxDate.month) elif freq == 'W': d = mxDate.absdate - return mxD.DateTimeFromAbsDateTime(d + (7 - d % 7) % 7 - 1) + return mxD.DateTimeFromAbsDateTime(d + (7 - d % 7) % 7) elif freq in ('B', 'D'): if freq == 'B' and mxDate.day_of_week in [5,6]: raise ValueError("Weekend passed as business day") From scipy-svn at scipy.org Mon Jan 15 13:55:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 12:55:53 -0600 (CST) Subject: [Scipy-svn] r2562 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070115185553.29A5A39C03F@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 12:55:50 -0600 (Mon, 15 Jan 2007) New Revision: 2562 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: * added support for weekly frequency * bug fixes Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-15 18:55:18 UTC (rev 2561) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-15 18:55:50 UTC (rev 2562) @@ -123,9 +123,8 @@ return result; } +static long asfreq_DtoW(long fromDate, char relation) { return (fromDate - 1)/7 + 1; } -static long asfreq_DtoW(long fromDate, char relation) { return -1; } - static long asfreq_DtoB(long fromDate, char relation) { mxDateTimeObject *mxDate; long result; @@ -246,51 +245,70 @@ //************ FROM WEEKLY *************** -static long asfreq_WtoA(long fromDate, char relation) { return -1; } -static long asfreq_WtoQ(long fromDate, char relation) { return -1; } -static long asfreq_WtoM(long fromDate, char relation) { return -1; } -static long asfreq_WtoB(long fromDate, char relation) { return -1; } -static long asfreq_WtoD(long fromDate, char relation) { return -1; } -static long asfreq_WtoH(long fromDate, char relation) { return -1; } -static long asfreq_WtoT(long fromDate, char relation) { return -1; } -static long asfreq_WtoS(long fromDate, char relation) { return -1; } +static long asfreq_WtoD(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 7 - 6;} + else { return fromDate * 7; }} -//************ FROM MONTHLY *************** +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_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_WtoB(long fromDate, char relation) { + mxDateTimeObject *mxDate; + long result; -static long asfreq_MtoW(long fromDate, char relation) { return -1; } + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(asfreq_WtoD(fromDate, relation), 0); + if (relation == 'B') { result = DtoB_WeekendToMonday(mxDate); } + else { result = DtoB_WeekendToFriday(mxDate); } + Py_DECREF(mxDate); + return result; +} +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); } + +//************ FROM MONTHLY *************** + static void MtoD_ym(long fromDate, long *y, long *m) { *y = (fromDate - 1) / 12 + 1; *m = fromDate - 12 * (*y) - 1; } -static long asfreq_MtoB(long fromDate, char relation) { +static long asfreq_MtoD(long fromDate, char relation) { long y, m; if (relation == 'B') { MtoD_ym(fromDate, &y, &m); - return busday_before(y,m,1); + return absdate_from_ymd(y, m, 1); } else { MtoD_ym(fromDate+1, &y, &m); - return busday_after(y, m, 1); + return absdate_from_ymd(y, m, 1) - 1; } } -static long asfreq_MtoD(long fromDate, char relation) { +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; } - long y, m; +static long asfreq_MtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_MtoD(fromDate, relation), relation); } - if (relation == 'B') { - MtoD_ym(fromDate, &y, &m); - return absdate_from_ymd(y, m, 1); - } else { - MtoD_ym(fromDate+1, &y, &m); - return absdate_from_ymd(y, m, 1) - 1; - } +static long asfreq_MtoB(long fromDate, char relation) { + + mxDateTimeObject *mxDate; + long result; + + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(asfreq_MtoD(fromDate, relation), 0); + if (relation == 'B') { result = DtoB_WeekendToMonday(mxDate); } + else { result = DtoB_WeekendToFriday(mxDate); } + Py_DECREF(mxDate); + return result; } static long asfreq_MtoH(long fromDate, char relation) { return asfreq_DtoH(asfreq_MtoD(fromDate, relation), relation); } @@ -299,46 +317,46 @@ //************ FROM QUARTERLY *************** -static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1)/ 4 + 1; } - -static long asfreq_QtoM(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 3 - 2; } - else { return fromDate * 3; } -} - -static long asfreq_QtoW(long fromDate, char relation) { return -1; } - static void QtoD_ym(long fromDate, long *y, long *m) { *y = (fromDate - 1) / 4 + 1; *m = (fromDate + 4) * 3 - 12 * (*y) - 2; } -static long asfreq_QtoB(long fromDate, char relation) { +static long asfreq_QtoD(long fromDate, char relation) { long y, m; if (relation == 'B') { QtoD_ym(fromDate, &y, &m); - return busday_before(y,m,1); + return absdate_from_ymd(y, m, 1); } else { QtoD_ym(fromDate+1, &y, &m); - return busday_after(y, m, 1); + return absdate_from_ymd(y, m, 1) - 1; } } -static long asfreq_QtoD(long fromDate, char relation) { +static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1)/ 4 + 1; } - long y, m; +static long asfreq_QtoM(long fromDate, char relation) { + if (relation == 'B') { return fromDate * 3 - 2; } + else { return fromDate * 3; } +} - if (relation == 'B') { - QtoD_ym(fromDate, &y, &m); - return absdate_from_ymd(y, m, 1); - } else { - QtoD_ym(fromDate+1, &y, &m); - return absdate_from_ymd(y, m, 1) - 1; - } +static long asfreq_QtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_QtoD(fromDate, relation), relation); } + +static long asfreq_QtoB(long fromDate, char relation) { + + mxDateTimeObject *mxDate; + long result; + + mxDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(asfreq_QtoD(fromDate, relation), 0); + if (relation == 'B') { result = DtoB_WeekendToMonday(mxDate); } + else { result = DtoB_WeekendToFriday(mxDate); } + Py_DECREF(mxDate); + return result; } + 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); } @@ -346,6 +364,11 @@ //************ FROM ANNUAL *************** +static long asfreq_AtoD(long fromDate, char relation) { + if (relation == 'B') { return absdate_from_ymd(fromDate,1,1); } + else { return absdate_from_ymd(fromDate+1,1,1) - 1; } +} + static long asfreq_AtoQ(long fromDate, char relation) { if (relation == 'B') { return fromDate * 4 - 3; } else { return fromDate * 4; } @@ -356,18 +379,13 @@ else { return fromDate * 12; } } -static long asfreq_AtoW(long fromDate, char relation) { return -1; } +static long asfreq_AtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_AtoD(fromDate, relation), relation); } static long asfreq_AtoB(long fromDate, char relation) { if (relation == 'B') { return busday_before(fromDate,1,1); } else { return busday_after(fromDate+1,1,1); } } -static long asfreq_AtoD(long fromDate, char relation) { - if (relation == 'B') { return absdate_from_ymd(fromDate,1,1); } - else { return absdate_from_ymd(fromDate+1,1,1) - 1; } -} - 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); } @@ -553,6 +571,14 @@ case 'Q': return 3; default: return 1; } + case 'W': //monthly + switch(toFreq) + { + case 'A': return 53; + case 'Q': return 13; + case 'M': return 4; + default: return 1; + } case 'B': //business switch(toFreq) { @@ -571,6 +597,42 @@ case 'W': return 7; default: return 1; } + case 'H': //hourly + switch(toFreq) + { + case 'A': return 24 * maxDaysPerYear;; + case 'Q': return 24 * maxDaysPerQuarter; + case 'M': return 24 * maxDaysPerMonth; + case 'W': return 24 * 7; + case 'D': return 24; + case 'B': return 24; + default: return 1; + } + case 'T': //minutely + switch(toFreq) + { + case 'A': return 24 * 60 * maxDaysPerYear;; + case 'Q': return 24 * 60 * maxDaysPerQuarter; + case 'M': return 24 * 60 * maxDaysPerMonth; + case 'W': return 24 * 60 * 7; + case 'D': return 24 * 60; + case 'B': return 24 * 60; + case 'H': return 60; + default: return 1; + } + case 'S': //minutely + switch(toFreq) + { + case 'A': return 24 * 60 * 60 * maxDaysPerYear;; + case 'Q': return 24 * 60 * 60 * maxDaysPerQuarter; + case 'M': return 24 * 60 * 60 * maxDaysPerMonth; + case 'W': return 24 * 60 * 60 * 7; + case 'D': return 24 * 60 * 60; + case 'B': return 24 * 60 * 60; + case 'H': return 60 * 60; + case 'T': return 60; + default: return 1; + } default: return 1; } } From scipy-svn at scipy.org Mon Jan 15 13:57:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 12:57:26 -0600 (CST) Subject: [Scipy-svn] r2563 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070115185726.3B46C39C0BD@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 12:57:21 -0600 (Mon, 15 Jan 2007) New Revision: 2563 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: added tests for frequency conversion Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-15 18:55:50 UTC (rev 2562) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-15 18:57:21 UTC (rev 2563) @@ -26,9 +26,10 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -import tdates +from timeseries import tdates +from timeseries import tcore reload(tdates) -from tdates import date_array_fromlist, Date, DateArray, mxDFromString +from timeseries.tdates import date_array_fromlist, Date, DateArray, mxDFromString class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -103,7 +104,407 @@ odates = date_array_fromlist(dobj) assert_equal(dates,odates) + def test_consistent_value(self): + "Tests that values don't get mutated when constructing dates from a value" + freqs = [x for x in list(tcore.fmtfreq_dict) if x != 'U'] + for f in freqs: + today = tdates.thisday(f) + assert(tdates.Date(freq=f, value=today.value) == today) + +class test_freq_conversion(NumpyTestCase): + "Test frequency conversion of date objects" + + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + + def test_conv_annual(self): + "frequency conversion tests: from Annual Frequency" + + date_A = tdates.Date(freq='A', year=2007) + date_A_to_Q_before = tdates.Date(freq='Q', year=2007, quarter=1) + date_A_to_Q_after = tdates.Date(freq='Q', year=2007, quarter=4) + date_A_to_M_before = tdates.Date(freq='M', year=2007, month=1) + date_A_to_M_after = tdates.Date(freq='M', year=2007, month=12) + date_A_to_W_before = tdates.Date(freq='W', year=2007, month=1, day=1) + date_A_to_W_after = tdates.Date(freq='W', year=2007, month=12, day=31) + date_A_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) + date_A_to_B_after = tdates.Date(freq='B', year=2007, month=12, day=31) + date_A_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) + date_A_to_D_after = tdates.Date(freq='D', year=2007, month=12, day=31) + date_A_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_A_to_H_after = tdates.Date(freq='H', year=2007, month=12, day=31, hours=23) + date_A_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_A_to_T_after = tdates.Date(freq='T', year=2007, month=12, day=31, hours=23, minutes=59) + date_A_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_A_to_S_after = tdates.Date(freq='S', year=2007, month=12, day=31, hours=23, minutes=59, seconds=59) + + assert(date_A.asfreq('Q', "BEFORE") == date_A_to_Q_before) + assert(date_A.asfreq('Q', "AFTER") == date_A_to_Q_after) + assert(date_A.asfreq('M', "BEFORE") == date_A_to_M_before) + assert(date_A.asfreq('M', "AFTER") == date_A_to_M_after) + assert(date_A.asfreq('W', "BEFORE") == date_A_to_W_before) + assert(date_A.asfreq('W', "AFTER") == date_A_to_W_after) + assert(date_A.asfreq('B', "BEFORE") == date_A_to_B_before) + assert(date_A.asfreq('B', "AFTER") == date_A_to_B_after) + assert(date_A.asfreq('D', "BEFORE") == date_A_to_D_before) + assert(date_A.asfreq('D', "AFTER") == date_A_to_D_after) + assert(date_A.asfreq('H', "BEFORE") == date_A_to_H_before) + assert(date_A.asfreq('H', "AFTER") == date_A_to_H_after) + assert(date_A.asfreq('T', "BEFORE") == date_A_to_T_before) + assert(date_A.asfreq('T', "AFTER") == date_A_to_T_after) + assert(date_A.asfreq('S', "BEFORE") == date_A_to_S_before) + assert(date_A.asfreq('S', "AFTER") == date_A_to_S_after) + + + def test_conv_quarterly(self): + "frequency conversion tests: from Quarterly Frequency" + + date_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_Q_end_of_year = tdates.Date(freq='Q', year=2007, quarter=4) + date_Q_to_A = tdates.Date(freq='A', year=2007) + date_Q_to_M_before = tdates.Date(freq='M', year=2007, month=1) + date_Q_to_M_after = tdates.Date(freq='M', year=2007, month=3) + date_Q_to_W_before = tdates.Date(freq='W', year=2007, month=1, day=1) + date_Q_to_W_after = tdates.Date(freq='W', year=2007, month=3, day=31) + date_Q_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) + date_Q_to_B_after = tdates.Date(freq='B', year=2007, month=3, day=30) + date_Q_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) + date_Q_to_D_after = tdates.Date(freq='D', year=2007, month=3, day=31) + date_Q_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_Q_to_H_after = tdates.Date(freq='H', year=2007, month=3, day=31, hours=23) + date_Q_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_Q_to_T_after = tdates.Date(freq='T', year=2007, month=3, day=31, hours=23, minutes=59) + date_Q_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_Q_to_S_after = tdates.Date(freq='S', year=2007, month=3, day=31, hours=23, minutes=59, seconds=59) + + assert(date_Q.asfreq('A') == date_Q_to_A) + assert(date_Q_end_of_year.asfreq('A') == date_Q_to_A) + + assert(date_Q.asfreq('M', "BEFORE") == date_Q_to_M_before) + assert(date_Q.asfreq('M', "AFTER") == date_Q_to_M_after) + assert(date_Q.asfreq('W', "BEFORE") == date_Q_to_W_before) + assert(date_Q.asfreq('W', "AFTER") == date_Q_to_W_after) + assert(date_Q.asfreq('B', "BEFORE") == date_Q_to_B_before) + assert(date_Q.asfreq('B', "AFTER") == date_Q_to_B_after) + assert(date_Q.asfreq('D', "BEFORE") == date_Q_to_D_before) + assert(date_Q.asfreq('D', "AFTER") == date_Q_to_D_after) + assert(date_Q.asfreq('H', "BEFORE") == date_Q_to_H_before) + assert(date_Q.asfreq('H', "AFTER") == date_Q_to_H_after) + assert(date_Q.asfreq('T', "BEFORE") == date_Q_to_T_before) + assert(date_Q.asfreq('T', "AFTER") == date_Q_to_T_after) + assert(date_Q.asfreq('S', "BEFORE") == date_Q_to_S_before) + assert(date_Q.asfreq('S', "AFTER") == date_Q_to_S_after) + + + def test_conv_monthly(self): + "frequency conversion tests: from Monthly Frequency" + + date_M = tdates.Date(freq='M', year=2007, month=1) + date_M_end_of_year = tdates.Date(freq='M', year=2007, month=12) + date_M_end_of_quarter = tdates.Date(freq='M', year=2007, month=3) + date_M_to_A = tdates.Date(freq='A', year=2007) + date_M_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_M_to_W_before = tdates.Date(freq='W', year=2007, month=1, day=1) + date_M_to_W_after = tdates.Date(freq='W', year=2007, month=1, day=31) + date_M_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) + date_M_to_B_after = tdates.Date(freq='B', year=2007, month=1, day=31) + date_M_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) + date_M_to_D_after = tdates.Date(freq='D', year=2007, month=1, day=31) + date_M_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_M_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=31, hours=23) + date_M_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_M_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=31, hours=23, minutes=59) + date_M_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_M_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=31, hours=23, minutes=59, seconds=59) + + assert(date_M.asfreq('A') == date_M_to_A) + assert(date_M_end_of_year.asfreq('A') == date_M_to_A) + assert(date_M.asfreq('Q') == date_M_to_Q) + assert(date_M_end_of_quarter.asfreq('Q') == date_M_to_Q) + + assert(date_M.asfreq('W', "BEFORE") == date_M_to_W_before) + assert(date_M.asfreq('W', "AFTER") == date_M_to_W_after) + assert(date_M.asfreq('B', "BEFORE") == date_M_to_B_before) + assert(date_M.asfreq('B', "AFTER") == date_M_to_B_after) + assert(date_M.asfreq('D', "BEFORE") == date_M_to_D_before) + assert(date_M.asfreq('D', "AFTER") == date_M_to_D_after) + assert(date_M.asfreq('H', "BEFORE") == date_M_to_H_before) + assert(date_M.asfreq('H', "AFTER") == date_M_to_H_after) + assert(date_M.asfreq('T', "BEFORE") == date_M_to_T_before) + assert(date_M.asfreq('T', "AFTER") == date_M_to_T_after) + assert(date_M.asfreq('S', "BEFORE") == date_M_to_S_before) + assert(date_M.asfreq('S', "AFTER") == date_M_to_S_after) + + + def test_conv_weekly(self): + "frequency conversion tests: from Weekly Frequency" + + date_W = tdates.Date(freq='W', year=2007, month=1, day=1) + date_W_end_of_year = tdates.Date(freq='W', year=2007, month=12, day=31) + date_W_end_of_quarter = tdates.Date(freq='W', year=2007, month=3, day=31) + date_W_end_of_month = tdates.Date(freq='W', year=2007, month=1, day=31) + date_W_to_A = tdates.Date(freq='A', year=2007) + date_W_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_W_to_M = tdates.Date(freq='M', year=2007, month=1) + + if tdates.Date(freq='D', year=2007, month=12, day=31).day_of_week() == 6: + date_W_to_A_end_of_year = tdates.Date(freq='A', year=2007) + else: + date_W_to_A_end_of_year = tdates.Date(freq='A', year=2008) + + if tdates.Date(freq='D', year=2007, month=3, day=31).day_of_week() == 6: + date_W_to_Q_end_of_quarter = tdates.Date(freq='Q', year=2007, quarter=1) + else: + date_W_to_Q_end_of_quarter = tdates.Date(freq='Q', year=2007, quarter=2) + + if tdates.Date(freq='D', year=2007, month=1, day=31).day_of_week() == 6: + date_W_to_M_end_of_month = tdates.Date(freq='M', year=2007, month=1) + else: + date_W_to_M_end_of_month = tdates.Date(freq='M', year=2007, month=2) + + date_W_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) + date_W_to_B_after = tdates.Date(freq='B', year=2007, month=1, day=5) + date_W_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) + date_W_to_D_after = tdates.Date(freq='D', year=2007, month=1, day=7) + date_W_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_W_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=7, hours=23) + date_W_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_W_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=7, hours=23, minutes=59) + date_W_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_W_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=7, hours=23, minutes=59, seconds=59) + + assert(date_W.asfreq('A') == date_W_to_A) + assert(date_W_end_of_year.asfreq('A') == date_W_to_A_end_of_year) + assert(date_W.asfreq('Q') == date_W_to_Q) + assert(date_W_end_of_quarter.asfreq('Q') == date_W_to_Q_end_of_quarter) + assert(date_W.asfreq('M') == date_W_to_M) + assert(date_W_end_of_month.asfreq('M') == date_W_to_M_end_of_month) + + assert(date_W.asfreq('B', "BEFORE") == date_W_to_B_before) + assert(date_W.asfreq('B', "AFTER") == date_W_to_B_after) + assert(date_W.asfreq('D', "BEFORE") == date_W_to_D_before) + assert(date_W.asfreq('D', "AFTER") == date_W_to_D_after) + assert(date_W.asfreq('H', "BEFORE") == date_W_to_H_before) + assert(date_W.asfreq('H', "AFTER") == date_W_to_H_after) + assert(date_W.asfreq('T', "BEFORE") == date_W_to_T_before) + assert(date_W.asfreq('T', "AFTER") == date_W_to_T_after) + assert(date_W.asfreq('S', "BEFORE") == date_W_to_S_before) + assert(date_W.asfreq('S', "AFTER") == date_W_to_S_after) + + def test_conv_business(self): + "frequency conversion tests: from Business Frequency" + + date_B = tdates.Date(freq='B', year=2007, month=1, day=1) + date_B_end_of_year = tdates.Date(freq='B', year=2007, month=12, day=31) + date_B_end_of_quarter = tdates.Date(freq='B', year=2007, month=3, day=30) + date_B_end_of_month = tdates.Date(freq='B', year=2007, month=1, day=31) + date_B_end_of_week = tdates.Date(freq='B', year=2007, month=1, day=5) + + date_B_to_A = tdates.Date(freq='A', year=2007) + date_B_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_B_to_M = tdates.Date(freq='M', year=2007, month=1) + date_B_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) + date_B_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) + date_B_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_B_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) + date_B_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_B_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) + date_B_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_B_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) + + assert(date_B.asfreq('A') == date_B_to_A) + assert(date_B_end_of_year.asfreq('A') == date_B_to_A) + assert(date_B.asfreq('Q') == date_B_to_Q) + assert(date_B_end_of_quarter.asfreq('Q') == date_B_to_Q) + assert(date_B.asfreq('M') == date_B_to_M) + assert(date_B_end_of_month.asfreq('M') == date_B_to_M) + assert(date_B.asfreq('W') == date_B_to_W) + assert(date_B_end_of_week.asfreq('W') == date_B_to_W) + + assert(date_B.asfreq('D') == date_B_to_D) + + assert(date_B.asfreq('H', "BEFORE") == date_B_to_H_before) + assert(date_B.asfreq('H', "AFTER") == date_B_to_H_after) + assert(date_B.asfreq('T', "BEFORE") == date_B_to_T_before) + assert(date_B.asfreq('T', "AFTER") == date_B_to_T_after) + assert(date_B.asfreq('S', "BEFORE") == date_B_to_S_before) + assert(date_B.asfreq('S', "AFTER") == date_B_to_S_after) + + def test_conv_daily(self): + "frequency conversion tests: from Business Frequency" + + date_D = tdates.Date(freq='D', year=2007, month=1, day=1) + date_D_end_of_year = tdates.Date(freq='D', year=2007, month=12, day=31) + date_D_end_of_quarter = tdates.Date(freq='D', year=2007, month=3, day=31) + date_D_end_of_month = tdates.Date(freq='D', year=2007, month=1, day=31) + date_D_end_of_week = tdates.Date(freq='D', year=2007, month=1, day=7) + + date_D_friday = tdates.Date(freq='D', year=2007, month=1, day=5) + date_D_saturday = tdates.Date(freq='D', year=2007, month=1, day=6) + date_D_sunday = tdates.Date(freq='D', year=2007, month=1, day=7) + date_D_monday = tdates.Date(freq='D', year=2007, month=1, day=8) + + date_B_friday = tdates.Date(freq='B', year=2007, month=1, day=5) + date_B_monday = tdates.Date(freq='B', year=2007, month=1, day=8) + + date_D_to_A = tdates.Date(freq='A', year=2007) + date_D_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_D_to_M = tdates.Date(freq='M', year=2007, month=1) + date_D_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) + + date_D_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_D_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) + date_D_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_D_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) + date_D_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_D_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) + + assert(date_D.asfreq('A') == date_D_to_A) + assert(date_D_end_of_year.asfreq('A') == date_D_to_A) + assert(date_D.asfreq('Q') == date_D_to_Q) + assert(date_D_end_of_quarter.asfreq('Q') == date_D_to_Q) + assert(date_D.asfreq('M') == date_D_to_M) + assert(date_D_end_of_month.asfreq('M') == date_D_to_M) + assert(date_D.asfreq('W') == date_D_to_W) + assert(date_D_end_of_week.asfreq('W') == date_D_to_W) + + assert(date_D_friday.asfreq('B') == date_B_friday) + assert(date_D_saturday.asfreq('B', "BEFORE") == date_B_friday) + assert(date_D_saturday.asfreq('B', "AFTER") == date_B_monday) + assert(date_D_sunday.asfreq('B', "BEFORE") == date_B_friday) + assert(date_D_sunday.asfreq('B', "AFTER") == date_B_monday) + + assert(date_D.asfreq('H', "BEFORE") == date_D_to_H_before) + assert(date_D.asfreq('H', "AFTER") == date_D_to_H_after) + assert(date_D.asfreq('T', "BEFORE") == date_D_to_T_before) + assert(date_D.asfreq('T', "AFTER") == date_D_to_T_after) + assert(date_D.asfreq('S', "BEFORE") == date_D_to_S_before) + assert(date_D.asfreq('S', "AFTER") == date_D_to_S_after) + + def test_conv_hourly(self): + "frequency conversion tests: from Hourly Frequency" + + date_H = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_H_end_of_year = tdates.Date(freq='H', year=2007, month=12, day=31, hours=23) + date_H_end_of_quarter = tdates.Date(freq='H', year=2007, month=3, day=31, hours=23) + date_H_end_of_month = tdates.Date(freq='H', year=2007, month=1, day=31, hours=23) + date_H_end_of_week = tdates.Date(freq='H', year=2007, month=1, day=7, hours=23) + date_H_end_of_day = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) + date_H_end_of_bus = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) + + date_H_to_A = tdates.Date(freq='A', year=2007) + date_H_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_H_to_M = tdates.Date(freq='M', year=2007, month=1) + date_H_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) + date_H_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) + date_H_to_B = tdates.Date(freq='B', year=2007, month=1, day=1) + + date_H_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_H_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=59) + date_H_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_H_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=59, seconds=59) + + assert(date_H.asfreq('A') == date_H_to_A) + assert(date_H_end_of_year.asfreq('A') == date_H_to_A) + assert(date_H.asfreq('Q') == date_H_to_Q) + assert(date_H_end_of_quarter.asfreq('Q') == date_H_to_Q) + assert(date_H.asfreq('M') == date_H_to_M) + assert(date_H_end_of_month.asfreq('M') == date_H_to_M) + assert(date_H.asfreq('W') == date_H_to_W) + assert(date_H_end_of_week.asfreq('W') == date_H_to_W) + assert(date_H.asfreq('D') == date_H_to_D) + assert(date_H_end_of_day.asfreq('D') == date_H_to_D) + assert(date_H.asfreq('B') == date_H_to_B) + assert(date_H_end_of_bus.asfreq('B') == date_H_to_B) + + assert(date_H.asfreq('T', "BEFORE") == date_H_to_T_before) + assert(date_H.asfreq('T', "AFTER") == date_H_to_T_after) + assert(date_H.asfreq('S', "BEFORE") == date_H_to_S_before) + assert(date_H.asfreq('S', "AFTER") == date_H_to_S_after) + + def test_conv_minutely(self): + "frequency conversion tests: from Minutely Frequency" + + date_T = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_T_end_of_year = tdates.Date(freq='T', year=2007, month=12, day=31, hours=23, minutes=59) + date_T_end_of_quarter = tdates.Date(freq='T', year=2007, month=3, day=31, hours=23, minutes=59) + date_T_end_of_month = tdates.Date(freq='T', year=2007, month=1, day=31, hours=23, minutes=59) + date_T_end_of_week = tdates.Date(freq='T', year=2007, month=1, day=7, hours=23, minutes=59) + date_T_end_of_day = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) + date_T_end_of_bus = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) + date_T_end_of_hour = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=59) + + date_T_to_A = tdates.Date(freq='A', year=2007) + date_T_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_T_to_M = tdates.Date(freq='M', year=2007, month=1) + date_T_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) + date_T_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) + date_T_to_B = tdates.Date(freq='B', year=2007, month=1, day=1) + date_T_to_H = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + + date_T_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_T_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=59) + + assert(date_T.asfreq('A') == date_T_to_A) + assert(date_T_end_of_year.asfreq('A') == date_T_to_A) + assert(date_T.asfreq('Q') == date_T_to_Q) + assert(date_T_end_of_quarter.asfreq('Q') == date_T_to_Q) + assert(date_T.asfreq('M') == date_T_to_M) + assert(date_T_end_of_month.asfreq('M') == date_T_to_M) + assert(date_T.asfreq('W') == date_T_to_W) + assert(date_T_end_of_week.asfreq('W') == date_T_to_W) + assert(date_T.asfreq('D') == date_T_to_D) + assert(date_T_end_of_day.asfreq('D') == date_T_to_D) + assert(date_T.asfreq('B') == date_T_to_B) + assert(date_T_end_of_bus.asfreq('B') == date_T_to_B) + assert(date_T.asfreq('H') == date_T_to_H) + assert(date_T_end_of_hour.asfreq('H') == date_T_to_H) + + assert(date_T.asfreq('S', "BEFORE") == date_T_to_S_before) + assert(date_T.asfreq('S', "AFTER") == date_T_to_S_after) + + + def test_conv_secondly(self): + "frequency conversion tests: from Secondly Frequency" + + date_S = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) + date_S_end_of_year = tdates.Date(freq='S', year=2007, month=12, day=31, hours=23, minutes=59, seconds=59) + date_S_end_of_quarter = tdates.Date(freq='S', year=2007, month=3, day=31, hours=23, minutes=59, seconds=59) + date_S_end_of_month = tdates.Date(freq='S', year=2007, month=1, day=31, hours=23, minutes=59, seconds=59) + date_S_end_of_week = tdates.Date(freq='S', year=2007, month=1, day=7, hours=23, minutes=59, seconds=59) + date_S_end_of_day = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) + date_S_end_of_bus = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) + date_S_end_of_hour = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=59, seconds=59) + date_S_end_of_minute = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=59) + + date_S_to_A = tdates.Date(freq='A', year=2007) + date_S_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) + date_S_to_M = tdates.Date(freq='M', year=2007, month=1) + date_S_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) + date_S_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) + date_S_to_B = tdates.Date(freq='B', year=2007, month=1, day=1) + date_S_to_H = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_S_to_T = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + + assert(date_S.asfreq('A') == date_S_to_A) + assert(date_S_end_of_year.asfreq('A') == date_S_to_A) + assert(date_S.asfreq('Q') == date_S_to_Q) + assert(date_S_end_of_quarter.asfreq('Q') == date_S_to_Q) + assert(date_S.asfreq('M') == date_S_to_M) + assert(date_S_end_of_month.asfreq('M') == date_S_to_M) + assert(date_S.asfreq('W') == date_S_to_W) + assert(date_S_end_of_week.asfreq('W') == date_S_to_W) + assert(date_S.asfreq('D') == date_S_to_D) + assert(date_S_end_of_day.asfreq('D') == date_S_to_D) + assert(date_S.asfreq('B') == date_S_to_B) + assert(date_S_end_of_bus.asfreq('B') == date_S_to_B) + assert(date_S.asfreq('H') == date_S_to_H) + assert(date_S_end_of_hour.asfreq('H') == date_S_to_H) + assert(date_S.asfreq('T') == date_S_to_T) + assert(date_S_end_of_minute.asfreq('T') == date_S_to_T) + + class test_methods(NumpyTestCase): "Base test class for MaskedArrays." @@ -137,7 +538,10 @@ 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]) + + + ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": From scipy-svn at scipy.org Mon Jan 15 14:01:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 13:01:16 -0600 (CST) Subject: [Scipy-svn] r2564 - trunk/Lib/sandbox/timeseries Message-ID: <20070115190116.06D2C39C07A@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 13:01:13 -0600 (Mon, 15 Jan 2007) New Revision: 2564 Modified: trunk/Lib/sandbox/timeseries/readme.txt Log: Modified: trunk/Lib/sandbox/timeseries/readme.txt =================================================================== --- trunk/Lib/sandbox/timeseries/readme.txt 2007-01-15 18:57:21 UTC (rev 2563) +++ trunk/Lib/sandbox/timeseries/readme.txt 2007-01-15 19:01:13 UTC (rev 2564) @@ -5,6 +5,7 @@ 2. Only tested with numpy 1.0.1 3. Only tested with Python 2.4.x 4. Only tested on Windows Platform +5. Requires maskedarray from the sandbox (not the standard masked array module with numpy) Instructions: From scipy-svn at scipy.org Mon Jan 15 14:11:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 13:11:16 -0600 (CST) Subject: [Scipy-svn] r2565 - trunk/Lib/linsolve/umfpack Message-ID: <20070115191116.405C639C07A@new.scipy.org> Author: wnbell Date: 2007-01-15 13:11:14 -0600 (Mon, 15 Jan 2007) New Revision: 2565 Modified: trunk/Lib/linsolve/umfpack/umfpack.py Log: Cast do_recipt to boolean Modified: trunk/Lib/linsolve/umfpack/umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-15 19:01:13 UTC (rev 2564) +++ trunk/Lib/linsolve/umfpack/umfpack.py 2007-01-15 19:11:14 UTC (rev 2565) @@ -674,7 +674,7 @@ U = sp.csc_matrix((Ux,Ui,Up),(min(n_row,n_col),n_col)) R = Rs - return (L,U,P,Q,R,do_recip) + return (L,U,P,Q,R,bool(do_recip)) else: #allocate additional storage for imaginary parts @@ -702,6 +702,6 @@ L = sp.csr_matrix((Lxz,Lj,Lp),(n_row,min(n_row,n_col))) U = sp.csc_matrix((Uxz,Ui,Up),(min(n_row,n_col),n_col)) R = Rs - - return (L,U,P,Q,R,do_recip) + return (L,U,P,Q,R,bool(do_recip)) + From scipy-svn at scipy.org Mon Jan 15 14:21:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 13:21:02 -0600 (CST) Subject: [Scipy-svn] r2566 - trunk/Lib/sandbox/timeseries Message-ID: <20070115192102.24E0F39C0BD@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 13:20:59 -0600 (Mon, 15 Jan 2007) New Revision: 2566 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: added functions for filling in masked values in a masked array (via interpolation, etc) Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-15 19:11:14 UTC (rev 2565) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-15 19:20:59 UTC (rev 2566) @@ -1,5 +1,6 @@ import numpy import maskedarray as MA +from scipy.interpolate import fitpack #####--------------------------------------------------------------------------- @@ -155,3 +156,92 @@ return flatten_sequence(args) +#####--------------------------------------------------------------------------- +#---- --- 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.""" + + assert(marr.ndim == 1) + + result = marr.copy() + + if marr.mask is MA.nomask or marr.size == 0: return result + + currGap = 0 + + if maxgap is not None: + + for i in range(1, result.size): + if result.mask[i]: + currGap += 1 + if currGap <= maxgap and not result.mask[i-1]: + result.data[i] = result.data[i-1] + result.mask[i] = False + elif currGap == maxgap + 1: + result.mask[i-maxgap:i] = True + else: + currGap = 0 + + else: + + for i in range(1, result.size): + if result.mask[i] and not result.mask[i-1]: + result.data[i] = result.data[i-1] + result.mask[i] = False + + return result + + +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' +""" + + kind = kind.lower() + + if kind == 'constant': return forward_fill(marr) + + if marr.ndim != 1: raise ValueError("array must be 1 dimensional!") + + if not hasattr(marr, 'mask') or marr.mask is MA.nomask: return marr.copy() + + unmaskedIndices = numpy.where((marr.mask == False))[0] + if unmaskedIndices.size < 2: return marr.copy() + + 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 = numpy.where(marr.mask)[0] + interpIndices = maskedIndices[(maskedIndices > first_unmasked) & (maskedIndices < last_unmasked)] + + result = marr.copy() + result[interpIndices] = fitpack.splev(interpIndices, tck).astype(marr.dtype) + return result From scipy-svn at scipy.org Mon Jan 15 15:17:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 14:17:41 -0600 (CST) Subject: [Scipy-svn] r2567 - trunk/Lib/sandbox/timeseries Message-ID: <20070115201741.F288239C0AC@new.scipy.org> Author: mattknox_ca Date: 2007-01-15 14:17:32 -0600 (Mon, 15 Jan 2007) New Revision: 2567 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: fixed bug with __new__ method of TimeSeries class not accepting a list for the data Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-15 19:20:59 UTC (rev 2566) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-15 20:17:32 UTC (rev 2567) @@ -220,7 +220,7 @@ # newdata = MaskedArray.__new__(cls, data=_data, mask=mask, **options) newdata = super(TimeSeries,cls).__new__(cls, _data, mask=mask, **options) - assert(_datadatescompat(data,newdates)) + assert(_datadatescompat(newdata.data,newdates)) return newdata #.................................. From scipy-svn at scipy.org Mon Jan 15 18:55:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 17:55:01 -0600 (CST) Subject: [Scipy-svn] r2568 - trunk/Lib/linsolve Message-ID: <20070115235501.D0A0939C041@new.scipy.org> Author: stefan Date: 2007-01-15 17:54:42 -0600 (Mon, 15 Jan 2007) New Revision: 2568 Modified: trunk/Lib/linsolve/linsolve.py Log: Fix typo. Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-01-15 20:17:32 UTC (rev 2567) +++ trunk/Lib/linsolve/linsolve.py 2007-01-15 23:54:42 UTC (rev 2568) @@ -99,7 +99,7 @@ A linear solver, for a sparse, square matrix A, using LU decomposition where L is a lower triangular matrix and U is an upper triagular matrix. - Returns a factored_lu object. (scipy.linsolve._superly.SciPyLUType) + Returns a factored_lu object. (scipy.linsolve._superlu.SciPyLUType) See scipy.linsolve._superlu.dgstrf for more info. """ From scipy-svn at scipy.org Mon Jan 15 23:38:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 22:38:19 -0600 (CST) Subject: [Scipy-svn] r2569 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070116043819.B891C39C00B@new.scipy.org> Author: pierregm Date: 2007-01-15 22:38:16 -0600 (Mon, 15 Jan 2007) New Revision: 2569 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/tests/test_core.py Log: cf changelog Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-15 23:54:42 UTC (rev 2568) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-16 04:38:16 UTC (rev 2569) @@ -1,61 +1,51 @@ -#2007-01-15 : MRecords -# : - Add the addfield method -#2007-01-14 : Mrecords -# : - Slices are now properly supported -# : - `filled` is now properly supported -#2007-01-12 : Mrecords -# : - Complete reorganization... -#2007-01-10 : Mrecords -# : - Defines a class of records that support masked arrays +#2007-01-15 : mrecords: Add the addfield method +# : core : Force the mask of a masked array `x` to be copied w/... +# ...masked_array(x,copy=True,mask=nomask,keep_mask=true) +#2007-01-14 : mrecords: Slices are now properly supported +# : mrecords: `filled` is now properly supported +#2007-01-12 : mrecords: Complete reorganization... +#2007-01-10 : mrecords: Defines a class of records that support masked arrays #2007-01-08 : Core: -# : - Force a reset of the class defaults after initialization -# : - Modified __array_finallize__ to allow objects w/ _data and _mask fields to be recognized as MA -#2007-01-04 : Core: -# : - Fixed a but in masked_all_like -#2007-01-02 : Extras -# : - Force apply_along_axis to output the proper fill_value -# : Core -# : - Can use dtypes for the definition of default_fill_value -#2006-12-30 : Core -# : - Cleaned up setitem/setslice w/ hard_mask=True -# : - Fixed masked_unary/binary_operations to work with subclasses of MaskedArray -#2006-12-22 : Core -# : - Optimized(?) default_/maximum_/minimum_fill_value -# : - Force __new__ to not return a MaskedArray, in order to ... -# : ... optimize __array_finalize__ -# : - Add the hard_mask flag to __new__ (*[False]*) -#2006-12-19 : Core -# : - Fixed a problem on _set_mask which prevented to set a mask to nomask -# : Extras -# : - Renamed compress2d to compress_rowcols -# : - Added dot -#2006-12-18 : Extras -# : - Added compress2d and mask_rowcols -#2006-12-13 : - moved 'average' to 'extras' -# : Core -# : - Fixed make_mask (forced filling to True) -# : - Fixed ndim -# : - Fixed error message in __new__ when wrong sizes -# : - Fixed the reshape function. -# : Extras -# : - masked_all: set default dtype to float_ -# : - _fromnxfunctions: make sure that list are recognized -# : - added notmasked_edges, notmasked_contiguous +# : core : Force a reset of the class defaults after initialization +# : core : Modified __array_finallize__ to allow objects w/ _data... +# ... _mask fields to be recognized as MA +#2007-01-04 : core : Fixed a but in masked_all_like +#2007-01-02 : extras : Force apply_along_axis to output the proper fill_value +# : core : Can use dtypes for the definition of default_fill_value +#2006-12-30 : core : Cleaned up setitem/setslice w/ hard_mask=True +# : core : Fixed masked_unary/binary_operations... +# ...to work with subclasses of MaskedArray +#2006-12-22 : core : Optimized(?) default_/maximum_/minimum_fill_value +# : core : Force __new__ to not return a MaskedArray, in order to ... +# : ... optimize __array_finalize__ +# : core : Add the hard_mask flag to __new__ (*[False]*) +#2006-12-19 : core : Fixed a problem on _set_mask which prevented to set a mask to nomask +# : extras : Renamed compress2d to compress_rowcols +# : extras : Added dot +#2006-12-18 : extras : Added compress2d and mask_rowcols +# : extras : moved 'average' to 'extras' +#2006-12-13 : core : Fixed make_mask (forced filling to True) +# : core : Fixed ndim +# : core : Fixed error message in __new__ when wrong sizes +# : core : Fixed the reshape function. +# : extras : masked_all: set default dtype to float_ +# : extras : _fromnxfunctions: make sure that list are recognized +# : extras : added notmasked_edges, notmasked_contiguous #2006-12-09 : - Code reorganization: define 2 modules, core and extras -#2006-11-25 : - Disable copy by default -# - Added keep_mask flag (to save mask when creating a ma from a ma) -# - Fixed functions: empty_like -# - Fixed methods: .any and .all -# - New functions: masked_all, masked_all_like -# - New methods: .squeeze -#2006-11-20 : - fixed make_mask -# - fixed nonzero method -#2006-11-16 : - fixed .T -#2006-11-12 : - add max, min as function (not only method...) -# - repr returns a name like masked_xxx, where xxx is the subclass -#2006-10-31 : - make sure that make_mask returns a pure ndarray. -#2006-10-30 : - When converted to a float, a masked singleton is transformed to nan -# instead of raising an exception. +#2006-11-25 : core : Disable copy by default +# core : Added keep_mask flag (to save mask when creating a ma from a ma) +# core : Fixed functions: empty_like +# core : Fixed methods: .any and .all +# core : New functions: masked_all, masked_all_like +# core : New methods: .squeeze +#2006-11-20 : core : fixed make_mask +# core : fixed nonzero method +#2006-11-16 : core : fixed .T +#2006-11-12 : core : add max, min as function (not only method...) +# core : repr returns a name like masked_xxx, where xxx is the subclass +#2006-10-31 : core : make sure that make_mask returns a pure ndarray. +#2006-10-30 : core : When converted to a float, a masked singleton is ... +# ...transformed to nan instead of raising an exception. #21: Use __get__ method in _arraymethods, _arithmethods, _compamethods #18: Updated put to match the definition of numpy 1.0, deleted putmask, changed resize #2: prevent an extra kword being sent to make_mask_none Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-01-15 23:54:42 UTC (rev 2568) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-16 04:38:16 UTC (rev 2569) @@ -831,7 +831,10 @@ (hasattr(data,"_mask") and hasattr(data,"_data")) : if keep_mask: if mask is nomask: - cls._defaultmask = data._mask + if copy: + cls._defaultmask = data._mask.copy() + else: + cls._defaultmask = data._mask else: cls._defaultmask = mask_or(data._mask, mask, copy=copy, small_mask=small_mask) @@ -870,7 +873,7 @@ # cls.__defaultmask = getmask(_data) # return _data.view(cls) # Define mask ................. - mask = make_mask(mask, small_mask=small_mask) + mask = make_mask(mask, copy=copy, small_mask=small_mask) #....Check shapes compatibility if mask is not nomask: (nd, nm) = (_data.size, mask.size) Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-01-15 23:54:42 UTC (rev 2568) +++ trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-01-16 04:38:16 UTC (rev 2569) @@ -323,6 +323,15 @@ y9 = x4.copy() assert_equal(y9._data, x4._data) assert_equal(y9._mask, x4._mask) + # + x = masked_array([1,2,3], mask=[0,1,0]) + # Copy is False by default + y = masked_array(x) + assert_equal(id(y._data), id(x._data)) + assert_equal(id(y._mask), id(x._mask)) + y = masked_array(x, copy=True) + assert_not_equal(id(y._data), id(x._data)) + assert_not_equal(id(y._mask), id(x._mask)) #........................ def check_testOddFeatures_1(self): @@ -1007,6 +1016,17 @@ xh[filled(xh<5,False)] = 2 assert_equal(xh._data, [[1,2],[2,5]]) assert_equal(xh._mask, [[1,0],[0,0]]) + # + "Another test of hardmask" + d = arange(5) + n = [0,0,0,1,1] + m = make_mask(n) + xh = array(d, mask = m, hard_mask=True) + xh[4:5] = 999 + assert(xh.mask is m) + xh[0:1] = 999 + + assert_equal(xh._data,[999,1,2,3,4]) #.............................................................................. #.............................................................................. From scipy-svn at scipy.org Mon Jan 15 23:43:12 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 22:43:12 -0600 (CST) Subject: [Scipy-svn] r2570 - in trunk/Lib/sandbox/timeseries: . tests Message-ID: <20070116044312.795A539C00B@new.scipy.org> Author: pierregm Date: 2007-01-15 22:43:06 -0600 (Mon, 15 Jan 2007) New Revision: 2570 Modified: trunk/Lib/sandbox/timeseries/ trunk/Lib/sandbox/timeseries/.project trunk/Lib/sandbox/timeseries/__init__.py trunk/Lib/sandbox/timeseries/tcore.py trunk/Lib/sandbox/timeseries/tdates.py trunk/Lib/sandbox/timeseries/tests/test_dates.py trunk/Lib/sandbox/timeseries/tmulti.py trunk/Lib/sandbox/timeseries/tseries.py Log: cosmetic fixes. cf changelog Property changes on: trunk/Lib/sandbox/timeseries ___________________________________________________________________ Name: svn:ignore - sandbox + sandbox quicktest.py build Modified: trunk/Lib/sandbox/timeseries/.project =================================================================== --- trunk/Lib/sandbox/timeseries/.project 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/.project 2007-01-16 04:43:06 UTC (rev 2570) @@ -1,6 +1,6 @@ - scipy_svn_timeseries + timeseries Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-01-16 04:43:06 UTC (rev 2570) @@ -0,0 +1,26 @@ +"""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$ +""" +__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 * + +__all__ = ['tdates', 'tseries','tmulti'] +__all__ += tdates.__all__ +__all__ += tseries.__all__ +__all__ += tmulti.__all__ \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-16 04:43:06 UTC (rev 2570) @@ -1,7 +1,22 @@ +""" +A collection of tools for timeseries + +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknow_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + import numpy -import maskedarray as MA +import numpy.core.numeric as numeric + from scipy.interpolate import fitpack +import maskedarray as MA +from maskedarray import masked, nomask, getmask #####--------------------------------------------------------------------------- #---- --- Generic functions --- @@ -125,9 +140,11 @@ } def freqToType(freq): + "Returns the Date dtype corresponding to the given frequency." return freq_type_mapping[fmtFreq(freq)] def isDateType(dtype): + "Returns True whether the argument is the dtype of a Date." #TODO: That looks messy. We should simplify that if len([x for x in freq_type_mapping.values() if x == dtype]) > 0: return True @@ -163,39 +180,36 @@ def forward_fill(marr, maxgap=None): """forward_fill(marr, maxgap=None) -forward fill masked values in a 1-d array when there are <= maxgap +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.""" - assert(marr.ndim == 1) + if numeric.ndim(marr) > 1: + raise ValueError,"The input array should be 1D only!" - result = marr.copy() + marr = MA.array(marr, copy=True) + if getmask(marr) is nomask or marr.size == 0: + return marr - if marr.mask is MA.nomask or marr.size == 0: return result - currGap = 0 if maxgap is not None: - - for i in range(1, result.size): - if result.mask[i]: + for i in range(1, marr.size): + if marr._mask[i]: currGap += 1 - if currGap <= maxgap and not result.mask[i-1]: - result.data[i] = result.data[i-1] - result.mask[i] = False + if currGap <= maxgap and not marr._mask[i-1]: + marr._data[i] = marr._data[i-1] + marr._mask[i] = False elif currGap == maxgap + 1: - result.mask[i-maxgap:i] = True + marr._mask[i-maxgap:i] = True else: - currGap = 0 - + currGap = 0 else: - - for i in range(1, result.size): - if result.mask[i] and not result.mask[i-1]: - result.data[i] = result.data[i-1] - result.mask[i] = False - - return result + 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): @@ -204,7 +218,6 @@ 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] @@ -214,18 +227,20 @@ 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) - - if marr.ndim != 1: raise ValueError("array must be 1 dimensional!") - - if not hasattr(marr, 'mask') or marr.mask is MA.nomask: return marr.copy() - - unmaskedIndices = numpy.where((marr.mask == False))[0] - if unmaskedIndices.size < 2: return marr.copy() - + if kind == 'constant': + return forward_fill(marr) try: k = {'linear' : 1, 'cubic' : 3, @@ -239,9 +254,8 @@ tck = fitpack.splrep(unmaskedIndices, vals, k=k) - maskedIndices = numpy.where(marr.mask)[0] - interpIndices = maskedIndices[(maskedIndices > first_unmasked) & (maskedIndices < last_unmasked)] - - result = marr.copy() - result[interpIndices] = fitpack.splev(interpIndices, tck).astype(marr.dtype) - return result + maskedIndices = marr._mask.nonzero()[0] + interpIndices = maskedIndices[(maskedIndices > first_unmasked) & \ + (maskedIndices < last_unmasked)] + marr[interpIndices] = fitpack.splev(interpIndices, tck).astype(marr.dtype) + return marr Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-16 04:43:06 UTC (rev 2570) @@ -1,9 +1,11 @@ """ -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu +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 - mattknow_ca_at_hotmail_dot_com :version: $Id$ """ -__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" __version__ = '1.0' __revision__ = "$Revision$" __date__ = '$Date$' @@ -35,6 +37,16 @@ daflog = logging.getLogger('darray_from') dalog = logging.getLogger('DateArray') + +__all__ = [ +'Date', 'DateArray','isDate','isDateArray', +'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', +'datearray','date_array', 'date_array_fromlist_', 'date_array_fromrange', +'day_of_week','dat_of_year','day','month','quarter','year','hour','minute','second', +'truncateDate','monthToQuarter','thisday','today','prevbusday','asfreq' + ] + + #####--------------------------------------------------------------------------- #---- --- Date Info --- #####--------------------------------------------------------------------------- @@ -282,7 +294,8 @@ elif self.freq == 'B': days = self.mxDate.absdate weeks = days // 7 - val = days - weeks*2 # (weeks*5) + (days - weeks*7) + val = days - weeks*2 + # (weeks*5) + (days - weeks*7) # Daily/undefined elif self.freq in ['D', 'U']: val = self.mxDate.absdate @@ -736,23 +749,7 @@ tostr = firststr self.__tostr = tostr return self.__tostr - # -# def asfreq_ini(self, freq=None): -# "Converts the dates to another frequency." -# # Note: As we define a new object, we don't need caching -# if freq is None: -# return self -# freq = corelib.fmtFreq(freq) -# if freq == self.freq: -# return self -# if self.isvalid(): -# new = numeric.arange(self.size, dtype=int_) -# new += self[0].asfreq(freq).value -# else: -# new = numpy.fromiter((d.asfreq(freq).value for d in self), -# dtype=float_) -# return DateArray(new, freq=freq) - + # 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 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-16 04:43:06 UTC (rev 2570) @@ -1,15 +1,14 @@ # pylint: disable-msg=W0611, W0612, W0511,R0201 -"""Tests suite for MaskedArray. -Adapted from the original test_ma by Pierre Gerard-Marchant +"""Tests suite for timeseries.tdates. -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu -:version: $Id: test_core.py 59 2006-12-22 23:58:11Z backtopop $ +:author: Pierre Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknow_ca_at_hotmail_dot_com +:version: $Id$ """ -__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" __version__ = '1.0' -__revision__ = "$Revision: 59 $" -__date__ = '$Date: 2006-12-22 18:58:11 -0500 (Fri, 22 Dec 2006) $' +__revision__ = "$Revision$" +__date__ = '$Date$' import types import datetime @@ -26,10 +25,10 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -from timeseries import tdates -from timeseries import tcore +import tdates +import tcore reload(tdates) -from timeseries.tdates import date_array_fromlist, Date, DateArray, mxDFromString +from tdates import date_array_fromlist, Date, DateArray, mxDFromString class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -121,388 +120,455 @@ def test_conv_annual(self): "frequency conversion tests: from Annual Frequency" - date_A = tdates.Date(freq='A', year=2007) - date_A_to_Q_before = tdates.Date(freq='Q', year=2007, quarter=1) - date_A_to_Q_after = tdates.Date(freq='Q', year=2007, quarter=4) - date_A_to_M_before = tdates.Date(freq='M', year=2007, month=1) - date_A_to_M_after = tdates.Date(freq='M', year=2007, month=12) - date_A_to_W_before = tdates.Date(freq='W', year=2007, month=1, day=1) - date_A_to_W_after = tdates.Date(freq='W', year=2007, month=12, day=31) - date_A_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) - date_A_to_B_after = tdates.Date(freq='B', year=2007, month=12, day=31) - date_A_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) - date_A_to_D_after = tdates.Date(freq='D', year=2007, month=12, day=31) - date_A_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_A_to_H_after = tdates.Date(freq='H', year=2007, month=12, day=31, hours=23) - date_A_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_A_to_T_after = tdates.Date(freq='T', year=2007, month=12, day=31, hours=23, minutes=59) - date_A_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_A_to_S_after = tdates.Date(freq='S', year=2007, month=12, day=31, hours=23, minutes=59, seconds=59) + date_A = Date(freq='A', year=2007) + date_A_to_Q_before = Date(freq='Q', year=2007, quarter=1) + date_A_to_Q_after = Date(freq='Q', year=2007, quarter=4) + date_A_to_M_before = Date(freq='M', year=2007, month=1) + date_A_to_M_after = Date(freq='M', year=2007, month=12) + date_A_to_W_before = Date(freq='W', year=2007, month=1, day=1) + date_A_to_W_after = Date(freq='W', year=2007, month=12, day=31) + date_A_to_B_before = Date(freq='B', year=2007, month=1, day=1) + date_A_to_B_after = Date(freq='B', year=2007, month=12, day=31) + date_A_to_D_before = Date(freq='D', year=2007, month=1, day=1) + date_A_to_D_after = Date(freq='D', year=2007, month=12, day=31) + date_A_to_H_before = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_A_to_H_after = Date(freq='H', year=2007, month=12, day=31, + hours=23) + date_A_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_A_to_T_after = Date(freq='T', year=2007, month=12, day=31, + hours=23, minutes=59) + date_A_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_A_to_S_after = Date(freq='S', year=2007, month=12, day=31, + hours=23, minutes=59, seconds=59) - assert(date_A.asfreq('Q', "BEFORE") == date_A_to_Q_before) - assert(date_A.asfreq('Q', "AFTER") == date_A_to_Q_after) - assert(date_A.asfreq('M', "BEFORE") == date_A_to_M_before) - assert(date_A.asfreq('M', "AFTER") == date_A_to_M_after) - assert(date_A.asfreq('W', "BEFORE") == date_A_to_W_before) - assert(date_A.asfreq('W', "AFTER") == date_A_to_W_after) - assert(date_A.asfreq('B', "BEFORE") == date_A_to_B_before) - assert(date_A.asfreq('B', "AFTER") == date_A_to_B_after) - assert(date_A.asfreq('D', "BEFORE") == date_A_to_D_before) - assert(date_A.asfreq('D', "AFTER") == date_A_to_D_after) - assert(date_A.asfreq('H', "BEFORE") == date_A_to_H_before) - assert(date_A.asfreq('H', "AFTER") == date_A_to_H_after) - assert(date_A.asfreq('T', "BEFORE") == date_A_to_T_before) - assert(date_A.asfreq('T', "AFTER") == date_A_to_T_after) - assert(date_A.asfreq('S', "BEFORE") == date_A_to_S_before) - assert(date_A.asfreq('S', "AFTER") == date_A_to_S_after) + assert_equal(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) + assert_equal(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) + assert_equal(date_A.asfreq('M', "BEFORE"), date_A_to_M_before) + assert_equal(date_A.asfreq('M', "AFTER"), date_A_to_M_after) + assert_equal(date_A.asfreq('W', "BEFORE"), date_A_to_W_before) + assert_equal(date_A.asfreq('W', "AFTER"), date_A_to_W_after) + assert_equal(date_A.asfreq('B', "BEFORE"), date_A_to_B_before) + assert_equal(date_A.asfreq('B', "AFTER"), date_A_to_B_after) + assert_equal(date_A.asfreq('D', "BEFORE"), date_A_to_D_before) + assert_equal(date_A.asfreq('D', "AFTER"), date_A_to_D_after) + assert_equal(date_A.asfreq('H', "BEFORE"), date_A_to_H_before) + assert_equal(date_A.asfreq('H', "AFTER"), date_A_to_H_after) + assert_equal(date_A.asfreq('T', "BEFORE"), date_A_to_T_before) + assert_equal(date_A.asfreq('T', "AFTER"), date_A_to_T_after) + assert_equal(date_A.asfreq('S', "BEFORE"), date_A_to_S_before) + assert_equal(date_A.asfreq('S', "AFTER"), date_A_to_S_after) def test_conv_quarterly(self): "frequency conversion tests: from Quarterly Frequency" - date_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_Q_end_of_year = tdates.Date(freq='Q', year=2007, quarter=4) - date_Q_to_A = tdates.Date(freq='A', year=2007) - date_Q_to_M_before = tdates.Date(freq='M', year=2007, month=1) - date_Q_to_M_after = tdates.Date(freq='M', year=2007, month=3) - date_Q_to_W_before = tdates.Date(freq='W', year=2007, month=1, day=1) - date_Q_to_W_after = tdates.Date(freq='W', year=2007, month=3, day=31) - date_Q_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) - date_Q_to_B_after = tdates.Date(freq='B', year=2007, month=3, day=30) - date_Q_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) - date_Q_to_D_after = tdates.Date(freq='D', year=2007, month=3, day=31) - date_Q_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_Q_to_H_after = tdates.Date(freq='H', year=2007, month=3, day=31, hours=23) - date_Q_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_Q_to_T_after = tdates.Date(freq='T', year=2007, month=3, day=31, hours=23, minutes=59) - date_Q_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_Q_to_S_after = tdates.Date(freq='S', year=2007, month=3, day=31, hours=23, minutes=59, seconds=59) + date_Q = Date(freq='Q', year=2007, quarter=1) + date_Q_end_of_year = Date(freq='Q', year=2007, quarter=4) + date_Q_to_A = Date(freq='A', year=2007) + date_Q_to_M_before = Date(freq='M', year=2007, month=1) + date_Q_to_M_after = Date(freq='M', year=2007, month=3) + date_Q_to_W_before = Date(freq='W', year=2007, month=1, day=1) + date_Q_to_W_after = Date(freq='W', year=2007, month=3, day=31) + date_Q_to_B_before = Date(freq='B', year=2007, month=1, day=1) + date_Q_to_B_after = Date(freq='B', year=2007, month=3, day=30) + date_Q_to_D_before = Date(freq='D', year=2007, month=1, day=1) + date_Q_to_D_after = Date(freq='D', year=2007, month=3, day=31) + date_Q_to_H_before = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_Q_to_H_after = Date(freq='H', year=2007, month=3, day=31, + hours=23) + date_Q_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_Q_to_T_after = Date(freq='T', year=2007, month=3, day=31, + hours=23, minutes=59) + date_Q_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_Q_to_S_after = Date(freq='S', year=2007, month=3, day=31, + hours=23, minutes=59, seconds=59) - assert(date_Q.asfreq('A') == date_Q_to_A) - assert(date_Q_end_of_year.asfreq('A') == date_Q_to_A) + assert_equal(date_Q.asfreq('A'), date_Q_to_A) + assert_equal(date_Q_end_of_year.asfreq('A'), date_Q_to_A) - assert(date_Q.asfreq('M', "BEFORE") == date_Q_to_M_before) - assert(date_Q.asfreq('M', "AFTER") == date_Q_to_M_after) - assert(date_Q.asfreq('W', "BEFORE") == date_Q_to_W_before) - assert(date_Q.asfreq('W', "AFTER") == date_Q_to_W_after) - assert(date_Q.asfreq('B', "BEFORE") == date_Q_to_B_before) - assert(date_Q.asfreq('B', "AFTER") == date_Q_to_B_after) - assert(date_Q.asfreq('D', "BEFORE") == date_Q_to_D_before) - assert(date_Q.asfreq('D', "AFTER") == date_Q_to_D_after) - assert(date_Q.asfreq('H', "BEFORE") == date_Q_to_H_before) - assert(date_Q.asfreq('H', "AFTER") == date_Q_to_H_after) - assert(date_Q.asfreq('T', "BEFORE") == date_Q_to_T_before) - assert(date_Q.asfreq('T', "AFTER") == date_Q_to_T_after) - assert(date_Q.asfreq('S', "BEFORE") == date_Q_to_S_before) - assert(date_Q.asfreq('S', "AFTER") == date_Q_to_S_after) + assert_equal(date_Q.asfreq('M', "BEFORE"), date_Q_to_M_before) + assert_equal(date_Q.asfreq('M', "AFTER"), date_Q_to_M_after) + assert_equal(date_Q.asfreq('W', "BEFORE"), date_Q_to_W_before) + assert_equal(date_Q.asfreq('W', "AFTER"), date_Q_to_W_after) + assert_equal(date_Q.asfreq('B', "BEFORE"), date_Q_to_B_before) + assert_equal(date_Q.asfreq('B', "AFTER"), date_Q_to_B_after) + assert_equal(date_Q.asfreq('D', "BEFORE"), date_Q_to_D_before) + assert_equal(date_Q.asfreq('D', "AFTER"), date_Q_to_D_after) + assert_equal(date_Q.asfreq('H', "BEFORE"), date_Q_to_H_before) + assert_equal(date_Q.asfreq('H', "AFTER"), date_Q_to_H_after) + assert_equal(date_Q.asfreq('T', "BEFORE"), date_Q_to_T_before) + assert_equal(date_Q.asfreq('T', "AFTER"), date_Q_to_T_after) + assert_equal(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before) + assert_equal(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after) def test_conv_monthly(self): "frequency conversion tests: from Monthly Frequency" - date_M = tdates.Date(freq='M', year=2007, month=1) - date_M_end_of_year = tdates.Date(freq='M', year=2007, month=12) - date_M_end_of_quarter = tdates.Date(freq='M', year=2007, month=3) - date_M_to_A = tdates.Date(freq='A', year=2007) - date_M_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_M_to_W_before = tdates.Date(freq='W', year=2007, month=1, day=1) - date_M_to_W_after = tdates.Date(freq='W', year=2007, month=1, day=31) - date_M_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) - date_M_to_B_after = tdates.Date(freq='B', year=2007, month=1, day=31) - date_M_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) - date_M_to_D_after = tdates.Date(freq='D', year=2007, month=1, day=31) - date_M_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_M_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=31, hours=23) - date_M_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_M_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=31, hours=23, minutes=59) - date_M_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_M_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=31, hours=23, minutes=59, seconds=59) + date_M = Date(freq='M', year=2007, month=1) + date_M_end_of_year = Date(freq='M', year=2007, month=12) + date_M_end_of_quarter = Date(freq='M', year=2007, month=3) + date_M_to_A = Date(freq='A', year=2007) + date_M_to_Q = Date(freq='Q', year=2007, quarter=1) + date_M_to_W_before = Date(freq='W', year=2007, month=1, day=1) + date_M_to_W_after = Date(freq='W', year=2007, month=1, day=31) + date_M_to_B_before = Date(freq='B', year=2007, month=1, day=1) + date_M_to_B_after = Date(freq='B', year=2007, month=1, day=31) + date_M_to_D_before = Date(freq='D', year=2007, month=1, day=1) + date_M_to_D_after = Date(freq='D', year=2007, month=1, day=31) + date_M_to_H_before = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_M_to_H_after = Date(freq='H', year=2007, month=1, day=31, + hours=23) + date_M_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_M_to_T_after = Date(freq='T', year=2007, month=1, day=31, + hours=23, minutes=59) + date_M_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_M_to_S_after = Date(freq='S', year=2007, month=1, day=31, + hours=23, minutes=59, seconds=59) - assert(date_M.asfreq('A') == date_M_to_A) - assert(date_M_end_of_year.asfreq('A') == date_M_to_A) - assert(date_M.asfreq('Q') == date_M_to_Q) - assert(date_M_end_of_quarter.asfreq('Q') == date_M_to_Q) + assert_equal(date_M.asfreq('A'), date_M_to_A) + assert_equal(date_M_end_of_year.asfreq('A'), date_M_to_A) + assert_equal(date_M.asfreq('Q'), date_M_to_Q) + assert_equal(date_M_end_of_quarter.asfreq('Q'), date_M_to_Q) - assert(date_M.asfreq('W', "BEFORE") == date_M_to_W_before) - assert(date_M.asfreq('W', "AFTER") == date_M_to_W_after) - assert(date_M.asfreq('B', "BEFORE") == date_M_to_B_before) - assert(date_M.asfreq('B', "AFTER") == date_M_to_B_after) - assert(date_M.asfreq('D', "BEFORE") == date_M_to_D_before) - assert(date_M.asfreq('D', "AFTER") == date_M_to_D_after) - assert(date_M.asfreq('H', "BEFORE") == date_M_to_H_before) - assert(date_M.asfreq('H', "AFTER") == date_M_to_H_after) - assert(date_M.asfreq('T', "BEFORE") == date_M_to_T_before) - assert(date_M.asfreq('T', "AFTER") == date_M_to_T_after) - assert(date_M.asfreq('S', "BEFORE") == date_M_to_S_before) - assert(date_M.asfreq('S', "AFTER") == date_M_to_S_after) + assert_equal(date_M.asfreq('W', "BEFORE"), date_M_to_W_before) + assert_equal(date_M.asfreq('W', "AFTER"), date_M_to_W_after) + assert_equal(date_M.asfreq('B', "BEFORE"), date_M_to_B_before) + assert_equal(date_M.asfreq('B', "AFTER"), date_M_to_B_after) + assert_equal(date_M.asfreq('D', "BEFORE"), date_M_to_D_before) + assert_equal(date_M.asfreq('D', "AFTER"), date_M_to_D_after) + assert_equal(date_M.asfreq('H', "BEFORE"), date_M_to_H_before) + assert_equal(date_M.asfreq('H', "AFTER"), date_M_to_H_after) + assert_equal(date_M.asfreq('T', "BEFORE"), date_M_to_T_before) + assert_equal(date_M.asfreq('T', "AFTER"), date_M_to_T_after) + assert_equal(date_M.asfreq('S', "BEFORE"), date_M_to_S_before) + assert_equal(date_M.asfreq('S', "AFTER"), date_M_to_S_after) def test_conv_weekly(self): "frequency conversion tests: from Weekly Frequency" - date_W = tdates.Date(freq='W', year=2007, month=1, day=1) - date_W_end_of_year = tdates.Date(freq='W', year=2007, month=12, day=31) - date_W_end_of_quarter = tdates.Date(freq='W', year=2007, month=3, day=31) - date_W_end_of_month = tdates.Date(freq='W', year=2007, month=1, day=31) - date_W_to_A = tdates.Date(freq='A', year=2007) - date_W_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_W_to_M = tdates.Date(freq='M', year=2007, month=1) + date_W = Date(freq='W', year=2007, month=1, day=1) + date_W_end_of_year = Date(freq='W', year=2007, month=12, day=31) + date_W_end_of_quarter = Date(freq='W', year=2007, month=3, day=31) + date_W_end_of_month = Date(freq='W', year=2007, month=1, day=31) + date_W_to_A = Date(freq='A', year=2007) + date_W_to_Q = Date(freq='Q', year=2007, quarter=1) + date_W_to_M = Date(freq='M', year=2007, month=1) - if tdates.Date(freq='D', year=2007, month=12, day=31).day_of_week() == 6: - date_W_to_A_end_of_year = tdates.Date(freq='A', year=2007) + if Date(freq='D', year=2007, month=12, day=31).day_of_week() == 6: + date_W_to_A_end_of_year = Date(freq='A', year=2007) else: - date_W_to_A_end_of_year = tdates.Date(freq='A', year=2008) + date_W_to_A_end_of_year = Date(freq='A', year=2008) - if tdates.Date(freq='D', year=2007, month=3, day=31).day_of_week() == 6: - date_W_to_Q_end_of_quarter = tdates.Date(freq='Q', year=2007, quarter=1) + if Date(freq='D', year=2007, month=3, day=31).day_of_week() == 6: + date_W_to_Q_end_of_quarter = Date(freq='Q', year=2007, quarter=1) else: - date_W_to_Q_end_of_quarter = tdates.Date(freq='Q', year=2007, quarter=2) + date_W_to_Q_end_of_quarter = Date(freq='Q', year=2007, quarter=2) - if tdates.Date(freq='D', year=2007, month=1, day=31).day_of_week() == 6: - date_W_to_M_end_of_month = tdates.Date(freq='M', year=2007, month=1) + if Date(freq='D', year=2007, month=1, day=31).day_of_week() == 6: + date_W_to_M_end_of_month = Date(freq='M', year=2007, month=1) else: - date_W_to_M_end_of_month = tdates.Date(freq='M', year=2007, month=2) + date_W_to_M_end_of_month = Date(freq='M', year=2007, month=2) - date_W_to_B_before = tdates.Date(freq='B', year=2007, month=1, day=1) - date_W_to_B_after = tdates.Date(freq='B', year=2007, month=1, day=5) - date_W_to_D_before = tdates.Date(freq='D', year=2007, month=1, day=1) - date_W_to_D_after = tdates.Date(freq='D', year=2007, month=1, day=7) - date_W_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_W_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=7, hours=23) - date_W_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_W_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=7, hours=23, minutes=59) - date_W_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_W_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=7, hours=23, minutes=59, seconds=59) + date_W_to_B_before = Date(freq='B', year=2007, month=1, day=1) + date_W_to_B_after = Date(freq='B', year=2007, month=1, day=5) + date_W_to_D_before = Date(freq='D', year=2007, month=1, day=1) + date_W_to_D_after = Date(freq='D', year=2007, month=1, day=7) + date_W_to_H_before = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_W_to_H_after = Date(freq='H', year=2007, month=1, day=7, + hours=23) + date_W_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_W_to_T_after = Date(freq='T', year=2007, month=1, day=7, + hours=23, minutes=59) + date_W_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_W_to_S_after = Date(freq='S', year=2007, month=1, day=7, + hours=23, minutes=59, seconds=59) - assert(date_W.asfreq('A') == date_W_to_A) - assert(date_W_end_of_year.asfreq('A') == date_W_to_A_end_of_year) - assert(date_W.asfreq('Q') == date_W_to_Q) - assert(date_W_end_of_quarter.asfreq('Q') == date_W_to_Q_end_of_quarter) - assert(date_W.asfreq('M') == date_W_to_M) - assert(date_W_end_of_month.asfreq('M') == date_W_to_M_end_of_month) + assert_equal(date_W.asfreq('A'), date_W_to_A) + assert_equal(date_W_end_of_year.asfreq('A'), date_W_to_A_end_of_year) + assert_equal(date_W.asfreq('Q'), date_W_to_Q) + assert_equal(date_W_end_of_quarter.asfreq('Q'), date_W_to_Q_end_of_quarter) + assert_equal(date_W.asfreq('M'), date_W_to_M) + assert_equal(date_W_end_of_month.asfreq('M'), date_W_to_M_end_of_month) - assert(date_W.asfreq('B', "BEFORE") == date_W_to_B_before) - assert(date_W.asfreq('B', "AFTER") == date_W_to_B_after) - assert(date_W.asfreq('D', "BEFORE") == date_W_to_D_before) - assert(date_W.asfreq('D', "AFTER") == date_W_to_D_after) - assert(date_W.asfreq('H', "BEFORE") == date_W_to_H_before) - assert(date_W.asfreq('H', "AFTER") == date_W_to_H_after) - assert(date_W.asfreq('T', "BEFORE") == date_W_to_T_before) - assert(date_W.asfreq('T', "AFTER") == date_W_to_T_after) - assert(date_W.asfreq('S', "BEFORE") == date_W_to_S_before) - assert(date_W.asfreq('S', "AFTER") == date_W_to_S_after) + assert_equal(date_W.asfreq('B', "BEFORE"), date_W_to_B_before) + assert_equal(date_W.asfreq('B', "AFTER"), date_W_to_B_after) + assert_equal(date_W.asfreq('D', "BEFORE"), date_W_to_D_before) + assert_equal(date_W.asfreq('D', "AFTER"), date_W_to_D_after) + assert_equal(date_W.asfreq('H', "BEFORE"), date_W_to_H_before) + assert_equal(date_W.asfreq('H', "AFTER"), date_W_to_H_after) + assert_equal(date_W.asfreq('T', "BEFORE"), date_W_to_T_before) + assert_equal(date_W.asfreq('T', "AFTER"), date_W_to_T_after) + assert_equal(date_W.asfreq('S', "BEFORE"), date_W_to_S_before) + assert_equal(date_W.asfreq('S', "AFTER"), date_W_to_S_after) def test_conv_business(self): "frequency conversion tests: from Business Frequency" - date_B = tdates.Date(freq='B', year=2007, month=1, day=1) - date_B_end_of_year = tdates.Date(freq='B', year=2007, month=12, day=31) - date_B_end_of_quarter = tdates.Date(freq='B', year=2007, month=3, day=30) - date_B_end_of_month = tdates.Date(freq='B', year=2007, month=1, day=31) - date_B_end_of_week = tdates.Date(freq='B', year=2007, month=1, day=5) + date_B = Date(freq='B', year=2007, month=1, day=1) + date_B_end_of_year = Date(freq='B', year=2007, month=12, day=31) + date_B_end_of_quarter = Date(freq='B', year=2007, month=3, day=30) + date_B_end_of_month = Date(freq='B', year=2007, month=1, day=31) + date_B_end_of_week = Date(freq='B', year=2007, month=1, day=5) - date_B_to_A = tdates.Date(freq='A', year=2007) - date_B_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_B_to_M = tdates.Date(freq='M', year=2007, month=1) - date_B_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) - date_B_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) - date_B_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_B_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) - date_B_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_B_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) - date_B_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_B_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) + date_B_to_A = Date(freq='A', year=2007) + date_B_to_Q = Date(freq='Q', year=2007, quarter=1) + date_B_to_M = Date(freq='M', year=2007, month=1) + date_B_to_W = Date(freq='W', year=2007, month=1, day=7) + date_B_to_D = Date(freq='D', year=2007, month=1, day=1) + date_B_to_H_before = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_B_to_H_after = Date(freq='H', year=2007, month=1, day=1, + hours=23) + date_B_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_B_to_T_after = Date(freq='T', year=2007, month=1, day=1, + hours=23, minutes=59) + date_B_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_B_to_S_after = Date(freq='S', year=2007, month=1, day=1, + hours=23, minutes=59, seconds=59) - assert(date_B.asfreq('A') == date_B_to_A) - assert(date_B_end_of_year.asfreq('A') == date_B_to_A) - assert(date_B.asfreq('Q') == date_B_to_Q) - assert(date_B_end_of_quarter.asfreq('Q') == date_B_to_Q) - assert(date_B.asfreq('M') == date_B_to_M) - assert(date_B_end_of_month.asfreq('M') == date_B_to_M) - assert(date_B.asfreq('W') == date_B_to_W) - assert(date_B_end_of_week.asfreq('W') == date_B_to_W) + assert_equal(date_B.asfreq('A'), date_B_to_A) + assert_equal(date_B_end_of_year.asfreq('A'), date_B_to_A) + assert_equal(date_B.asfreq('Q'), date_B_to_Q) + assert_equal(date_B_end_of_quarter.asfreq('Q'), date_B_to_Q) + assert_equal(date_B.asfreq('M'), date_B_to_M) + assert_equal(date_B_end_of_month.asfreq('M'), date_B_to_M) + assert_equal(date_B.asfreq('W'), date_B_to_W) + assert_equal(date_B_end_of_week.asfreq('W'), date_B_to_W) - assert(date_B.asfreq('D') == date_B_to_D) + assert_equal(date_B.asfreq('D'), date_B_to_D) - assert(date_B.asfreq('H', "BEFORE") == date_B_to_H_before) - assert(date_B.asfreq('H', "AFTER") == date_B_to_H_after) - assert(date_B.asfreq('T', "BEFORE") == date_B_to_T_before) - assert(date_B.asfreq('T', "AFTER") == date_B_to_T_after) - assert(date_B.asfreq('S', "BEFORE") == date_B_to_S_before) - assert(date_B.asfreq('S', "AFTER") == date_B_to_S_after) + assert_equal(date_B.asfreq('H', "BEFORE"), date_B_to_H_before) + assert_equal(date_B.asfreq('H', "AFTER"), date_B_to_H_after) + assert_equal(date_B.asfreq('T', "BEFORE"), date_B_to_T_before) + assert_equal(date_B.asfreq('T', "AFTER"), date_B_to_T_after) + assert_equal(date_B.asfreq('S', "BEFORE"), date_B_to_S_before) + assert_equal(date_B.asfreq('S', "AFTER"), date_B_to_S_after) def test_conv_daily(self): "frequency conversion tests: from Business Frequency" - date_D = tdates.Date(freq='D', year=2007, month=1, day=1) - date_D_end_of_year = tdates.Date(freq='D', year=2007, month=12, day=31) - date_D_end_of_quarter = tdates.Date(freq='D', year=2007, month=3, day=31) - date_D_end_of_month = tdates.Date(freq='D', year=2007, month=1, day=31) - date_D_end_of_week = tdates.Date(freq='D', year=2007, month=1, day=7) + date_D = Date(freq='D', year=2007, month=1, day=1) + date_D_end_of_year = Date(freq='D', year=2007, month=12, day=31) + date_D_end_of_quarter = Date(freq='D', year=2007, month=3, day=31) + date_D_end_of_month = Date(freq='D', year=2007, month=1, day=31) + date_D_end_of_week = Date(freq='D', year=2007, month=1, day=7) - date_D_friday = tdates.Date(freq='D', year=2007, month=1, day=5) - date_D_saturday = tdates.Date(freq='D', year=2007, month=1, day=6) - date_D_sunday = tdates.Date(freq='D', year=2007, month=1, day=7) - date_D_monday = tdates.Date(freq='D', year=2007, month=1, day=8) + date_D_friday = Date(freq='D', year=2007, month=1, day=5) + date_D_saturday = Date(freq='D', year=2007, month=1, day=6) + date_D_sunday = Date(freq='D', year=2007, month=1, day=7) + date_D_monday = Date(freq='D', year=2007, month=1, day=8) - date_B_friday = tdates.Date(freq='B', year=2007, month=1, day=5) - date_B_monday = tdates.Date(freq='B', year=2007, month=1, day=8) + date_B_friday = Date(freq='B', year=2007, month=1, day=5) + date_B_monday = Date(freq='B', year=2007, month=1, day=8) - date_D_to_A = tdates.Date(freq='A', year=2007) - date_D_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_D_to_M = tdates.Date(freq='M', year=2007, month=1) - date_D_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) + date_D_to_A = Date(freq='A', year=2007) + date_D_to_Q = Date(freq='Q', year=2007, quarter=1) + date_D_to_M = Date(freq='M', year=2007, month=1) + date_D_to_W = Date(freq='W', year=2007, month=1, day=7) - date_D_to_H_before = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_D_to_H_after = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) - date_D_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_D_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) - date_D_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_D_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) + date_D_to_H_before = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_D_to_H_after = Date(freq='H', year=2007, month=1, day=1, + hours=23) + date_D_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_D_to_T_after = Date(freq='T', year=2007, month=1, day=1, + hours=23, minutes=59) + date_D_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_D_to_S_after = Date(freq='S', year=2007, month=1, day=1, + hours=23, minutes=59, seconds=59) - assert(date_D.asfreq('A') == date_D_to_A) - assert(date_D_end_of_year.asfreq('A') == date_D_to_A) - assert(date_D.asfreq('Q') == date_D_to_Q) - assert(date_D_end_of_quarter.asfreq('Q') == date_D_to_Q) - assert(date_D.asfreq('M') == date_D_to_M) - assert(date_D_end_of_month.asfreq('M') == date_D_to_M) - assert(date_D.asfreq('W') == date_D_to_W) - assert(date_D_end_of_week.asfreq('W') == date_D_to_W) + assert_equal(date_D.asfreq('A'), date_D_to_A) + assert_equal(date_D_end_of_year.asfreq('A'), date_D_to_A) + assert_equal(date_D.asfreq('Q'), date_D_to_Q) + assert_equal(date_D_end_of_quarter.asfreq('Q'), date_D_to_Q) + assert_equal(date_D.asfreq('M'), date_D_to_M) + assert_equal(date_D_end_of_month.asfreq('M'), date_D_to_M) + assert_equal(date_D.asfreq('W'), date_D_to_W) + assert_equal(date_D_end_of_week.asfreq('W'), date_D_to_W) - assert(date_D_friday.asfreq('B') == date_B_friday) - assert(date_D_saturday.asfreq('B', "BEFORE") == date_B_friday) - assert(date_D_saturday.asfreq('B', "AFTER") == date_B_monday) - assert(date_D_sunday.asfreq('B', "BEFORE") == date_B_friday) - assert(date_D_sunday.asfreq('B', "AFTER") == date_B_monday) + assert_equal(date_D_friday.asfreq('B'), date_B_friday) + assert_equal(date_D_saturday.asfreq('B', "BEFORE"), date_B_friday) + assert_equal(date_D_saturday.asfreq('B', "AFTER"), date_B_monday) + assert_equal(date_D_sunday.asfreq('B', "BEFORE"), date_B_friday) + assert_equal(date_D_sunday.asfreq('B', "AFTER"), date_B_monday) - assert(date_D.asfreq('H', "BEFORE") == date_D_to_H_before) - assert(date_D.asfreq('H', "AFTER") == date_D_to_H_after) - assert(date_D.asfreq('T', "BEFORE") == date_D_to_T_before) - assert(date_D.asfreq('T', "AFTER") == date_D_to_T_after) - assert(date_D.asfreq('S', "BEFORE") == date_D_to_S_before) - assert(date_D.asfreq('S', "AFTER") == date_D_to_S_after) + assert_equal(date_D.asfreq('H', "BEFORE"), date_D_to_H_before) + assert_equal(date_D.asfreq('H', "AFTER"), date_D_to_H_after) + assert_equal(date_D.asfreq('T', "BEFORE"), date_D_to_T_before) + assert_equal(date_D.asfreq('T', "AFTER"), date_D_to_T_after) + assert_equal(date_D.asfreq('S', "BEFORE"), date_D_to_S_before) + assert_equal(date_D.asfreq('S', "AFTER"), date_D_to_S_after) def test_conv_hourly(self): "frequency conversion tests: from Hourly Frequency" - date_H = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_H_end_of_year = tdates.Date(freq='H', year=2007, month=12, day=31, hours=23) - date_H_end_of_quarter = tdates.Date(freq='H', year=2007, month=3, day=31, hours=23) - date_H_end_of_month = tdates.Date(freq='H', year=2007, month=1, day=31, hours=23) - date_H_end_of_week = tdates.Date(freq='H', year=2007, month=1, day=7, hours=23) - date_H_end_of_day = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) - date_H_end_of_bus = tdates.Date(freq='H', year=2007, month=1, day=1, hours=23) + date_H = Date(freq='H', year=2007, month=1, day=1, hours=0) + date_H_end_of_year = Date(freq='H', year=2007, month=12, day=31, + hours=23) + date_H_end_of_quarter = Date(freq='H', year=2007, month=3, day=31, + hours=23) + date_H_end_of_month = Date(freq='H', year=2007, month=1, day=31, + hours=23) + date_H_end_of_week = Date(freq='H', year=2007, month=1, day=7, + hours=23) + date_H_end_of_day = Date(freq='H', year=2007, month=1, day=1, + hours=23) + date_H_end_of_bus = Date(freq='H', year=2007, month=1, day=1, + hours=23) - date_H_to_A = tdates.Date(freq='A', year=2007) - date_H_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_H_to_M = tdates.Date(freq='M', year=2007, month=1) - date_H_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) - date_H_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) - date_H_to_B = tdates.Date(freq='B', year=2007, month=1, day=1) + date_H_to_A = Date(freq='A', year=2007) + date_H_to_Q = Date(freq='Q', year=2007, quarter=1) + date_H_to_M = Date(freq='M', year=2007, month=1) + date_H_to_W = Date(freq='W', year=2007, month=1, day=7) + date_H_to_D = Date(freq='D', year=2007, month=1, day=1) + date_H_to_B = Date(freq='B', year=2007, month=1, day=1) - date_H_to_T_before = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_H_to_T_after = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=59) - date_H_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_H_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=59, seconds=59) + date_H_to_T_before = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_H_to_T_after = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=59) + date_H_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_H_to_S_after = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=59, seconds=59) - assert(date_H.asfreq('A') == date_H_to_A) - assert(date_H_end_of_year.asfreq('A') == date_H_to_A) - assert(date_H.asfreq('Q') == date_H_to_Q) - assert(date_H_end_of_quarter.asfreq('Q') == date_H_to_Q) - assert(date_H.asfreq('M') == date_H_to_M) - assert(date_H_end_of_month.asfreq('M') == date_H_to_M) - assert(date_H.asfreq('W') == date_H_to_W) - assert(date_H_end_of_week.asfreq('W') == date_H_to_W) - assert(date_H.asfreq('D') == date_H_to_D) - assert(date_H_end_of_day.asfreq('D') == date_H_to_D) - assert(date_H.asfreq('B') == date_H_to_B) - assert(date_H_end_of_bus.asfreq('B') == date_H_to_B) + assert_equal(date_H.asfreq('A'), date_H_to_A) + assert_equal(date_H_end_of_year.asfreq('A'), date_H_to_A) + assert_equal(date_H.asfreq('Q'), date_H_to_Q) + assert_equal(date_H_end_of_quarter.asfreq('Q'), date_H_to_Q) + assert_equal(date_H.asfreq('M'), date_H_to_M) + assert_equal(date_H_end_of_month.asfreq('M'), date_H_to_M) + assert_equal(date_H.asfreq('W'), date_H_to_W) + assert_equal(date_H_end_of_week.asfreq('W'), date_H_to_W) + assert_equal(date_H.asfreq('D'), date_H_to_D) + assert_equal(date_H_end_of_day.asfreq('D'), date_H_to_D) + assert_equal(date_H.asfreq('B'), date_H_to_B) + assert_equal(date_H_end_of_bus.asfreq('B'), date_H_to_B) - assert(date_H.asfreq('T', "BEFORE") == date_H_to_T_before) - assert(date_H.asfreq('T', "AFTER") == date_H_to_T_after) - assert(date_H.asfreq('S', "BEFORE") == date_H_to_S_before) - assert(date_H.asfreq('S', "AFTER") == date_H_to_S_after) + assert_equal(date_H.asfreq('T', "BEFORE"), date_H_to_T_before) + assert_equal(date_H.asfreq('T', "AFTER"), date_H_to_T_after) + assert_equal(date_H.asfreq('S', "BEFORE"), date_H_to_S_before) + assert_equal(date_H.asfreq('S', "AFTER"), date_H_to_S_after) def test_conv_minutely(self): "frequency conversion tests: from Minutely Frequency" - date_T = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) - date_T_end_of_year = tdates.Date(freq='T', year=2007, month=12, day=31, hours=23, minutes=59) - date_T_end_of_quarter = tdates.Date(freq='T', year=2007, month=3, day=31, hours=23, minutes=59) - date_T_end_of_month = tdates.Date(freq='T', year=2007, month=1, day=31, hours=23, minutes=59) - date_T_end_of_week = tdates.Date(freq='T', year=2007, month=1, day=7, hours=23, minutes=59) - date_T_end_of_day = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) - date_T_end_of_bus = tdates.Date(freq='T', year=2007, month=1, day=1, hours=23, minutes=59) - date_T_end_of_hour = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=59) + date_T = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) + date_T_end_of_year = Date(freq='T', year=2007, month=12, day=31, + hours=23, minutes=59) + date_T_end_of_quarter = Date(freq='T', year=2007, month=3, day=31, + hours=23, minutes=59) + date_T_end_of_month = Date(freq='T', year=2007, month=1, day=31, + hours=23, minutes=59) + date_T_end_of_week = Date(freq='T', year=2007, month=1, day=7, + hours=23, minutes=59) + date_T_end_of_day = Date(freq='T', year=2007, month=1, day=1, + hours=23, minutes=59) + date_T_end_of_bus = Date(freq='T', year=2007, month=1, day=1, + hours=23, minutes=59) + date_T_end_of_hour = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=59) - date_T_to_A = tdates.Date(freq='A', year=2007) - date_T_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_T_to_M = tdates.Date(freq='M', year=2007, month=1) - date_T_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) - date_T_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) - date_T_to_B = tdates.Date(freq='B', year=2007, month=1, day=1) - date_T_to_H = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) + date_T_to_A = Date(freq='A', year=2007) + date_T_to_Q = Date(freq='Q', year=2007, quarter=1) + date_T_to_M = Date(freq='M', year=2007, month=1) + date_T_to_W = Date(freq='W', year=2007, month=1, day=7) + date_T_to_D = Date(freq='D', year=2007, month=1, day=1) + date_T_to_B = Date(freq='B', year=2007, month=1, day=1) + date_T_to_H = Date(freq='H', year=2007, month=1, day=1, hours=0) - date_T_to_S_before = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_T_to_S_after = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=59) + date_T_to_S_before = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_T_to_S_after = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=59) - assert(date_T.asfreq('A') == date_T_to_A) - assert(date_T_end_of_year.asfreq('A') == date_T_to_A) - assert(date_T.asfreq('Q') == date_T_to_Q) - assert(date_T_end_of_quarter.asfreq('Q') == date_T_to_Q) - assert(date_T.asfreq('M') == date_T_to_M) - assert(date_T_end_of_month.asfreq('M') == date_T_to_M) - assert(date_T.asfreq('W') == date_T_to_W) - assert(date_T_end_of_week.asfreq('W') == date_T_to_W) - assert(date_T.asfreq('D') == date_T_to_D) - assert(date_T_end_of_day.asfreq('D') == date_T_to_D) - assert(date_T.asfreq('B') == date_T_to_B) - assert(date_T_end_of_bus.asfreq('B') == date_T_to_B) - assert(date_T.asfreq('H') == date_T_to_H) - assert(date_T_end_of_hour.asfreq('H') == date_T_to_H) + assert_equal(date_T.asfreq('A'), date_T_to_A) + assert_equal(date_T_end_of_year.asfreq('A'), date_T_to_A) + assert_equal(date_T.asfreq('Q'), date_T_to_Q) + assert_equal(date_T_end_of_quarter.asfreq('Q'), date_T_to_Q) + assert_equal(date_T.asfreq('M'), date_T_to_M) + assert_equal(date_T_end_of_month.asfreq('M'), date_T_to_M) + assert_equal(date_T.asfreq('W'), date_T_to_W) + assert_equal(date_T_end_of_week.asfreq('W'), date_T_to_W) + assert_equal(date_T.asfreq('D'), date_T_to_D) + assert_equal(date_T_end_of_day.asfreq('D'), date_T_to_D) + assert_equal(date_T.asfreq('B'), date_T_to_B) + assert_equal(date_T_end_of_bus.asfreq('B'), date_T_to_B) + assert_equal(date_T.asfreq('H'), date_T_to_H) + assert_equal(date_T_end_of_hour.asfreq('H'), date_T_to_H) - assert(date_T.asfreq('S', "BEFORE") == date_T_to_S_before) - assert(date_T.asfreq('S', "AFTER") == date_T_to_S_after) + assert_equal(date_T.asfreq('S', "BEFORE"), date_T_to_S_before) + assert_equal(date_T.asfreq('S', "AFTER"), date_T_to_S_after) def test_conv_secondly(self): "frequency conversion tests: from Secondly Frequency" - date_S = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=0) - date_S_end_of_year = tdates.Date(freq='S', year=2007, month=12, day=31, hours=23, minutes=59, seconds=59) - date_S_end_of_quarter = tdates.Date(freq='S', year=2007, month=3, day=31, hours=23, minutes=59, seconds=59) - date_S_end_of_month = tdates.Date(freq='S', year=2007, month=1, day=31, hours=23, minutes=59, seconds=59) - date_S_end_of_week = tdates.Date(freq='S', year=2007, month=1, day=7, hours=23, minutes=59, seconds=59) - date_S_end_of_day = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) - date_S_end_of_bus = tdates.Date(freq='S', year=2007, month=1, day=1, hours=23, minutes=59, seconds=59) - date_S_end_of_hour = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=59, seconds=59) - date_S_end_of_minute = tdates.Date(freq='S', year=2007, month=1, day=1, hours=0, minutes=0, seconds=59) + date_S = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=0) + date_S_end_of_year = Date(freq='S', year=2007, month=12, day=31, + hours=23, minutes=59, seconds=59) + date_S_end_of_quarter = Date(freq='S', year=2007, month=3, day=31, + hours=23, minutes=59, seconds=59) + date_S_end_of_month = Date(freq='S', year=2007, month=1, day=31, + hours=23, minutes=59, seconds=59) + date_S_end_of_week = Date(freq='S', year=2007, month=1, day=7, + hours=23, minutes=59, seconds=59) + date_S_end_of_day = Date(freq='S', year=2007, month=1, day=1, + hours=23, minutes=59, seconds=59) + date_S_end_of_bus = Date(freq='S', year=2007, month=1, day=1, + hours=23, minutes=59, seconds=59) + date_S_end_of_hour = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=59, seconds=59) + date_S_end_of_minute = Date(freq='S', year=2007, month=1, day=1, + hours=0, minutes=0, seconds=59) - date_S_to_A = tdates.Date(freq='A', year=2007) - date_S_to_Q = tdates.Date(freq='Q', year=2007, quarter=1) - date_S_to_M = tdates.Date(freq='M', year=2007, month=1) - date_S_to_W = tdates.Date(freq='W', year=2007, month=1, day=7) - date_S_to_D = tdates.Date(freq='D', year=2007, month=1, day=1) - date_S_to_B = tdates.Date(freq='B', year=2007, month=1, day=1) - date_S_to_H = tdates.Date(freq='H', year=2007, month=1, day=1, hours=0) - date_S_to_T = tdates.Date(freq='T', year=2007, month=1, day=1, hours=0, minutes=0) + date_S_to_A = Date(freq='A', year=2007) + date_S_to_Q = Date(freq='Q', year=2007, quarter=1) + date_S_to_M = Date(freq='M', year=2007, month=1) + date_S_to_W = Date(freq='W', year=2007, month=1, day=7) + date_S_to_D = Date(freq='D', year=2007, month=1, day=1) + date_S_to_B = Date(freq='B', year=2007, month=1, day=1) + date_S_to_H = Date(freq='H', year=2007, month=1, day=1, + hours=0) + date_S_to_T = Date(freq='T', year=2007, month=1, day=1, + hours=0, minutes=0) - assert(date_S.asfreq('A') == date_S_to_A) - assert(date_S_end_of_year.asfreq('A') == date_S_to_A) - assert(date_S.asfreq('Q') == date_S_to_Q) - assert(date_S_end_of_quarter.asfreq('Q') == date_S_to_Q) - assert(date_S.asfreq('M') == date_S_to_M) - assert(date_S_end_of_month.asfreq('M') == date_S_to_M) - assert(date_S.asfreq('W') == date_S_to_W) - assert(date_S_end_of_week.asfreq('W') == date_S_to_W) - assert(date_S.asfreq('D') == date_S_to_D) - assert(date_S_end_of_day.asfreq('D') == date_S_to_D) - assert(date_S.asfreq('B') == date_S_to_B) - assert(date_S_end_of_bus.asfreq('B') == date_S_to_B) - assert(date_S.asfreq('H') == date_S_to_H) - assert(date_S_end_of_hour.asfreq('H') == date_S_to_H) - assert(date_S.asfreq('T') == date_S_to_T) - assert(date_S_end_of_minute.asfreq('T') == date_S_to_T) + assert_equal(date_S.asfreq('A'), date_S_to_A) + assert_equal(date_S_end_of_year.asfreq('A'), date_S_to_A) + assert_equal(date_S.asfreq('Q'), date_S_to_Q) + assert_equal(date_S_end_of_quarter.asfreq('Q'), date_S_to_Q) + assert_equal(date_S.asfreq('M'), date_S_to_M) + assert_equal(date_S_end_of_month.asfreq('M'), date_S_to_M) + assert_equal(date_S.asfreq('W'), date_S_to_W) + assert_equal(date_S_end_of_week.asfreq('W'), date_S_to_W) + assert_equal(date_S.asfreq('D'), date_S_to_D) + assert_equal(date_S_end_of_day.asfreq('D'), date_S_to_D) + assert_equal(date_S.asfreq('B'), date_S_to_B) + assert_equal(date_S_end_of_bus.asfreq('B'), date_S_to_B) + assert_equal(date_S.asfreq('H'), date_S_to_H) + assert_equal(date_S_end_of_hour.asfreq('H'), date_S_to_H) + assert_equal(date_S.asfreq('T'), date_S_to_T) + assert_equal(date_S_end_of_minute.asfreq('T'), date_S_to_T) class test_methods(NumpyTestCase): Property changes on: trunk/Lib/sandbox/timeseries/tests/test_dates.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Modified: trunk/Lib/sandbox/timeseries/tmulti.py =================================================================== --- trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-16 04:43:06 UTC (rev 2570) @@ -18,6 +18,7 @@ from numpy import bool_, complex_, float_, int_, str_, object_ import numpy.core.fromnumeric as fromnumeric import numpy.core.numeric as numeric +from numpy.core.numeric import ndarray import numpy.core.numerictypes as ntypes import numpy.core.umath as umath from numpy.core.defchararray import chararray @@ -35,7 +36,7 @@ make_mask_none, mask_or, masked_array, filled import maskedarray.mrecords as MR -reload(MR) +#reload(MR) from maskedarray.mrecords import _checknames, _guessvartypes, openfile,\ MaskedRecords from maskedarray.mrecords import fromrecords as mrecfromrecords @@ -43,7 +44,7 @@ from tseries import TimeSeries, time_series, _getdatalength from tdates import Date, DateArray, date_array -ndarray = numeric.ndarray +#ndarray = numeric.ndarray _byteorderconv = numpy.core.records._byteorderconv _typestr = ntypes._typestr @@ -54,6 +55,9 @@ logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) +__all__ = [ +'MultiTimeSeries','fromarrays','fromrecords','fromtextfile', +] def _getformats(data): """Returns the formats of each array of arraylist as a comma-separated @@ -130,6 +134,27 @@ # assert(_datadatescompat(data,newdates)) # return _data.view(cls) + + #.................................. + def __array_wrap__(self, obj, context=None): + """Special hook for ufuncs. +Wraps the numpy array and sets the mask according to context. + """ +# mclass = self.__class__ + #.......... + logging.debug("__wrap__ received %s" % type(obj)) + if context is None: +# return mclass(obj, mask=self._mask, copy=False) + return MaskedArray(obj, mask=self._mask, copy=False, + dtype=obj.dtype, + fill_value=self.fill_value, ) + #.......... + (func, args) = context[:2] + +# return mclass(obj, copy=False, mask=m) + return MultiTimeSeries(obj, copy=False, mask=m,) +# dtype=obj.dtype, fill_value=self._fill_value) + def __array_finalize__(self,obj): logging.debug("__array_finalize__ received %s" % type(obj)) @@ -600,6 +625,7 @@ # descr = [('A',N.float_),('B',N.float_)] # #if 1: +# import numpy as N # if 1: ## def setup(self): ## "Generic setup" @@ -613,6 +639,8 @@ # dates = date_array(dlist) # ts = time_series(mrec,dates) # mts = MultiTimeSeries(mrec,dates) +# +# logmts = N.log(mts) # self_data = [d, m, mrec, dlist, dates, ts, mts] # # # mts.addfield(masked_array(d+10, mask=m[::-1])) Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 04:38:16 UTC (rev 2569) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 04:43:06 UTC (rev 2570) @@ -17,20 +17,15 @@ -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu +: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 ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" __version__ = '1.0' __revision__ = "$Revision$" __date__ = '$Date$' - -import logging -import weakref - - import numpy from numpy import ndarray from numpy.core import bool_, complex_, float_, int_, object_ @@ -42,7 +37,6 @@ import maskedarray as MA #reload(MA) -#MaskedArray = MA.MaskedArray from maskedarray.core import MaskedArray, MAError, masked, nomask, \ filled, getmask, getmaskarray, make_mask_none, mask_or, make_mask, \ masked_array @@ -60,7 +54,17 @@ import cseries #reload(cseries) +__all__ = [ +'TimeSeriesError','TimeSeriesCompatibilityError','TimeSeries','isTimeSeries', +'time_series', +'day_of_week','dat_of_year','day','month','quarter','year','hour','minute','second', +'tofile','asrecords','flatten','adjust_endpoints','align_series','aligned', +'mask_period','mask_inside_period','mask_outside_period', +'convert','fill_missing_dates' + ] + #............................................................................... +import logging logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) talog = logging.getLogger('log.TimeArray') @@ -1143,7 +1147,8 @@ delta = dflat.get_steps()-1 gap = delta.nonzero() slcid = numpy.r_[[0,], numpy.arange(1,n)[gap], [n,]] - oldslc = numpy.array([slice(i,e) for (i,e) in numpy.broadcast(slcid[:-1],slcid[1:])]) + 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]], [slice(i+d,e+d) for (i,e,d) in \ @@ -1184,7 +1189,7 @@ return time_series(newdata.reshape(nshp), newdates) - +################################################################################ if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) from maskedarray.testutils import assert_equal From scipy-svn at scipy.org Tue Jan 16 00:28:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 15 Jan 2007 23:28:38 -0600 (CST) Subject: [Scipy-svn] r2571 - in trunk/Lib/sandbox/timeseries: . tests Message-ID: <20070116052838.4EF2039C03A@new.scipy.org> Author: pierregm Date: 2007-01-15 23:28:28 -0600 (Mon, 15 Jan 2007) New Revision: 2571 Modified: trunk/Lib/sandbox/timeseries/CHANGELOG trunk/Lib/sandbox/timeseries/tests/test_timeseries.py trunk/Lib/sandbox/timeseries/tseries.py Log: cf changelog Modified: trunk/Lib/sandbox/timeseries/CHANGELOG =================================================================== --- trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-16 04:43:06 UTC (rev 2570) +++ trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-16 05:28:28 UTC (rev 2571) @@ -1,16 +1,16 @@ -#2007-01-15 : - Added tmulti and its tests, to support multi-variable series +#2007-01-15 : tmulti : Add the module and its tests, to support multi-variable series +# : tdates : Some minor bug fixes +# : tseries: Fixed a bug in __new__ when data are lists +# : tcore : Introduced the forward/backward_fill and interpol functions. #2007-01-14 : Code reorganization: -# : - Moved Matt's initial version to archived_version -# : - Moved Pierre's version to base -# : tdates -# : - Fixed a bug w/ definition of months and weeks -# : - Renamed dateOf to asfreq + use cseries -#2007-01-04 : tsdate -# : - Corrected a bug w/ Date.__init__ and 'B' freq -#2007-01-03 : tseries -# : - Allowed endpoints adjustment after convert -# : - Put the estimation of the data length in its own function. -# : - Added a timestep compatibility check. -# : - The variables in a multi-series correspond now to the last axis. -# : - Blocked transpose/swapaxes, temporarily. -# : - Speed-up fill_missing_dates \ No newline at end of file +# : - Moved Matt's initial version to archived_version +# : - Moved Pierre's version to base +# : tdates : Fixed a bug w/ definition of months and weeks +# : tdates : Renamed dateOf to asfreq + use cseries +#2007-01-04 : tdates : Corrected a bug w/ Date.__init__ and 'B' freq +#2007-01-03 : tseries: Allowed endpoints adjustment after convert +# : tseries: Put the estimation of the data length in its own function. +# : tseries: Added a timestep compatibility check. +# : tseries: The variables in a multi-series correspond now to the last axis. +# : tseries: Blocked transpose/swapaxes, temporarily. +# : tseries: Speed-up fill_missing_dates \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-16 04:43:06 UTC (rev 2570) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-16 05:28:28 UTC (rev 2571) @@ -11,8 +11,6 @@ __revision__ = "$Revision$" __date__ = '$Date$' -import types - import numpy as N from numpy import bool_, complex_, float_, int_, object_ import numpy.core.fromnumeric as fromnumeric @@ -24,12 +22,8 @@ from maskedarray import masked_array, masked, nomask import maskedarray.testutils -#reload(maskedarray.testutils) from maskedarray.testutils import assert_equal, assert_array_equal -#import tdates -##reload(tdates) -#from tdates import date_array_fromlist import tseries #reload(tseries) from tseries import Date, date_array_fromlist @@ -57,8 +51,7 @@ def test_fromrange (self): "Base data definition." (dlist, dates, data) = self.d - series = time_series(data, start_date=Date('D',value=dates[0]), - length=15) + series = time_series(data, start_date=dates[0], length=15) assert(isinstance(series, TimeSeries)) assert_equal(series._mask, [1,0,0,0,0]*3) assert_equal(series._series, data) Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 04:43:06 UTC (rev 2570) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 05:28:28 UTC (rev 2571) @@ -224,7 +224,7 @@ # newdata = MaskedArray.__new__(cls, data=_data, mask=mask, **options) newdata = super(TimeSeries,cls).__new__(cls, _data, mask=mask, **options) - assert(_datadatescompat(newdata.data,newdates)) + assert(_datadatescompat(newdata._data,newdates)) return newdata #.................................. @@ -1193,55 +1193,70 @@ if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) from maskedarray.testutils import assert_equal - if 0: - dlist = ['2007-01-%02i' % i for i in range(1,16)] - dates = date_array(dlist) - data = masked_array(numeric.arange(15, dtype=float_), mask=[1,0,0,0,0]*3) -# btseries = BaseTimeSeries(data._data, dates) - tseries = time_series(data, dlist) - dseries = numpy.log(tseries) +# if 0: +# dlist = ['2007-01-%02i' % i for i in range(1,16)] +# dates = date_array(dlist) +# data = masked_array(numeric.arange(15, dtype=float_), mask=[1,0,0,0,0]*3) +## btseries = BaseTimeSeries(data._data, dates) +# tseries = time_series(data, dlist) +# dseries = numpy.log(tseries) +# if 0: +# mlist = ['2005-%02i' % i for i in range(1,13)] +# mlist += ['2006-%02i' % i for i in range(1,13)] +# mdata = numpy.arange(24) +# mser1 = time_series(mdata, mlist, observed='SUMMED') +# # +# mlist2 = ['2004-%02i' % i for i in range(1,13)] +# mlist2 += ['2005-%02i' % i for i in range(1,13)] +# mser2 = time_series(mdata, mlist2, observed='SUMMED') +# # +# today = thisday('m') +# (malg1,malg2) = aligned(mser1, mser2) +# +# C = convert(mser2,'A') +# D = convert(mser2,'A',func=None) +# +# if 0: +# dlist = ['2007-01-%02i' % i for i in range(1,16)] +# dates = date_array(dlist) +# print "."*50+"\ndata" +# data = masked_array(numeric.arange(15)-6, mask=[1,0,0,0,0]*3) +# print "."*50+"\nseries" +# tseries = time_series(data, dlist) +# +# if 0: +# dlist_1 = ['2007-01-%02i' % i for i in range(1,8)] +# dlist_2 = ['2007-01-%02i' % i for i in numpy.arange(1,28)[::4]] +# data = masked_array(numeric.arange(7), mask=[1,0,0,0,0,0,0]) +# tseries_1 = time_series(data, dlist_1) +# tseries_2 = time_series(data, dlist_2) +# tseries_3 = time_series(data[::-1], dlist_2) +# +# try: +# tseries = tseries_1 + tseries_2 +# except TimeSeriesCompatibilityError: +# print "I knew it!" +# tseries = tseries_2 + tseries_3 +# assert_equal(tseries._dates, tseries_3._dates) +# assert_equal(tseries._mask, [1,0,0,0,0,0,1]) +# +# if 0: +# mser3 = time_series(MA.mr_[malg1._series, 100+malg2._series].reshape(2,-1).T, +# dates=malg1.dates) +# data = mser3._series._data + if 1: - mlist = ['2005-%02i' % i for i in range(1,13)] - mlist += ['2006-%02i' % i for i in range(1,13)] - mdata = numpy.arange(24) - mser1 = time_series(mdata, mlist, observed='SUMMED') - # - mlist2 = ['2004-%02i' % i for i in range(1,13)] - mlist2 += ['2005-%02i' % i for i in range(1,13)] - mser2 = time_series(mdata, mlist2, observed='SUMMED') - # - today = thisday('m') - (malg1,malg2) = aligned(mser1, mser2) - - C = convert(mser2,'A') - D = convert(mser2,'A',func=None) - - if 0: dlist = ['2007-01-%02i' % i for i in range(1,16)] - dates = date_array(dlist) - print "."*50+"\ndata" - data = masked_array(numeric.arange(15)-6, mask=[1,0,0,0,0]*3) - print "."*50+"\nseries" - tseries = time_series(data, dlist) - - if 1: - dlist_1 = ['2007-01-%02i' % i for i in range(1,8)] - dlist_2 = ['2007-01-%02i' % i for i in numpy.arange(1,28)[::4]] - data = masked_array(numeric.arange(7), mask=[1,0,0,0,0,0,0]) - tseries_1 = time_series(data, dlist_1) - tseries_2 = time_series(data, dlist_2) - tseries_3 = time_series(data[::-1], dlist_2) - - try: - tseries = tseries_1 + tseries_2 - except TimeSeriesCompatibilityError: - print "I knew it!" - tseries = tseries_2 + tseries_3 - assert_equal(tseries._dates, tseries_3._dates) - assert_equal(tseries._mask, [1,0,0,0,0,0,1]) - - if 1: - mser3 = time_series(MA.mr_[malg1._series, 100+malg2._series].reshape(2,-1).T, - dates=malg1.dates) - data = mser3._series._data - + dates = date_array_fromlist(dlist) + data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3, dtype=float_) + self_d = (time_series(range(15), dlist), data, dates) + (series, data, dates) = self_d +# # Testing a basic condition on data +# cond = (series<8).filled(False) +# dseries = series[cond] +# assert_equal(dseries._data, [1,2,3,4,6,7]) +# assert_equal(dseries._dates, series._dates[[1,2,3,4,6,7]]) +# assert_equal(dseries._mask, nomask) +# # 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]) \ No newline at end of file From scipy-svn at scipy.org Tue Jan 16 02:11:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 16 Jan 2007 01:11:50 -0600 (CST) Subject: [Scipy-svn] r2572 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070116071150.BCB9139C0C7@new.scipy.org> Author: pierregm Date: 2007-01-16 01:11:41 -0600 (Tue, 16 Jan 2007) New Revision: 2572 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/extras.py trunk/Lib/sandbox/maskedarray/tests/test_extras.py Log: Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-16 05:28:28 UTC (rev 2571) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-16 07:11:41 UTC (rev 2572) @@ -1,4 +1,5 @@ -#2007-01-15 : mrecords: Add the addfield method +#2007-01-16 : extras : new function : `mediff1d` +#2007-01-15 : mrecords: new method: `addfield` # : core : Force the mask of a masked array `x` to be copied w/... # ...masked_array(x,copy=True,mask=nomask,keep_mask=true) #2007-01-14 : mrecords: Slices are now properly supported Modified: trunk/Lib/sandbox/maskedarray/extras.py =================================================================== --- trunk/Lib/sandbox/maskedarray/extras.py 2007-01-16 05:28:28 UTC (rev 2571) +++ trunk/Lib/sandbox/maskedarray/extras.py 2007-01-16 07:11:41 UTC (rev 2572) @@ -11,15 +11,15 @@ __revision__ = "$Revision$" __date__ = '$Date$' -__all__ = ['apply_along_axis', 'atleast_1d', 'atleast_2d', 'atleast_3d', - 'average', - 'vstack', 'hstack', 'dstack', 'row_stack', 'column_stack', - 'compress_rowcols', 'compress_rows', 'compress_cols', 'count_masked', - 'dot', - 'mask_rowcols', 'mask_rows', 'mask_cols', 'masked_all', - 'masked_all_like', 'mr_', - 'notmasked_edges', 'notmasked_contiguous', - 'stdu', 'varu', +__all__ = [ +'apply_along_axis', 'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', +'vstack', 'hstack', 'dstack', 'row_stack', 'column_stack', +'compress_rowcols', 'compress_rows', 'compress_cols', 'count_masked', +'dot', +'mask_rowcols','mask_rows','mask_cols','masked_all','masked_all_like', +'mediff1d', 'mr_', +'notmasked_edges','notmasked_contiguous', +'stdu', 'varu', ] from itertools import groupby @@ -66,7 +66,7 @@ """Returns an empty masked array of the same shape and dtype as the array `a`, where all the data are masked.""" a = masked_array(numeric.empty_like(arr), - mask=numeric.ones(shape, bool_)) + mask=numeric.ones(arr.shape, bool_)) return a #####-------------------------------------------------------------------------- @@ -446,6 +446,53 @@ m = ~numpy.dot(am,bm) return masked_array(d, mask=m) +#............................................................................... +def mediff1d(array, to_end=None, to_begin=None): + """Array difference with prefixed and/or appended value.""" + a = MA.masked_array(array, copy=True) + if a.ndim > 1: + a.reshape((a.size,)) + (d, m, n) = (a._data, a._mask, a.size-1) + dd = d[1:]-d[:-1] + if m is nomask: + dm = nomask + else: + dm = m[1:]-m[:-1] + # + if to_end is not None: + to_end = MA.asarray(to_end) + nend = to_end.size + if to_begin is not None: + to_begin = MA.asarray(to_begin) + nbegin = to_begin.size + r_data = N.empty((n+nend+nbegin,), dtype=a.dtype) + r_mask = N.zeros((n+nend+nbegin,), dtype=bool_) + r_data[:nbegin] = to_begin._data + r_mask[:nbegin] = to_begin._mask + r_data[nbegin:-nend] = dd + r_mask[nbegin:-nend] = dm + else: + r_data = N.empty((n+nend,), dtype=a.dtype) + r_mask = N.zeros((n+nend,), dtype=bool_) + r_data[:-nend] = dd + r_mask[:-nend] = dm + r_data[-nend:] = to_end._data + r_mask[-nend:] = to_end._mask + # + elif to_begin is not None: + to_begin = MA.asarray(to_begin) + nbegin = to_begin.size + r_data = N.empty((n+nbegin,), dtype=a.dtype) + r_mask = N.zeros((n+nbegin,), dtype=bool_) + r_data[:nbegin] = to_begin._data + r_mask[:nbegin] = to_begin._mask + r_data[nbegin:] = dd + r_mask[nbegin:] = dm + # + else: + r_data = dd + r_mask = dm + return masked_array(r_data, mask=r_mask) #####-------------------------------------------------------------------------- #---- --- Concatenation helpers --- Modified: trunk/Lib/sandbox/maskedarray/tests/test_extras.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_extras.py 2007-01-16 05:28:28 UTC (rev 2571) +++ trunk/Lib/sandbox/maskedarray/tests/test_extras.py 2007-01-16 07:11:41 UTC (rev 2572) @@ -261,6 +261,40 @@ assert_equal(c.mask,[[1,0],[1,1]]) c = dot(b,a) assert_equal(c.mask,[[0,0,1],[1,1,1],[0,0,1]]) + + def test_mediff1d(self): + "Tests mediff1d" + x = masked_array(N.arange(5), mask=[1,0,0,0,1]) + difx_d = (x._data[1:]-x._data[:-1]) + difx_m = (x._mask[1:]-x._mask[:-1]) + dx = mediff1d(x) + assert_equal(dx._data, difx_d) + assert_equal(dx._mask, difx_m) + # + dx = mediff1d(x, to_begin=masked) + assert_equal(dx._data, N.r_[0,difx_d]) + assert_equal(dx._mask, N.r_[1,difx_m]) + dx = mediff1d(x, to_begin=[1,2,3]) + assert_equal(dx._data, N.r_[[1,2,3],difx_d]) + assert_equal(dx._mask, N.r_[[0,0,0],difx_m]) + # + dx = mediff1d(x, to_end=masked) + assert_equal(dx._data, N.r_[difx_d,0]) + assert_equal(dx._mask, N.r_[difx_m,1]) + dx = mediff1d(x, to_end=[1,2,3]) + assert_equal(dx._data, N.r_[difx_d,[1,2,3]]) + assert_equal(dx._mask, N.r_[difx_m,[0,0,0]]) + # + dx = mediff1d(x, to_end=masked, to_begin=masked) + assert_equal(dx._data, N.r_[0,difx_d,0]) + assert_equal(dx._mask, N.r_[1,difx_m,1]) + dx = mediff1d(x, to_end=[1,2,3], to_begin=masked) + assert_equal(dx._data, N.r_[0,difx_d,[1,2,3]]) + assert_equal(dx._mask, N.r_[1,difx_m,[0,0,0]]) + # + dx = mediff1d(x._data, to_end=masked, to_begin=masked) + assert_equal(dx._data, N.r_[0,difx_d,0]) + assert_equal(dx._mask, N.r_[1,0,0,0,0,1]) ############################################################################### #------------------------------------------------------------------------------ From scipy-svn at scipy.org Tue Jan 16 14:23:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 16 Jan 2007 13:23:41 -0600 (CST) Subject: [Scipy-svn] r2573 - trunk/Lib/sandbox/timeseries Message-ID: <20070116192341.39F0E39C06D@new.scipy.org> Author: mattknox_ca Date: 2007-01-16 13:23:36 -0600 (Tue, 16 Jan 2007) New Revision: 2573 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: fixed typos in __all__ list Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 07:11:41 UTC (rev 2572) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 19:23:36 UTC (rev 2573) @@ -57,7 +57,7 @@ __all__ = [ 'TimeSeriesError','TimeSeriesCompatibilityError','TimeSeries','isTimeSeries', 'time_series', -'day_of_week','dat_of_year','day','month','quarter','year','hour','minute','second', +'day_of_week','day_of_year','day','month','quarter','year','hour','minute','second', 'tofile','asrecords','flatten','adjust_endpoints','align_series','aligned', 'mask_period','mask_inside_period','mask_outside_period', 'convert','fill_missing_dates' From scipy-svn at scipy.org Tue Jan 16 15:10:14 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 16 Jan 2007 14:10:14 -0600 (CST) Subject: [Scipy-svn] r2574 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070116201014.7EBFA39C06B@new.scipy.org> Author: mattknox_ca Date: 2007-01-16 14:10:11 -0600 (Tue, 16 Jan 2007) New Revision: 2574 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: updated cseries_getDateInfo function to support more attributes Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-16 19:23:36 UTC (rev 2573) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-16 20:10:11 UTC (rev 2574) @@ -156,6 +156,9 @@ return result; } +// needed for getDateInfo function +static long asfreq_DtoD(long fromDate, char relation) { 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; } @@ -480,6 +483,7 @@ case 'B': if (forConvert) { return &asfreq_DtoB_forConvert; } else { return &asfreq_DtoB; } + case 'D': return &asfreq_DtoD; case 'H': return &asfreq_DtoH; case 'T': return &asfreq_DtoT; case 'S': return &asfreq_DtoS; @@ -833,8 +837,51 @@ static long dInfo_quarter(mxDateTimeObject *dateObj) { return ((dateObj->month-1)/3)+1; } static long dInfo_month(mxDateTimeObject *dateObj) { return dateObj->month; } static long dInfo_day(mxDateTimeObject *dateObj) { return dateObj->day; } -static long dInfo_dow(mxDateTimeObject *dateObj) { return dateObj->day_of_week; } +static long dInfo_day_of_year(mxDateTimeObject *dateObj) { return dateObj->day_of_year; } +static long dInfo_day_of_week(mxDateTimeObject *dateObj) { return dateObj->day_of_week; } +static long dInfo_week(mxDateTimeObject *dateObj) { + long year, week, day; + PyObject *ISOWeekTuple = NULL; + ISOWeekTuple = PyObject_GetAttrString(dateObj, "iso_week"); + + if (!PyArg_ParseTuple(ISOWeekTuple,"iii;need a ISO Week 3-tuple (year,week,day)", + &year,&week,&day)) return NULL; + + Py_DECREF(ISOWeekTuple); + + return week; +} +static long dInfo_hour(mxDateTimeObject *dateObj) { return dateObj->hour; } +static long dInfo_minute(mxDateTimeObject *dateObj) { return dateObj->minute; } +static long dInfo_second(mxDateTimeObject *dateObj) { return dateObj->second; } + +static double getAbsTime(char freq, long dailyDate, long originalDate) { + + double periodsPerDay, result; + long startOfDay; + + switch(freq) + { + case 'H': + periodsPerDay = 24; + break; + case 'T': + periodsPerDay = 24*60; + break; + case 'S': + periodsPerDay = 24*60*60; + break; + default: + return 0; + } + + startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay); + return (24*60*60)*((double)(originalDate - startOfDay))/periodsPerDay; +} + + + static char cseries_getDateInfo_doc[] = ""; static PyObject * cseries_getDateInfo(PyObject *self, PyObject *args) @@ -849,6 +896,7 @@ PyObject *val; long dateNum, dInfo; + double absdate, abstime; long (*toDaily)(long, char) = NULL; long (*getDateInfo)(mxDateTimeObject*) = NULL; @@ -875,9 +923,24 @@ case 'D': //day getDateInfo = &dInfo_day; break; + case 'R': //day of year + getDateInfo = &dInfo_day_of_year; + break; case 'W': //day of week - getDateInfo = &dInfo_dow; + getDateInfo = &dInfo_day_of_week; break; + case 'I': //week of year + getDateInfo = &dInfo_week; + break; + case 'H': //hour + getDateInfo = &dInfo_hour; + break; + case 'T': //minute + getDateInfo = &dInfo_minute; + break; + case 'S': //second + getDateInfo = &dInfo_second; + break; default: return NULL; } @@ -886,8 +949,10 @@ val = PyArray_GETITEM(array, iterSource->dataptr); dateNum = PyInt_AsLong(val); + absdate = (double)toDaily(dateNum, 'B'); + abstime = getAbsTime(*freq, absdate, dateNum); - convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(toDaily(dateNum, 'A'), 0); + convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(absdate, abstime); dInfo = getDateInfo(convDate); Py_DECREF(convDate); From scipy-svn at scipy.org Tue Jan 16 15:13:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 16 Jan 2007 14:13:20 -0600 (CST) Subject: [Scipy-svn] r2575 - trunk/Lib/sandbox/timeseries Message-ID: <20070116201320.5035039C06B@new.scipy.org> Author: mattknox_ca Date: 2007-01-16 14:13:16 -0600 (Tue, 16 Jan 2007) New Revision: 2575 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: * bug fixes * changed various Date and DateArray properties to call the C function "getDateInfo" Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-16 20:10:11 UTC (rev 2574) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-16 20:13:16 UTC (rev 2575) @@ -41,8 +41,8 @@ __all__ = [ 'Date', 'DateArray','isDate','isDateArray', 'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', -'datearray','date_array', 'date_array_fromlist_', 'date_array_fromrange', -'day_of_week','dat_of_year','day','month','quarter','year','hour','minute','second', +'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' ] @@ -117,7 +117,7 @@ >>> td.Date('D', mxDate=datetime.datetime.now()) """ def __init__(self, freq, year=None, month=None, day=None, quarter=None, - hours=None, minutes=None, seconds=None, + hour=None, minute=None, second=None, mxDate=None, value=None, string=None): if hasattr(freq, 'freq'): @@ -150,7 +150,6 @@ elif self.freq == 'W': self.mxDate = mxD.Date(1,1,7) + \ mxD.RelativeDateTime(weeks=value-1) -# mxD.RelativeDateTime(weeks=value-5./7-1) elif string is not None: self.mxDate = mxDFromString(string) @@ -180,7 +179,7 @@ month = -1 day = -1 elif self.freq == 'S': - if month is None or day is None or seconds is None: + if month is None or day is None or second is None: raise InsufficientDateError if self.freq in ['A','B','D','M','Q','W']: @@ -189,58 +188,71 @@ if self.mxDate.day_of_week in [5,6]: raise ValueError("Weekend passed as business day") elif self.freq in ['H','S','T']: - if hours is None: - if minutes is None: - if seconds is None: - hours = 0 + if hour is None: + if minute is None: + if second is None: + hour = 0 else: - hours = seconds//3600 + hour = second//3600 else: - hours = minutes // 60 - if minutes is None: - if seconds is None: - minutes = 0 + hour = minute // 60 + if minute is None: + if second is None: + minute = 0 else: - minutes = (seconds-hours*3600)//60 - if seconds is None: - seconds = 0 + minute = (second-hour*3600)//60 + if second is None: + second = 0 else: - seconds = seconds % 60 + second = second % 60 self.mxDate = truncateDate(self.freq, mxD.Date(year, month, day, - hours, minutes, seconds)) + hour, minute, second)) self.value = self.__value() - # FIXME: Shall we set them as properties ? + + @property def day(self): "Returns the day of month." - return self.mxDate.day + return self.__getDateInfo('D') + @property def day_of_week(self): "Returns the day of week." - return self.mxDate.day_of_week + return self.__getDateInfo('W') + @property def day_of_year(self): "Returns the day of year." - return self.mxDate.day_of_year + return self.__getDateInfo('R') + @property def month(self): "Returns the month." - return self.mxDate.month + return self.__getDateInfo('M') + @property def quarter(self): "Returns the quarter." - return monthToQuarter(self.mxDate.month) + return self.__getDateInfo('Q') + @property def year(self): "Returns the year." - return self.mxDate.year + return self.__getDateInfo('Y') + @property def second(self): "Returns the seconds." - return int(self.mxDate.second) + return self.__getDateInfo('S') + @property def minute(self): "Returns the minutes." - return int(self.mxDate.minute) + return self.__getDateInfo('T') + @property def hour(self): "Returns the hour." - return int(self.mxDate.hour) + return self.__getDateInfo('H') + @property def week(self): "Returns the week." - return self.mxDate.iso_week[1] + return self.__getDateInfo('I') + + def __getDateInfo(self, info): + return int(cseries.getDateInfo(numpy.asarray(self.value), self.freq, info)) def __add__(self, other): if isinstance(other, Date): @@ -345,7 +357,8 @@ "Formats the date" qFmt = fmt.replace("%q", "XXXX") tmpStr = self.mxDate.strftime(qFmt) - return tmpStr.replace("XXXX", str(self.quarter())) + if "XXXX" in tmpStr: tmpStr = tmpStr.replace("XXXX", str(self.quarter)) + return tmpStr def __str__(self): return self.strfmt(self.default_fmtstr()) @@ -444,15 +457,10 @@ relation `relation` .""" toFreq = corelib.fmtFreq(toFreq) _rel = relation.upper()[0] -# if _rel not in ['B', 'A']: -# msg = "Invalid relation '%s': Should be in ['before', 'after']" -# raise ValueError, msg % relation -# elif _rel == 'B': -# before = True -# else: -# before = False + if _rel not in ['B', 'A']: + msg = "Invalid relation '%s': Should be in ['before', 'after']" + raise ValueError, msg % relation -# if not isDateType(date): if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" @@ -464,156 +472,6 @@ return Date(freq=toFreq, value=value) else: return None -# # Convert to annual .................... -# elif toFreq == 'A': -# return Date(freq='A', year=date.year()) -# # Convert to quarterly ................. -# elif toFreq == 'Q': -# if date.freq == 'A': -# if before: -# return Date(freq='A', year=date.year(), quarter=1) -# else: -# return Date(freq='A', year=date.year(), quarter=4) -# else: -# return Date(freq='Q', year=date.year(), quarter=date.quarter()) -# # Convert to monthly.................... -# elif toFreq == 'M': -# if date.freq == 'A': -# if before: -# return Date(freq='M', year=date.year(), month=1) -# else: -# return Date(freq='M', year=date.year(), month=12) -# elif date.freq == 'Q': -# if before: -# return dateOf(date-1, 'M', "AFTER")+1 -# else: -# return Date(freq='M', year=date.year(), month=date.month()) -# else: -# return Date(freq='M', year=date.year(), month=date.month()) -# # Convert to weekly .................... -# elif toFreq == 'W': -# if date.freq == 'A': -# if before: -# return Date(freq='W', year=date.year(), month=1, day=1) -# else: -# return Date(freq='W', year=date.year(), month=12, day=-1) -# elif date.freq in ['Q','M']: -# if before: -# return dateOf(date-1, 'W', "AFTER")+1 -# else: -# return Date(freq='W', year=date.year(), month=date.month()) -# else: -# val = date.weeks() + int(date.year()*365.25/7.-1) -# return Date(freq='W', value=val) -# # Convert to business days.............. -# elif toFreq == 'B': -# if date.freq in ['A','Q','M','W']: -# if before: -# return dateOf(dateOf(date, 'D'), 'B', "AFTER") -# else: -# return dateOf(dateOf(date, 'D', "AFTER"), 'B', "BEFORE") -# elif date.freq == 'D': -# # BEFORE result: preceeding Friday if date is a weekend, same day otherwise -# # AFTER result: following Monday if date is a weekend, same day otherwise -# tempDate = date.mxDate -# if before: -# if tempDate.day_of_week >= 5: -# tempDate -= (tempDate.day_of_week - 4) -# else: -# if tempDate.day_of_week >= 5: -# tempDate += 7 - tempDate.day_of_week -# return Date(freq='B', mxDate=tempDate) -# else: -# if before: -# return dateOf(dateOf(date, 'D'), 'B', "BEFORE") -# else: -# return dateOf(dateOf(date, 'D'), 'B', "AFTER") -# # Convert to day ....................... -# elif toFreq == 'D': -# # ...from annual -# if date.freq == 'A': -# if before: -# return Date(freq='D', year=date.year(), month=1, day=1) -# else: -# return Date(freq='D', year=date.year(), month=12, day=31) -# # ...from quarter -# elif date.freq == 'Q': -# if before: -# return dateOf(date-1, 'D', "AFTER")+1 -# else: -# return Date(freq='D', year=date.year(), month=date.month(), -# day=date.day()) -# # ...from month -# elif date.freq == 'M': -# if before: -# return Date(freq='D', year=date.year(), month=date.month(), day=1) -# else: -# (mm,yy) = (date.month(), date.year()) -# if date.month() == 12: -# (mm, yy) = (1, yy + 1) -# else: -# mm = mm + 1 -# return Date('D', year=yy, month=mm, day=1)-1 -# # ...from week -# elif date.freq == 'W': -# if before: -# return Date(freq='D', year=date.year(), month=date.month(), -# day=date.day()) -# else: -# ndate = date + 1 -# return Date(freq='D', year=ndate.year(), month=ndate.month(), -# day=ndate.day()) -# # ...from a lower freq -# else: -# return Date('D', year=date.year(), month=date.month(), day=date.day()) -# #Convert to hour........................ -# elif toFreq == 'H': -# if date.freq in ['A','Q','M','W']: -# if before: -# return dateOf(dateOf(date, 'D', "BEFORE"), 'H', "BEFORE") -# else: -# return dateOf(dateOf(date, 'D', "AFTER"), 'H', "AFTER") -# if date.freq in ['B','D']: -# if before: -# return Date(freq='H', year=date.year(), month=date.month(), -# day=date.day(), hours=0) -# else: -# return Date(freq='H', year=date.year(), month=date.month(), -# day=date.day(), hours=23) -# else: -# return Date(freq='H', year=date.year(), month=date.month(), -# day=date.day(), hours=date.hour()) -# #Convert to second...................... -# elif toFreq == 'T': -# if date.freq in ['A','Q','M','W']: -# if before: -# return dateOf(dateOf(date, 'D', "BEFORE"), 'T', "BEFORE") -# else: -# return dateOf(dateOf(date, 'D', "AFTER"), 'T', "AFTER") -# elif date.freq in ['B','D','H']: -# if before: -# return Date(freq='T', year=date.year(), month=date.month(), -# day=date.day(), minutes=0) -# else: -# return Date(freq='T', year=date.year(), month=date.month(), -# day=date.day(), minutes=24*60-1) -# else: -# return Date(freq='H', year=date.year(), month=date.month(), -# day=date.day(), hours=date.hour(), minutes=date.minute()) -# #Convert to minute...................... -# elif toFreq == 'S': -# if date.freq in ['A','Q','M','W']: -# if before: -# return dateOf(dateOf(date, 'D', "BEFORE"), 'S', "BEFORE") -# else: -# return dateOf(dateOf(date, 'D', "AFTER"), 'S', "AFTER") -# elif date.freq in ['B','D']: -# if before: -# return Date(freq='S', year=date.year(), month=date.month(), -# day=date.day(), seconds=0) -# else: -# return Date(freq='S', year=date.year(), month=date.month(), -# day=date.day(), seconds=24*60*60-1) def isDate(data): "Returns whether `data` is an instance of Date." @@ -695,22 +553,60 @@ return ndarray.__repr__(self) #...................................................... @property - def years(self): - "Returns the years." - return numeric.asarray([d.year() for d in self], dtype=int_) + def day(self): + "Returns the day of month." + return self.__getDateInfo('D') @property - def months(self): - "Returns the months." - return numeric.asarray([d.month() for d in self], dtype=int_) + def day_of_week(self): + "Returns the day of week." + return self.__getDateInfo('W') @property - def day_of_year(self): - "Returns the days of years." - return numeric.asarray([d.day_of_year() for d in self], dtype=int_) - yeardays = day_of_year + def day_of_year(self): + "Returns the day of year." + return self.__getDateInfo('R') @property - def day_of_week(self): - "Returns the days of week." - return numeric.asarray([d.day_of_week() for d in self], dtype=int_) + 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_) + #.... Conversion methods .................... # def toobject(self): # "Converts the dates from ordinals to Date objects." From scipy-svn at scipy.org Tue Jan 16 15:17:09 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 16 Jan 2007 14:17:09 -0600 (CST) Subject: [Scipy-svn] r2576 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070116201709.8990F39C037@new.scipy.org> Author: mattknox_ca Date: 2007-01-16 14:17:06 -0600 (Tue, 16 Jan 2007) New Revision: 2576 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: updated unit tests to work with newest code Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-16 20:13:16 UTC (rev 2575) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-16 20:17:06 UTC (rev 2576) @@ -25,10 +25,10 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -import tdates -import tcore +from timeseries import tdates +from timeseries import tcore reload(tdates) -from tdates import date_array_fromlist, Date, DateArray, mxDFromString +from timeseries.tdates import date_array_fromlist, Date, DateArray, mxDFromString class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -111,6 +111,93 @@ assert(tdates.Date(freq=f, value=today.value) == today) +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, + hour=0) + t_date = tdates.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, + hour=0, minute=0, second=0) + + 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 x in range(11): + + m_date_x = m_date+x + assert_equal(m_date_x.year, 2007) + + if 1 <= x + 1 <= 3: assert_equal(m_date_x.quarter, 1) + elif 4 <= x + 1 <= 6: assert_equal(m_date_x.quarter, 2) + elif 7 <= x + 1 <= 9: assert_equal(m_date_x.quarter, 3) + elif 10 <= x + 1 <= 12: assert_equal(m_date_x.quarter, 4) + + assert_equal(m_date_x.month, x+1) + + assert_equal(w_date.year, 2007) + assert_equal(w_date.quarter, 1) + assert_equal(w_date.month, 1) + assert_equal(w_date.week, 1) + assert_equal((w_date-1).week, 52) + + assert_equal(b_date.year, 2007) + assert_equal(b_date.quarter, 1) + assert_equal(b_date.month, 1) + assert_equal(b_date.day, 1) + assert_equal(b_date.day_of_week, 0) + assert_equal(b_date.day_of_year, 1) + + assert_equal(d_date.year, 2007) + assert_equal(d_date.quarter, 1) + assert_equal(d_date.month, 1) + assert_equal(d_date.day, 1) + assert_equal(d_date.day_of_week, 0) + assert_equal(d_date.day_of_year, 1) + + assert_equal(h_date.year, 2007) + assert_equal(h_date.quarter, 1) + assert_equal(h_date.month, 1) + assert_equal(h_date.day, 1) + assert_equal(h_date.day_of_week, 0) + assert_equal(h_date.day_of_year, 1) + assert_equal(h_date.hour, 0) + + assert_equal(t_date.year, 2007) + assert_equal(t_date.quarter, 1) + assert_equal(t_date.month, 1) + assert_equal(t_date.day, 1) + assert_equal(t_date.day_of_week, 0) + assert_equal(t_date.day_of_year, 1) + assert_equal(t_date.hour, 0) + assert_equal(t_date.minute, 0) + + assert_equal(s_date.year, 2007) + assert_equal(s_date.quarter, 1) + assert_equal(s_date.month, 1) + assert_equal(s_date.day, 1) + assert_equal(s_date.day_of_week, 0) + assert_equal(s_date.day_of_year, 1) + assert_equal(s_date.hour, 0) + assert_equal(s_date.minute, 0) + assert_equal(s_date.second, 0) + + class test_freq_conversion(NumpyTestCase): "Test frequency conversion of date objects" @@ -132,17 +219,17 @@ date_A_to_D_before = Date(freq='D', year=2007, month=1, day=1) date_A_to_D_after = Date(freq='D', year=2007, month=12, day=31) date_A_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_A_to_H_after = Date(freq='H', year=2007, month=12, day=31, - hours=23) + hour=23) date_A_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_A_to_T_after = Date(freq='T', year=2007, month=12, day=31, - hours=23, minutes=59) + hour=23, minute=59) date_A_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_A_to_S_after = Date(freq='S', year=2007, month=12, day=31, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) assert_equal(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) assert_equal(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) @@ -177,17 +264,17 @@ date_Q_to_D_before = Date(freq='D', year=2007, month=1, day=1) date_Q_to_D_after = Date(freq='D', year=2007, month=3, day=31) date_Q_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_Q_to_H_after = Date(freq='H', year=2007, month=3, day=31, - hours=23) + hour=23) date_Q_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_Q_to_T_after = Date(freq='T', year=2007, month=3, day=31, - hours=23, minutes=59) + hour=23, minute=59) date_Q_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_Q_to_S_after = Date(freq='S', year=2007, month=3, day=31, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) assert_equal(date_Q.asfreq('A'), date_Q_to_A) assert_equal(date_Q_end_of_year.asfreq('A'), date_Q_to_A) @@ -223,17 +310,17 @@ date_M_to_D_before = Date(freq='D', year=2007, month=1, day=1) date_M_to_D_after = Date(freq='D', year=2007, month=1, day=31) date_M_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_M_to_H_after = Date(freq='H', year=2007, month=1, day=31, - hours=23) + hour=23) date_M_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_M_to_T_after = Date(freq='T', year=2007, month=1, day=31, - hours=23, minutes=59) + hour=23, minute=59) date_M_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_M_to_S_after = Date(freq='S', year=2007, month=1, day=31, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) assert_equal(date_M.asfreq('A'), date_M_to_A) assert_equal(date_M_end_of_year.asfreq('A'), date_M_to_A) @@ -265,17 +352,17 @@ date_W_to_Q = Date(freq='Q', year=2007, quarter=1) date_W_to_M = Date(freq='M', year=2007, month=1) - if Date(freq='D', year=2007, month=12, day=31).day_of_week() == 6: + if Date(freq='D', year=2007, month=12, day=31).day_of_week == 6: date_W_to_A_end_of_year = Date(freq='A', year=2007) else: date_W_to_A_end_of_year = Date(freq='A', year=2008) - if Date(freq='D', year=2007, month=3, day=31).day_of_week() == 6: + if Date(freq='D', year=2007, month=3, day=31).day_of_week == 6: date_W_to_Q_end_of_quarter = Date(freq='Q', year=2007, quarter=1) else: date_W_to_Q_end_of_quarter = Date(freq='Q', year=2007, quarter=2) - if Date(freq='D', year=2007, month=1, day=31).day_of_week() == 6: + if Date(freq='D', year=2007, month=1, day=31).day_of_week == 6: date_W_to_M_end_of_month = Date(freq='M', year=2007, month=1) else: date_W_to_M_end_of_month = Date(freq='M', year=2007, month=2) @@ -285,17 +372,17 @@ date_W_to_D_before = Date(freq='D', year=2007, month=1, day=1) date_W_to_D_after = Date(freq='D', year=2007, month=1, day=7) date_W_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_W_to_H_after = Date(freq='H', year=2007, month=1, day=7, - hours=23) + hour=23) date_W_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_W_to_T_after = Date(freq='T', year=2007, month=1, day=7, - hours=23, minutes=59) + hour=23, minute=59) date_W_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_W_to_S_after = Date(freq='S', year=2007, month=1, day=7, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) assert_equal(date_W.asfreq('A'), date_W_to_A) assert_equal(date_W_end_of_year.asfreq('A'), date_W_to_A_end_of_year) @@ -330,17 +417,17 @@ date_B_to_W = Date(freq='W', year=2007, month=1, day=7) date_B_to_D = Date(freq='D', year=2007, month=1, day=1) date_B_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_B_to_H_after = Date(freq='H', year=2007, month=1, day=1, - hours=23) + hour=23) date_B_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_B_to_T_after = Date(freq='T', year=2007, month=1, day=1, - hours=23, minutes=59) + hour=23, minute=59) date_B_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_B_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) assert_equal(date_B.asfreq('A'), date_B_to_A) assert_equal(date_B_end_of_year.asfreq('A'), date_B_to_A) @@ -383,17 +470,17 @@ date_D_to_W = Date(freq='W', year=2007, month=1, day=7) date_D_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_D_to_H_after = Date(freq='H', year=2007, month=1, day=1, - hours=23) + hour=23) date_D_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_D_to_T_after = Date(freq='T', year=2007, month=1, day=1, - hours=23, minutes=59) + hour=23, minute=59) date_D_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_D_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) assert_equal(date_D.asfreq('A'), date_D_to_A) assert_equal(date_D_end_of_year.asfreq('A'), date_D_to_A) @@ -420,19 +507,19 @@ def test_conv_hourly(self): "frequency conversion tests: from Hourly Frequency" - date_H = Date(freq='H', year=2007, month=1, day=1, hours=0) + date_H = Date(freq='H', year=2007, month=1, day=1, hour=0) date_H_end_of_year = Date(freq='H', year=2007, month=12, day=31, - hours=23) + hour=23) date_H_end_of_quarter = Date(freq='H', year=2007, month=3, day=31, - hours=23) + hour=23) date_H_end_of_month = Date(freq='H', year=2007, month=1, day=31, - hours=23) + hour=23) date_H_end_of_week = Date(freq='H', year=2007, month=1, day=7, - hours=23) + hour=23) date_H_end_of_day = Date(freq='H', year=2007, month=1, day=1, - hours=23) + hour=23) date_H_end_of_bus = Date(freq='H', year=2007, month=1, day=1, - hours=23) + hour=23) date_H_to_A = Date(freq='A', year=2007) date_H_to_Q = Date(freq='Q', year=2007, quarter=1) @@ -442,13 +529,13 @@ date_H_to_B = Date(freq='B', year=2007, month=1, day=1) date_H_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_H_to_T_after = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=59) + hour=0, minute=59) date_H_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_H_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=59, seconds=59) + hour=0, minute=59, second=59) assert_equal(date_H.asfreq('A'), date_H_to_A) assert_equal(date_H_end_of_year.asfreq('A'), date_H_to_A) @@ -472,21 +559,21 @@ "frequency conversion tests: from Minutely Frequency" date_T = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) date_T_end_of_year = Date(freq='T', year=2007, month=12, day=31, - hours=23, minutes=59) + hour=23, minute=59) date_T_end_of_quarter = Date(freq='T', year=2007, month=3, day=31, - hours=23, minutes=59) + hour=23, minute=59) date_T_end_of_month = Date(freq='T', year=2007, month=1, day=31, - hours=23, minutes=59) + hour=23, minute=59) date_T_end_of_week = Date(freq='T', year=2007, month=1, day=7, - hours=23, minutes=59) + hour=23, minute=59) date_T_end_of_day = Date(freq='T', year=2007, month=1, day=1, - hours=23, minutes=59) + hour=23, minute=59) date_T_end_of_bus = Date(freq='T', year=2007, month=1, day=1, - hours=23, minutes=59) + hour=23, minute=59) date_T_end_of_hour = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=59) + hour=0, minute=59) date_T_to_A = Date(freq='A', year=2007) date_T_to_Q = Date(freq='Q', year=2007, quarter=1) @@ -494,12 +581,12 @@ date_T_to_W = Date(freq='W', year=2007, month=1, day=7) date_T_to_D = Date(freq='D', year=2007, month=1, day=1) date_T_to_B = Date(freq='B', year=2007, month=1, day=1) - date_T_to_H = Date(freq='H', year=2007, month=1, day=1, hours=0) + date_T_to_H = Date(freq='H', year=2007, month=1, day=1, hour=0) date_T_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_T_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=59) + hour=0, minute=0, second=59) assert_equal(date_T.asfreq('A'), date_T_to_A) assert_equal(date_T_end_of_year.asfreq('A'), date_T_to_A) @@ -524,23 +611,23 @@ "frequency conversion tests: from Secondly Frequency" date_S = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=0) + hour=0, minute=0, second=0) date_S_end_of_year = Date(freq='S', year=2007, month=12, day=31, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) date_S_end_of_quarter = Date(freq='S', year=2007, month=3, day=31, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) date_S_end_of_month = Date(freq='S', year=2007, month=1, day=31, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) date_S_end_of_week = Date(freq='S', year=2007, month=1, day=7, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) date_S_end_of_day = Date(freq='S', year=2007, month=1, day=1, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) date_S_end_of_bus = Date(freq='S', year=2007, month=1, day=1, - hours=23, minutes=59, seconds=59) + hour=23, minute=59, second=59) date_S_end_of_hour = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=59, seconds=59) + hour=0, minute=59, second=59) date_S_end_of_minute = Date(freq='S', year=2007, month=1, day=1, - hours=0, minutes=0, seconds=59) + hour=0, minute=0, second=59) date_S_to_A = Date(freq='A', year=2007) date_S_to_Q = Date(freq='Q', year=2007, quarter=1) @@ -549,9 +636,9 @@ date_S_to_D = Date(freq='D', year=2007, month=1, day=1) date_S_to_B = Date(freq='B', year=2007, month=1, day=1) date_S_to_H = Date(freq='H', year=2007, month=1, day=1, - hours=0) + hour=0) date_S_to_T = Date(freq='T', year=2007, month=1, day=1, - hours=0, minutes=0) + hour=0, minute=0) assert_equal(date_S.asfreq('A'), date_S_to_A) assert_equal(date_S_end_of_year.asfreq('A'), date_S_to_A) From scipy-svn at scipy.org Wed Jan 17 14:19:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 17 Jan 2007 13:19:01 -0600 (CST) Subject: [Scipy-svn] r2577 - trunk/Lib/sandbox/timeseries Message-ID: <20070117191901.B9ED139C068@new.scipy.org> Author: mattknox_ca Date: 2007-01-17 13:18:58 -0600 (Wed, 17 Jan 2007) New Revision: 2577 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: removed interp parameter from convert function and method Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-16 20:17:06 UTC (rev 2576) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-17 19:18:58 UTC (rev 2577) @@ -487,9 +487,9 @@ return self return TimeSeries(self._series, dates=self._dates.asfreq(freq)) - def convert(self, freq, func='auto', position='END', interp=None): + 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, interp=interp) + return convert(self, freq, func=func, position=position) ##### -------------------------------------------------------------------------- ##--- ... Additional methods ... @@ -1031,7 +1031,7 @@ return [adjust_endpoints(x, start_date, end_date) for x in series] aligned = align_series #.................................................................... -def convert(series, freq, func='auto', position='END', interp=None): +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 @@ -1045,11 +1045,7 @@ 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 - placed at the end of the month). Interp is the method that will be used - to fill in the gaps. Valid values are "CUBIC", "LINEAR", "CONSTANT", "DIVIDED", - and None. - - Note: interp currently not implemented + placed at the end of the month). """ if not isinstance(series,TimeSeries): raise TypeError, "The argument should be a valid TimeSeries!" From scipy-svn at scipy.org Wed Jan 17 14:25:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 17 Jan 2007 13:25:19 -0600 (CST) Subject: [Scipy-svn] r2578 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070117192519.B22BA39C068@new.scipy.org> Author: mattknox_ca Date: 2007-01-17 13:25:10 -0600 (Wed, 17 Jan 2007) New Revision: 2578 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added test for creating time series where data is a list Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-17 19:18:58 UTC (rev 2577) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-17 19:25:10 UTC (rev 2578) @@ -24,10 +24,10 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -import tseries +from timeseries import tseries #reload(tseries) -from tseries import Date, date_array_fromlist -from tseries import time_series, TimeSeries, adjust_endpoints, mask_period +from timeseries.tseries import Date, date_array_fromlist +from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, mask_period class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -69,6 +69,12 @@ assert_equal(series._series, data) assert_equal(series._dates, dates) assert_equal(series.freq, 'D') + + def test_datafromlist(self): + (_, dates, _) = self.d + data = list(range(15)) + series = time_series(data, dates) + assert_equal(series._data.size, 15) #............................................................................... class test_arithmetics(NumpyTestCase): From scipy-svn at scipy.org Wed Jan 17 15:13:52 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 17 Jan 2007 14:13:52 -0600 (CST) Subject: [Scipy-svn] r2579 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070117201352.E4C2239C0CF@new.scipy.org> Author: mattknox_ca Date: 2007-01-17 14:13:48 -0600 (Wed, 17 Jan 2007) New Revision: 2579 Added: trunk/Lib/sandbox/timeseries/tests/test_misc.py Log: Added a file remotely Added: trunk/Lib/sandbox/timeseries/tests/test_misc.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-01-17 19:25:10 UTC (rev 2578) +++ trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-01-17 20:13:48 UTC (rev 2579) @@ -0,0 +1,70 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for MaskedArray. +Adapted from the original test_ma by Pierre Gerard-Marchant + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: test_timeseries.py 2578 2007-01-17 19:25:10Z mattknox_ca $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: mattknox_ca $)" +__version__ = '1.0' +__revision__ = "$Revision: 2578 $" +__date__ = '$Date: 2007-01-17 14:25:10 -0500 (Wed, 17 Jan 2007) $' + +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 tcore + +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(tcore.backward_fill(self.test_array, maxgap=1), result) + + result[5] = 7 + result[6] = 7 + + assert_equal(tcore.backward_fill(self.test_array), result) + + def test_forward_fill (self): + result = masked_array(self.data, mask=self.mask) + result[2] = 1 + + assert_equal(tcore.forward_fill(self.test_array, maxgap=1), result) + + result[5] = 4 + result[6] = 4 + + assert_equal(tcore.forward_fill(self.test_array), result) + + def test_interp_fill(self): + result_lin = masked_array(self.data).astype(float_) + result_lin[0] = masked + + approx(tcore.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 Thu Jan 18 14:51:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 18 Jan 2007 13:51:36 -0600 (CST) Subject: [Scipy-svn] r2580 - trunk/Lib/weave Message-ID: <20070118195136.AD17D39C091@new.scipy.org> Author: fperez Date: 2007-01-18 13:51:31 -0600 (Thu, 18 Jan 2007) New Revision: 2580 Modified: trunk/Lib/weave/catalog.py Log: Fix race condition on filesystem access that can arise when multiple processes try to initialize the catalog on a shared network filesystem. Modified: trunk/Lib/weave/catalog.py =================================================================== --- trunk/Lib/weave/catalog.py 2007-01-17 20:13:48 UTC (rev 2579) +++ trunk/Lib/weave/catalog.py 2007-01-18 19:51:31 UTC (rev 2580) @@ -33,6 +33,7 @@ import os,sys,string import pickle +import socket import tempfile try: @@ -127,13 +128,30 @@ os.mkdir(p) def is_writable(dir): - dummy = os.path.join(dir, "dummy") + """Determine whether a given directory is writable in a portable manner. + + :Parameters: + - dir: string + A string represeting a path to a directory on the filesystem. + + :Returns: + True or False. + """ + + # Do NOT use a hardcoded name here due to the danger from race conditions + # on NFS when multiple processes are accessing the same base directory in + # parallel. We use both hostname and pocess id for the prefix in an + # attempt to ensure that there can really be no name collisions (tempfile + # appends 6 random chars to this prefix). + prefix = 'dummy_%s_%s_' % (socket.gethostname(),os.getpid()) try: - open(dummy, 'w') - except IOError: - return 0 - os.unlink(dummy) - return 1 + tmp = tempfile.TemporaryFile(prefix=prefix,dir=dir) + except OSError: + return False + # The underlying file is destroyed upon closing the file object (under + # *nix, it was unlinked at creation time) + tmp.close() + return True def whoami(): """return a string identifying the user.""" From scipy-svn at scipy.org Fri Jan 19 02:34:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 19 Jan 2007 01:34:26 -0600 (CST) Subject: [Scipy-svn] r2581 - trunk/Lib/signal Message-ID: <20070119073426.8BA8239C086@new.scipy.org> Author: rkern Date: 2007-01-19 01:34:09 -0600 (Fri, 19 Jan 2007) New Revision: 2581 Modified: trunk/Lib/signal/filter_design.py Log: Fix some imports. Modified: trunk/Lib/signal/filter_design.py =================================================================== --- trunk/Lib/signal/filter_design.py 2007-01-18 19:51:31 UTC (rev 2580) +++ trunk/Lib/signal/filter_design.py 2007-01-19 07:34:09 UTC (rev 2581) @@ -2,11 +2,11 @@ """ import numpy -from numpy.core.umath import * -from numpy import atleast_1d, poly, polyval, roots, imag, real, asarray,\ - allclose, resize, pi, concatenate, absolute, logspace -from numpy import mintypecode, select -from scipy import special, optimize, linalg +from numpy import atleast_1d, poly, polyval, roots, real, asarray, allclose, \ + resize, pi, absolute, logspace, r_, sqrt, tan, log10, arctan, arcsinh, \ + cos, exp, cosh, arccosh, ceil, conjugate, zeros, sinh +from numpy import mintypecode +from scipy import special, optimize from scipy.misc import comb import string, types From scipy-svn at scipy.org Sun Jan 21 00:05:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 20 Jan 2007 23:05:34 -0600 (CST) Subject: [Scipy-svn] r2582 - trunk/Lib/signal Message-ID: <20070121050534.D777B39C05E@new.scipy.org> Author: rkern Date: 2007-01-20 23:05:33 -0600 (Sat, 20 Jan 2007) New Revision: 2582 Modified: trunk/Lib/signal/filter_design.py Log: Add workaround for 0-d arrays being passed to lp2lp and lp2hp. Modified: trunk/Lib/signal/filter_design.py =================================================================== --- trunk/Lib/signal/filter_design.py 2007-01-19 07:34:09 UTC (rev 2581) +++ trunk/Lib/signal/filter_design.py 2007-01-21 05:05:33 UTC (rev 2582) @@ -182,8 +182,11 @@ from a low-pass filter prototype with unity cutoff frequency. """ a,b = map(atleast_1d,(a,b)) + # fixme: this test is not terribly reliable in the face of 0-d arrays which + # tend to get passed in. However, using .flat should work around that + # problem. if type(wo) is type(a): - wo = wo[0] + wo = wo.flat[0] wo = float(wo) d = len(a) n = len(b) @@ -200,8 +203,11 @@ from a low-pass filter prototype with unity cutoff frequency. """ a,b = map(atleast_1d,(a,b)) + # fixme: this test is not terribly reliable in the face of 0-d arrays which + # tend to get passed in. However, using .flat should work around that + # problem. if type(wo) is type(a): - wo = wo[0] + wo = wo.flat[0] d = len(a) n = len(b) if wo != 1: From scipy-svn at scipy.org Sun Jan 21 04:11:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 21 Jan 2007 03:11:22 -0600 (CST) Subject: [Scipy-svn] r2583 - in trunk/Lib: integrate signal Message-ID: <20070121091122.D23FE39C05E@new.scipy.org> Author: oliphant Date: 2007-01-21 03:11:09 -0600 (Sun, 21 Jan 2007) New Revision: 2583 Modified: trunk/Lib/integrate/quadrature.py trunk/Lib/signal/filter_design.py Log: Fix lp2lp and lp2hp and add newton_cotes rules for quadrature. Modified: trunk/Lib/integrate/quadrature.py =================================================================== --- trunk/Lib/integrate/quadrature.py 2007-01-21 05:05:33 UTC (rev 2582) +++ trunk/Lib/integrate/quadrature.py 2007-01-21 09:11:09 UTC (rev 2583) @@ -3,11 +3,13 @@ # Author: Travis Oliphant __all__ = ['fixed_quad','quadrature','romberg','trapz','simps','romb', - 'cumtrapz'] + 'cumtrapz','newton_cotes','composite'] from scipy.special.orthogonal import p_roots from numpy import sum, ones, add, diff, isinf, isscalar, \ asarray, real, trapz, arange, empty +import scipy as sp +import numpy as np def fixed_quad(func,a,b,args=(),n=5): """Compute a definite integral using fixed-order Gaussian quadrature. @@ -457,3 +459,143 @@ if show: _printresmat(vfunc, interval, resmat) return result + + +# Coefficients for Netwon-Cotes quadrature +# +# These are the points being used +# to construct the local interpolating polynomial +# a are the weights for Newton-Cotes integration +# B is the error coefficient. +# error in these coefficients grows as N gets larger. +# or as samples are closer and closer together + +# You can use maxima to find these rational coefficients +# for equally spaced data using the commands +# a(i,N) := integrate(product(r-j,j,0,i-1) * product(r-j,j,i+1,N),r,0,N) / ((N-i)! * i!) * (-1)^(N-i); +# Be(N) := N^(N+2)/(N+2)! * (N/(N+3) - sum((i/N)^(N+2)*a(i,N),i,0,N)); +# Bo(N) := N^(N+1)/(N+1)! * (N/(N+2) - sum((i/N)^(N+1)*a(i,N),i,0,N)); +# B(N) := (if (mod(N,2)=0) then Be(N) else Bo(N)); +# +# pre-computed for equally-spaced weights +# +# num_a, den_a, int_a, num_B, den_B = _builtincoeffs[N] +# +# a = num_a*array(int_a)/den_a +# B = num_B*1.0 / den_B +# +# integrate(f(x),x,x_0,x_N) = dx*sum(a*f(x_i)) + B*(dx)^(2k+3) f^(2k+2)(x*) +# where k = N // 2 +# +_builtincoeffs = { + 1:(1,2,[1,1],-1,12), + 2:(1,3,[1,4,1],-1,90), + 3:(3,8,[1,3,3,1],-3,80), + 4:(2,45,[7,32,12,32,7],-8,945), + 5:(5,288,[19,75,50,50,75,19],-275,12096), + 6:(1,140,[41,216,27,272,27,216,41],-9,1400), + 7:(7,17280,[751,3577,1323,2989,2989,1323,3577,751],-8183,518400), + 8:(4,14175,[989,5888,-928,10496,-4540,10496,-928,5888,989], + -2368,467775), + 9:(9,89600,[2857,15741,1080,19344,5778,5778,19344,1080, + 15741,2857], -4671, 394240), + 10:(5,299376,[16067,106300,-48525,272400,-260550,427368, + -260550,272400,-48525,106300,16067], + -673175, 163459296), + 11:(11,87091200,[2171465,13486539,-3237113, 25226685,-9595542, + 15493566,15493566,-9595542,25226685,-3237113, + 13486539,2171465], -2224234463, 237758976000), + 12:(1, 5255250, [1364651,9903168,-7587864,35725120,-51491295, + 87516288,-87797136,87516288,-51491295,35725120, + -7587864,9903168,1364651], -3012, 875875), + 13:(13, 402361344000,[8181904909, 56280729661, -31268252574, + 156074417954,-151659573325,206683437987, + -43111992612,-43111992612,206683437987, + -151659573325,156074417954,-31268252574, + 56280729661,8181904909], -2639651053, + 344881152000), + 14:(7, 2501928000, [90241897,710986864,-770720657,3501442784, + -6625093363,12630121616,-16802270373,19534438464, + -16802270373,12630121616,-6625093363,3501442784, + -770720657,710986864,90241897], -3740727473, + 1275983280000) + } + +def newton_cotes(rn,equal=0): + r"""Return weights and error coefficient for Netwon-Cotes integration. + + Suppose we have (N+1) samples of f at the positions + x_0, x_1, ..., x_N. Then an N-point Newton-Cotes formula for the + integral between x_0 and x_N is: + + $\int_{x_0}^{x_N} f(x)dx = \Delta x \sum_{i=0}^{N} a_i f(x_i) + + B_N (\Delta x)^{N+2} f^{N+1} (\xi)$ + + where $\xi \in [x_0,x_N]$ and $\Delta x = \frac{x_N-x_0}{N}$ is the + averages samples spacing. + + If the samples are equally-spaced and N is even, then the error + term is $B_N (\Delta x)^{N+3} f^{N+2}(\xi)$. + + Normally, the Newton-Cotes rules are used on smaller integration + regions and a composite rule is used to return the total integral. + + Inputs: + rn -- the integer order for equally-spaced data + or the relative positions of the samples with + the first sample at 0 and the last at N, where + N+1 is the length of rn. N is the order of the Newt + equal -- Set to 1 to enforce equally spaced data + + Outputs: + an -- 1-d array of weights to apply to the function at + the provided sample positions. + B -- error coefficient + """ + try: + N = len(rn)-1 + if equal: + rn = np.arange(N+1) + elif np.all(np.diff(rn)==1): + equal = 1 + except: + N = rn + rn = np.arange(N+1) + equal = 1 + + if equal and _builtincoeffs.has_key(N): + na, da, vi, nb, db = _builtincoeffs[N] + return na*np.array(vi,float)/da, float(nb)/db + + if (rn[0] != 0) or (rn[-1] != N): + raise ValueError, "The sample positions must start at 0"\ + " and end at N" + yi = rn / float(N) + ti = 2.0*yi - 1 + nvec = np.arange(0,N+1) + C = np.mat(ti**nvec[:,np.newaxis]) + Cinv = C.I + # improve precision of result + Cinv = 2*Cinv - Cinv*C*Cinv + Cinv = 2*Cinv - Cinv*C*Cinv + Cinv = Cinv.A + vec = 2.0/ (nvec[::2]+1) + ai = np.dot(Cinv[:,::2],vec) * N/2 + + if (N%2 == 0) and equal: + BN = N/(N+3.) + power = N+2 + else: + BN = N/(N+2.) + power = N+1 + + BN = BN - np.dot(yi**power, ai) + p1 = power+1 + fac = power*math.log(N) - sp.special.gammaln(p1) + fac = math.exp(fac) + return ai, BN*fac + + +# Should only use if samples are forced on you +def composite(f,x=None,dx=1,axis=-1,n=5): + pass Modified: trunk/Lib/signal/filter_design.py =================================================================== --- trunk/Lib/signal/filter_design.py 2007-01-21 05:05:33 UTC (rev 2582) +++ trunk/Lib/signal/filter_design.py 2007-01-21 09:11:09 UTC (rev 2583) @@ -182,12 +182,10 @@ from a low-pass filter prototype with unity cutoff frequency. """ a,b = map(atleast_1d,(a,b)) - # fixme: this test is not terribly reliable in the face of 0-d arrays which - # tend to get passed in. However, using .flat should work around that - # problem. - if type(wo) is type(a): - wo = wo.flat[0] - wo = float(wo) + try: + wo = float(wo) + except TypeError: + wo = float(wo[0]) d = len(a) n = len(b) M = max((d,n)) @@ -203,11 +201,10 @@ from a low-pass filter prototype with unity cutoff frequency. """ a,b = map(atleast_1d,(a,b)) - # fixme: this test is not terribly reliable in the face of 0-d arrays which - # tend to get passed in. However, using .flat should work around that - # problem. - if type(wo) is type(a): - wo = wo.flat[0] + try: + wo = float(wo) + except TypeError: + wo = float(wo[0]) d = len(a) n = len(b) if wo != 1: @@ -877,8 +874,8 @@ Description: Return the order of the lowest order digital elliptic filter - that loses no more than gpass dB in the passband and has at least gstop dB - attenuation in the stopband. + that loses no more than gpass dB in the passband and has at least + gstop dB attenuation in the stopband. Inputs: @@ -895,9 +892,9 @@ Outputs: (ord, Wn) - ord -- The lowest order for a Chebyshev type II filter that meets specs. - Wn -- The Chebyshev natural frequency for - use with scipy.signal.cheby2 to give the filter. + ord -- The lowest order for an Elliptic (Cauer) filter that meets specs. + Wn -- The natural frequency for use with scipy.signal.ellip + to give the filter. """ wp = atleast_1d(wp) From scipy-svn at scipy.org Sun Jan 21 18:55:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 21 Jan 2007 17:55:08 -0600 (CST) Subject: [Scipy-svn] r2584 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070121235508.7C54139C073@new.scipy.org> Author: pierregm Date: 2007-01-21 17:55:03 -0600 (Sun, 21 Jan 2007) New Revision: 2584 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/tests/test_core.py Log: fixed max/min_fill_value & sort Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-21 09:11:09 UTC (rev 2583) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-21 23:55:03 UTC (rev 2584) @@ -1,3 +1,6 @@ +#2007-01-21 : core : fixed max/min_fill_values +# : : fixed sort (as method and function) +#2007-01-18 : core : fixed default filling values for unsigned int_. #2007-01-16 : extras : new function : `mediff1d` #2007-01-15 : mrecords: new method: `addfield` # : core : Force the mask of a masked array `x` to be copied w/... Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-01-21 09:11:09 UTC (rev 2583) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-21 23:55:03 UTC (rev 2584) @@ -66,6 +66,7 @@ import numpy.core.fromnumeric as fromnumeric from numpy.core.numeric import ndarray from numpy.core.fromnumeric import amax, amin +import numpy.core.numerictypes as ntypes from numpy.core.numerictypes import bool_, typecodes from numpy.core.multiarray import dtype import numpy.core.numeric as numeric @@ -140,16 +141,36 @@ 'i' : 999999, 'O' : '?', 'S' : 'N/A', + 'u' : 999999, 'V' : '???', } -max_filler = {'b': False, - 'f' : -numeric.inf, - 'i' : -sys.maxint, - } -min_filler = {'b' : True, - 'f' : numeric.inf, - 'i' : sys.maxint, - } +#{0: , +# 1: , +# 2: , +# 3: , +# 4: , +# 5: , +# 6: , +# 7: , +# 8: , +# 9: , +# 10: , +# 11: , +# 12: , +# 13: , +# 14: , +# 15: , +# 16: , +# 17: , +# 18: , +# 19: , +# 20: , +max_filler = ntypes._minvals +max_filler.update([(k,-numeric.inf) for k in + [numpy.float32, numpy.float64, numpy.float128]]) +min_filler = ntypes._maxvals +min_filler.update([(k,numeric.inf) for k in + [numpy.float32, numpy.float64, numpy.float128]]) def default_fill_value (obj): @@ -172,33 +193,40 @@ def minimum_fill_value (obj): "Calculates the default fill value suitable for taking the minimum of `obj`." if hasattr(obj, 'dtype'): - objtype = obj.dtype.kind - try: - return min_filler[objtype] - except KeyError: + objtype = obj.dtype + filler = min_filler[objtype] + if filler is None: raise TypeError, 'Unsuitable type for calculating minimum.' + return filler elif isinstance(obj, float): - return min_filler['f'] - elif isinstance(obj, int) or isinstance(obj, long): - return min_filler['i'] + return min_filler[ntypes.typeDict['float_']] + elif isinstance(obj, int): + return min_filler[ntypes.typeDict['int_']] + elif isinstance(obj, long): + return min_filler[ntypes.typeDict['uint']] + elif isinstance(obj, numeric.dtype): + return min_filler[obj] else: raise TypeError, 'Unsuitable type for calculating minimum.' def maximum_fill_value (obj): "Calculates the default fill value suitable for taking the maximum of `obj`." if hasattr(obj, 'dtype'): - objtype = obj.dtype.kind - try: - return max_filler[objtype] - except KeyError: - raise TypeError, 'Unsuitable type for calculating maximum.' + objtype = obj.dtype + filler = max_filler[objtype] + if filler is None: + raise TypeError, 'Unsuitable type for calculating minimum.' + return filler elif isinstance(obj, float): - return max_filler['f'] - elif isinstance(obj, int) or isinstance(obj, long): - #TODO: Check what happens to 'UnsignedInteger'! - return max_filler['i'] + return max_filler[ntypes.typeDict['float_']] + elif isinstance(obj, int): + return max_filler[ntypes.typeDict['int_']] + elif isinstance(obj, long): + return max_filler[ntypes.typeDict['uint']] + elif isinstance(obj, numeric.dtype): + return max_filler[obj] else: - raise TypeError, 'Unsuitable type for calculating maximum.' + raise TypeError, 'Unsuitable type for calculating minimum.' def set_fill_value (a, fill_value): "Sets the fill value of `a` if it is a masked array." @@ -896,7 +924,6 @@ cls._defaultmask = mask # logging.debug("__new__ returned %s as %s" % (type(_data), cls)) return numeric.asanyarray(_data).view(cls) - #.................................. def __array_wrap__(self, obj, context=None): """Special hook for ufuncs. @@ -904,9 +931,10 @@ """ # mclass = self.__class__ #.......... -# logging.debug("__wrap__ received %s" % type(obj)) +# logging.debug("__wrap__ received %s w/ context:%ss" % (type(obj),context)) if context is None: # return mclass(obj, mask=self._mask, copy=False) +# logging.debug("__wrap__ received nocontext") return MaskedArray(obj, mask=self._mask, copy=False, dtype=obj.dtype, fill_value=self.fill_value, ) @@ -927,6 +955,7 @@ if m.shape != dshape: m = reduce(mask_or, [getmaskarray(arg) for arg in args]) # return mclass(obj, copy=False, mask=m) +# logging.debug("__wrap__ context %s" % context) return MaskedArray(obj, copy=False, mask=m,) # dtype=obj.dtype, fill_value=self._fill_value) #........................ @@ -938,6 +967,9 @@ # logging.debug("__finalize__ received %s" % type(obj)) if isinstance(obj, MaskedArray): # We came here from a MaskedArray +# logging.debug("__finalize__ recieved data %s" % obj) +# logging.debug("__finalize__ recieved data._data %s" % obj._data) +# logging.debug("__finalize__ recieved data.base %s" % obj.base) self._data = obj._data self._mask = obj._mask self._hardmask = obj._hardmask @@ -1851,6 +1883,59 @@ if axis is None: return d.argmax() return d.argmax(axis) + + def sort(self, axis=-1, kind='quicksort', order=None, endwith=True): + """ + Sort a along the given axis. + + Keyword arguments: + + axis -- axis to be sorted (default -1) + kind -- sorting algorithm (default 'quicksort') + Possible values: 'quicksort', 'mergesort', or 'heapsort'. + order -- If a has fields defined, then the order keyword can be the + field name to sort on or a list (or tuple) of field names + to indicate the order that fields should be used to define + the sort. + endwith--Boolean flag indicating whether missing values (if any) should + be forced in the upper indices (at the end of the array) or + lower indices (at the beginning). + + Returns: None. + + This method sorts 'a' in place along the given axis using the algorithm + specified by the kind keyword. + + The various sorts may characterized by average speed, worst case + performance, need for work space, and whether they are stable. A stable + sort keeps items with the same key in the same relative order and is most + useful when used with argsort where the key might differ from the items + being sorted. The three available algorithms have the following properties: + + |------------------------------------------------------| + | kind | speed | worst case | work space | stable| + |------------------------------------------------------| + |'quicksort'| 1 | O(n^2) | 0 | no | + |'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes | + |'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 endwith: + filler = minimum_fill_value(self.dtype) + else: + filler = maximum_fill_value(self.dtype) + indx = self.filled(filler).argsort(axis=axis,kind=kind,order=order) + self._data = self._data[indx] + m = self._mask + if m is not nomask: + self._mask = m[indx] + return #............................................ # Backwards Compatibility. Heck... @property @@ -2494,6 +2579,55 @@ return d.argmax(axis=None) return d.argmax(axis=axis) +def sort(a, axis=-1, kind='quicksort', order=None, endwith=True): + """ + Sort a along the given axis. + +Keyword arguments: + +axis -- axis to be sorted (default -1) +kind -- sorting algorithm (default 'quicksort') + Possible values: 'quicksort', 'mergesort', or 'heapsort'. +order -- If a has fields defined, then the order keyword can be the + field name to sort on or a list (or tuple) of field names + to indicate the order that fields should be used to define + the sort. +endwith--Boolean flag indicating whether missing values (if any) should + be forced in the upper indices (at the end of the array) or + lower indices (at the beginning). + +Returns: None. + +This method sorts 'a' in place along the given axis using the algorithm +specified by the kind keyword. + +The various sorts may characterized by average speed, worst case +performance, need for work space, and whether they are stable. A stable +sort keeps items with the same key in the same relative order and is most +useful when used with argsort where the key might differ from the items +being sorted. The three available algorithms have the following properties: + +|------------------------------------------------------| +| kind | speed | worst case | work space | stable| +|------------------------------------------------------| +|'quicksort'| 1 | O(n^2) | 0 | no | +|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes | +|'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. + +""" + a = numeric.asanyarray(a) + if endwith: + filler = minimum_fill_value(a) + else: + filler = maximum_fill_value(a) + indx = filled(a,filler).argsort(axis=axis,kind=kind,order=order) + return a[indx] + def compressed(x): """Returns a compressed version of a masked array (or just the array if it wasn't masked first).""" @@ -2679,23 +2813,6 @@ m = make_mask(mask_or(m, getmask(indices)), copy=0, small_mask=1) return masked_array(d, mask=m) -def sort (x, axis=-1, fill_value=None, kind='quicksort'): - """If x does not have a mask, returns a masked array formed from the - result of numeric.sort(x, axis). - Otherwise, fills x with fill_value. Sort it. Sets a mask where the result - is equal to fill_value. Note that this may have unintended consequences - if the data contains the fill value at a non-masked site. - If fill_value is not given the default fill value for x's type will be - used. - """ - if fill_value is None: - fill_value = default_fill_value (x) - d = filled(x, fill_value) - s = fromnumeric.sort(d, axis=axis, kind=kind) - if getmask(x) is nomask: - return masked_array(s) - return masked_values(s, fill_value, copy=0) - def round_(a, decimals=0, out=None): """Returns reference to result. Copies a and rounds to 'decimals' places. @@ -2895,4 +3012,4 @@ MaskedArray.__dump__ = dump MaskedArray.__dumps__ = dumps - +################################################################################ Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-01-21 09:11:09 UTC (rev 2583) +++ trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-01-21 23:55:03 UTC (rev 2584) @@ -233,7 +233,7 @@ x4 = array(x1) # test conversion to strings junk, garbage = str(x2), repr(x2) - assert_equal(N.sort(x1),sort(x2, fill_value=0)) + assert_equal(N.sort(x1),sort(x2,endwith=False)) # tests of indexing assert type(x2[1]) is type(x1[1]) assert x1[1] == x2[1] @@ -1027,6 +1027,39 @@ xh[0:1] = 999 assert_equal(xh._data,[999,1,2,3,4]) + + def check_sort(self): + "Test sort" + x = array([1,4,2,3],mask=[0,1,0,0],dtype=N.uint8) + # + sortedx = sort(x) + assert_equal(sortedx._data,[1,2,3,4]) + assert_equal(sortedx._mask,[0,0,0,1]) + # + sortedx = sort(x, endwith=False) + assert_equal(sortedx._data, [4,1,2,3]) + assert_equal(sortedx._mask, [1,0,0,0]) + # + x.sort() + assert_equal(x._data,[1,2,3,4]) + assert_equal(x._mask,[0,0,0,1]) + # + x = array([1,4,2,3],mask=[0,1,0,0],dtype=N.uint8) + x.sort(endwith=False) + assert_equal(x._data, [4,1,2,3]) + assert_equal(x._mask, [1,0,0,0]) + # + x = [1,4,2,3] + sortedx = sort(x) + assert(not isinstance(sorted, MaskedArray)) + # + x = array([0,1,-1,-2,2], mask=nomask, dtype=N.int8) + sortedx = sort(x, endwith=False) + assert_equal(sortedx._data, [-2,-1,0,1,2]) + x = array([0,1,-1,-2,2], mask=[0,1,0,0,1], dtype=N.int8) + sortedx = sort(x, endwith=False) + assert_equal(sortedx._data, [1,2,-2,-1,0]) + assert_equal(sortedx._mask, [1,1,0,0,0]) #.............................................................................. #.............................................................................. From scipy-svn at scipy.org Mon Jan 22 10:28:18 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 22 Jan 2007 09:28:18 -0600 (CST) Subject: [Scipy-svn] r2585 - trunk/Lib/sandbox/timeseries Message-ID: <20070122152818.3DF5239C0D5@new.scipy.org> Author: mattknox_ca Date: 2007-01-22 09:28:14 -0600 (Mon, 22 Jan 2007) New Revision: 2585 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: changed fmtObserv so that the large representation is always return for a given observed string Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-21 23:55:03 UTC (rev 2584) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-22 15:28:14 UTC (rev 2585) @@ -42,6 +42,14 @@ #####--------------------------------------------------------------------------- #---- --- Option conversion --- #####--------------------------------------------------------------------------- +fmtobs_dict = {'UNDEF': ['UNDEF','UNDEFINED'], + 'BEGINNING': ['BEGIN','BEGINNING'], + 'ENDING': ['END','ENDING'], + 'AVERAGED': ['AVERAGE','AVERAGE','MEAN'], + 'SUMMED': ['SUM','SUMMED'], + 'MAXIMUM': ['MAX','MAXIMUM','HIGH'], + 'MINIMUM': ['MIN','MINIMUM','LOW']} + obs_dict = {"UNDEFINED":None, "UNDEF":None, "BEGIN": first_unmasked_val, @@ -59,13 +67,15 @@ "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 None - elif obStr.upper() in obs_dict.keys(): - return obStr.upper() + elif obStr.upper() in fmtobs_revdict: + return fmtobs_revdict[obStr.upper()] else: raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) From scipy-svn at scipy.org Mon Jan 22 10:30:39 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 22 Jan 2007 09:30:39 -0600 (CST) Subject: [Scipy-svn] r2586 - trunk/Lib/sandbox/timeseries Message-ID: <20070122153039.1F52E39C0D5@new.scipy.org> Author: mattknox_ca Date: 2007-01-22 09:30:37 -0600 (Mon, 22 Jan 2007) New Revision: 2586 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: changed undef to undefined in fmtobs_dict key Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-22 15:28:14 UTC (rev 2585) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-22 15:30:37 UTC (rev 2586) @@ -42,7 +42,7 @@ #####--------------------------------------------------------------------------- #---- --- Option conversion --- #####--------------------------------------------------------------------------- -fmtobs_dict = {'UNDEF': ['UNDEF','UNDEFINED'], +fmtobs_dict = {'UNDEFINED': ['UNDEF','UNDEFINED'], 'BEGINNING': ['BEGIN','BEGINNING'], 'ENDING': ['END','ENDING'], 'AVERAGED': ['AVERAGE','AVERAGE','MEAN'], From scipy-svn at scipy.org Mon Jan 22 16:16:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 22 Jan 2007 15:16:00 -0600 (CST) Subject: [Scipy-svn] r2587 - trunk/Lib/sandbox/timeseries Message-ID: <20070122211600.7698E39C068@new.scipy.org> Author: mattknox_ca Date: 2007-01-22 15:15:50 -0600 (Mon, 22 Jan 2007) New Revision: 2587 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: fixed problem with DateArray __getitem__ method which wouldn't let a DateArray instance be used as the data in a masked array Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-22 15:30:37 UTC (rev 2586) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-22 21:15:50 UTC (rev 2587) @@ -13,6 +13,7 @@ import datetime import itertools import warnings +import types import numpy @@ -541,7 +542,11 @@ except AttributeError: pass r = ndarray.__getitem__(self, index) - if r.size == 1: + + if not hasattr(r, "size"): + if type(r) == types.IntType: return Date(self.freq, value=r) + else: return r + elif r.size == 1: # Only one element, and it's not a scalar: we have a DateArray of size 1 if len(r.shape) > 0: r = r.item() From scipy-svn at scipy.org Mon Jan 22 16:29:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 22 Jan 2007 15:29:54 -0600 (CST) Subject: [Scipy-svn] r2588 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070122212954.11E2F39C068@new.scipy.org> Author: mattknox_ca Date: 2007-01-22 15:29:50 -0600 (Mon, 22 Jan 2007) New Revision: 2588 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added test for using DateArray as the data in a TimeSeries Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-22 21:15:50 UTC (rev 2587) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-22 21:29:50 UTC (rev 2588) @@ -19,6 +19,7 @@ from numpy.testing.utils import build_err_msg import maskedarray +import maskedarray as MA from maskedarray import masked_array, masked, nomask import maskedarray.testutils @@ -70,6 +71,26 @@ assert_equal(series._dates, dates) assert_equal(series.freq, 'D') + + def test_fromdatearray(self): + _, dates, _ = self.d + data = dates.copy() + data = dates + + series = time_series(data, dates) + assert(isinstance(series, TimeSeries)) + assert_equal(series._dates, dates) + assert_equal(series._data, data) + assert_equal(series.freq, '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) + + def test_datafromlist(self): (_, dates, _) = self.d data = list(range(15)) From scipy-svn at scipy.org Mon Jan 22 20:09:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 22 Jan 2007 19:09:10 -0600 (CST) Subject: [Scipy-svn] r2589 - in trunk/Lib: io sandbox/xplt Message-ID: <20070123010910.EB1BA39C117@new.scipy.org> Author: matthew.brett at gmail.com Date: 2007-01-22 19:08:11 -0600 (Mon, 22 Jan 2007) New Revision: 2589 Added: trunk/Lib/io/fopen.py Modified: trunk/Lib/io/__init__.py trunk/Lib/sandbox/xplt/Graphics.py Log: Added back fopen class pending discussion, modified xplt to use ndarray constructor instead of fopen, eliminating use of fopen in scipy distribution Modified: trunk/Lib/io/__init__.py =================================================================== --- trunk/Lib/io/__init__.py 2007-01-22 21:29:50 UTC (rev 2588) +++ trunk/Lib/io/__init__.py 2007-01-23 01:08:11 UTC (rev 2589) @@ -8,6 +8,7 @@ from numpyio import packbits, unpackbits, bswap, fread, fwrite, \ convert_objectarray from mio import * +from fopen import * from recaster import sctype_attributes, Recaster from array_import import * from data_store import * Added: trunk/Lib/io/fopen.py =================================================================== --- trunk/Lib/io/fopen.py 2007-01-22 21:29:50 UTC (rev 2588) +++ trunk/Lib/io/fopen.py 2007-01-23 01:08:11 UTC (rev 2589) @@ -0,0 +1,357 @@ +## Automatically adapted for scipy Oct 05, 2005 by convertcode.py + +# Author: Travis Oliphant + +import struct, os, sys +import types + +from numpy import * +import numpyio + +LittleEndian = (sys.byteorder == 'little') + +_unit_imag = {'f': array(1j,'F'), 'd': 1j} + +__all__ = ['fopen'] + +def getsize_type(mtype): + if mtype in ['B','uchar','byte','unsigned char','integer*1', 'int8']: + mtype = 'B' + elif mtype in ['S1', 'char', 'char*1']: + mtype = 'B' + elif mtype in ['b', 'schar', 'signed char']: + mtype = 'b' + elif mtype in ['h','short','int16','integer*2']: + mtype = 'h' + elif mtype in ['H','ushort','uint16','unsigned short']: + mtype = 'H' + elif mtype in ['i','int']: + mtype = 'i' + elif mtype in ['I','uint','uint32','unsigned int']: + mtype = 'I' + elif mtype in ['u4','int32','integer*4']: + mtype = 'u4' + elif mtype in ['f','float','float32','real*4', 'real']: + mtype = 'f' + elif mtype in ['d','double','float64','real*8', 'double precision']: + mtype = 'd' + elif mtype in ['F','complex float','complex*8','complex64']: + mtype = 'F' + elif mtype in ['D','complex*16','complex128','complex','complex double']: + mtype = 'D' + else: + mtype = obj2sctype(mtype) + + newarr = empty((1,),mtype) + return newarr.itemsize, newarr.dtype.char + +class fopen(object): + """Class for reading and writing binary files into numpy arrays. + + Inputs: + + file_name -- The complete path name to the file to open. + permission -- Open the file with given permissions: ('r', 'H', 'a') + for reading, writing, or appending. This is the same + as the mode argument in the builtin open command. + format -- The byte-ordering of the file: + (['native', 'n'], ['ieee-le', 'l'], ['ieee-be', 'B']) for + native, little-endian, or big-endian respectively. + + Attributes (Read only): + + bs -- non-zero if byte-swapping is performed on read and write. + format -- 'native', 'ieee-le', or 'ieee-be' + closed -- non-zero if the file is closed. + mode -- permissions with which this file was opened + name -- name of the file + """ + +# Methods: +# +# read -- read data from file and return numpy array +# write -- write to file from numpy array +# fort_read -- read Fortran-formatted binary data from the file. +# fort_write -- write Fortran-formatted binary data to the file. +# rewind -- rewind to beginning of file +# size -- get size of file +# seek -- seek to some position in the file +# tell -- return current position in file +# close -- close the file + + def __init__(self,file_name,permission='rb',format='n'): + if 'b' not in permission: permission += 'b' + if isinstance(file_name, basestring): + self.file = file(file_name, permission) + elif isinstance(file_name, file) and not file_name.closed: + # first argument is an open file + self.file = file_name + else: + raise TypeError, 'Need filename or open file as input' + self.setformat(format) + + def __del__(self): + try: + self.file.close() + except: + pass + + def close(self): + self.file.close() + + def seek(self, *args): + self.file.seek(*args) + + def tell(self): + return self.file.tell() + + def raw_read(self, size=-1): + """Read raw bytes from file as string.""" + return self.file.read(size) + + def raw_write(self, str): + """Write string to file as raw bytes.""" + return self.file.write(str) + + def setformat(self, format): + """Set the byte-order of the file.""" + if format in ['native','n','default']: + self.bs = False + self.format = 'native' + elif format in ['ieee-le','l','little-endian','le']: + self.bs = not LittleEndian + self.format = 'ieee-le' + elif format in ['ieee-be','B','big-endian','be']: + self.bs = LittleEndian + self.format = 'ieee-be' + else: + raise ValueError, "Unrecognized format: " + format + return + + def write(self,data,mtype=None,bs=None): + """Write to open file object the flattened numpy array data. + + Inputs: + + data -- the numpy array to write. + mtype -- a string indicating the binary type to write. + The default is the type of data. If necessary a cast is made. + unsigned byte : 'B', 'uchar', 'byte' 'unsigned char', 'int8', + 'integer*1' + character : 'S1', 'char', 'char*1' + signed char : 'b', 'schar', 'signed char' + short : 'h', 'short', 'int16', 'integer*2' + unsigned short : 'H', 'ushort','uint16','unsigned short' + int : 'i', 'int' + unsigned int : 'I', 'uint32','uint','unsigned int' + int32 : 'u4', 'int32', 'integer*4' + float : 'f', 'float', 'float32', 'real*4' + double : 'd', 'double', 'float64', 'real*8' + complex float : 'F', 'complex float', 'complex*8', 'complex64' + complex double : 'D', 'complex', 'complex double', 'complex*16', + 'complex128' + """ + if bs is None: + bs = self.bs + else: + bs = (bs == 1) + if isinstance(data, str): + N, buf = len(data), buffer(data) + data = ndarray(shape=(N,),dtype='B',buffer=buf) + else: + data = asarray(data) + if mtype is None: + mtype = data.dtype.char + howmany,mtype = getsize_type(mtype) + count = product(data.shape,axis=0) + numpyio.fwrite(self.file,count,data,mtype,bs) + return + + fwrite = write + + def read(self,count,stype,rtype=None,bs=None,c_is_b=0): + """Read data from file and return it in a numpy array. + + Inputs: + + count -- an integer specifying the number of elements of type + stype to read or a tuple indicating the shape of + the output array. + stype -- The data type of the stored data (see fwrite method). + rtype -- The type of the output array. Same as stype if None. + bs -- Whether or not to byteswap (or use self.bs if None) + c_is_b --- If non-zero then the count is an integer + specifying the total number of bytes to read + (must be a multiple of the size of stype). + + Outputs: (output,) + + output -- a numpy array of type rtype. + """ + if bs is None: + bs = self.bs + else: + bs = (bs == 1) + howmany,stype = getsize_type(stype) + shape = None + if c_is_b: + if count % howmany != 0: + raise ValueError, "When c_is_b is non-zero then " \ + "count is bytes\nand must be multiple of basic size." + count = count / howmany + elif type(count) in [types.TupleType, types.ListType]: + shape = list(count) + # allow -1 to specify unknown dimension size as in reshape + minus_ones = shape.count(-1) + if minus_ones == 0: + count = product(shape,axis=0) + elif minus_ones == 1: + now = self.tell() + self.seek(0,2) + end = self.tell() + self.seek(now) + remaining_bytes = end - now + know_dimensions_size = -product(count,axis=0) * getsize_type(stype)[0] + unknown_dimension_size, illegal = divmod(remaining_bytes, + know_dimensions_size) + if illegal: + raise ValueError("unknown dimension doesn't match filesize") + shape[shape.index(-1)] = unknown_dimension_size + count = product(shape,axis=0) + else: + raise ValueError( + "illegal count; can only specify one unknown dimension") + shape = tuple(shape) + if rtype is None: + rtype = stype + else: + howmany,rtype = getsize_type(rtype) + if count == 0: + return zeros(0,rtype) + retval = numpyio.fread(self.file, count, stype, rtype, bs) + if shape is not None: + retval = resize(retval, shape) + return retval + + fread = read + + def rewind(self,howmany=None): + """Rewind a file to its beginning or by a specified amount. + """ + if howmany is None: + self.seek(0) + else: + self.seek(-howmany,1) + + def size(self): + """Return the size of the file. + """ + try: + sz = self.thesize + except AttributeError: + curpos = self.tell() + self.seek(0,2) + sz = self.tell() + self.seek(curpos) + self.thesize = sz + return sz + + def fort_write(self,fmt,*args): + """Write a Fortran binary record. + + Inputs: + + fmt -- If a string then it represents the same format string as + used by struct.pack. The remaining arguments are passed + to struct.pack. + + If fmt is an array, then this array will be written as + a Fortran record using the output type args[0]. + + *args -- Arguments representing data to write. + """ + if self.format == 'ieee-le': + nfmt = " 0: + sz,mtype = getsize_type(args[0]) + else: + sz,mtype = getsize_type(fmt.dtype.char) + count = product(fmt.shape,axis=0) + strlen = struct.pack(nfmt,count*sz) + self.write(strlen) + numpyio.fwrite(self.file,count,fmt,mtype,self.bs) + self.write(strlen) + else: + raise TypeError, "Unknown type in first argument" + + def fort_read(self,fmt,dtype=None): + """Read a Fortran binary record. + + Inputs: + + fmt -- If dtype is not given this represents a struct.pack + format string to interpret the next record. Otherwise this + argument is ignored. + dtype -- If dtype is not None, then read in the next record as + an array of type dtype. + + Outputs: (data,) + + data -- If dtype is None, then data is a tuple containing the output + of struct.unpack on the next Fortan record. + If dtype is a datatype string, then the next record is + read in as a 1-D array of type datatype. + """ + lookup_dict = {'ieee-le':"<",'ieee-be':">",'native':''} + if dtype is None: + fmt = lookup_dict[self.format] + fmt + numbytes = struct.calcsize(fmt) + nn = struct.calcsize("i"); + if (self.raw_read(nn) == ''): + raise ValueError, "Unexpected end of file..." + strdata = self.raw_read(numbytes) + if strdata == '': + raise ValueError, "Unexpected end of file..." + data = struct.unpack(fmt,strdata) + if (self.raw_read(nn) == ''): + raise ValueError, "Unexpected end of file..." + return data + else: # Ignore format string and read in next record as an array. + fmt = lookup_dict[self.format] + "i" + nn = struct.calcsize(fmt) + nbytestr = self.raw_read(nn) + if nbytestr == '': + raise ValueError, "Unexpected end of file..." + nbytes = struct.unpack(fmt,nbytestr)[0] + howmany, dtype = getsize_type(dtype) + ncount = nbytes / howmany + if ncount*howmany != nbytes: + self.rewind(4) + raise ValueError, "A mismatch between the type requested and the data stored." + if ncount < 0: + raise ValueError, "Negative number of bytes to read:\n file is probably not opened with correct endian-ness." + if ncount == 0: + raise ValueError, "End of file? Zero-bytes to read." + retval = numpyio.fread(self.file, ncount, dtype, dtype, self.bs) + if len(retval) == 1: + retval = retval[0] + if (self.raw_read(nn) == ''): + raise ValueError, "Unexpected end of file..." + return retval + + Modified: trunk/Lib/sandbox/xplt/Graphics.py =================================================================== --- trunk/Lib/sandbox/xplt/Graphics.py 2007-01-22 21:29:50 UTC (rev 2588) +++ trunk/Lib/sandbox/xplt/Graphics.py 2007-01-23 01:08:11 UTC (rev 2589) @@ -1,22 +1,29 @@ +import os +import types + #import Tkinter #from Tkinter import * #from Scientific.TkWidgets.TkPlotCanvas import * + from scipy import * from numpy.core.umath import * + #from _Graphics import * #import PIL.ImageTk,PIL.Image #ImageTk = PIL.ImageTk #Image = PIL.Image -import gist, types, string, os + +# Local imports +import gist import Mplot -import scipy.io as io - def read_act(filename): - fid = io.fopen('%s.act'%filename) - p = fid.fread(256*3,'byte') + fid = open('%s.act'%filename, 'rb') + p = ndarray(shape=(256,3), + dtype='u1', + buffer=fid.read(256*3), + ).copy() fid.close() - p.shape = (256,3) return p Palette = {} From scipy-svn at scipy.org Tue Jan 23 00:45:46 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 22 Jan 2007 23:45:46 -0600 (CST) Subject: [Scipy-svn] r2590 - trunk/Lib/sandbox/maskedarray Message-ID: <20070123054546.B249539C120@new.scipy.org> Author: pierregm Date: 2007-01-22 23:45:43 -0600 (Mon, 22 Jan 2007) New Revision: 2590 Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG trunk/Lib/sandbox/maskedarray/core.py Log: cf changelog Modified: trunk/Lib/sandbox/maskedarray/CHANGELOG =================================================================== --- trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-23 01:08:11 UTC (rev 2589) +++ trunk/Lib/sandbox/maskedarray/CHANGELOG 2007-01-23 05:45:43 UTC (rev 2590) @@ -1,3 +1,4 @@ +#2007-01-22 : core : fixed a call to numpy.float128 on 32b machines #2007-01-21 : core : fixed max/min_fill_values # : : fixed sort (as method and function) #2007-01-18 : core : fixed default filling values for unsigned int_. Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-01-23 01:08:11 UTC (rev 2589) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-23 05:45:43 UTC (rev 2590) @@ -165,12 +165,13 @@ # 18: , # 19: , # 20: , -max_filler = ntypes._minvals -max_filler.update([(k,-numeric.inf) for k in - [numpy.float32, numpy.float64, numpy.float128]]) +max_filler = ntypes._minvals +max_filler.update([(k,-numeric.inf) for k in [numpy.float32, numpy.float64]]) min_filler = ntypes._maxvals -min_filler.update([(k,numeric.inf) for k in - [numpy.float32, numpy.float64, numpy.float128]]) +min_filler.update([(k,numeric.inf) for k in [numpy.float32, numpy.float64]]) +if 'float128' in ntypes.typeDict: + max_filler.update([(numpy.float128,-numeric.inf)]) + min_filler.update([(numpy.float128, numeric.inf)]) def default_fill_value (obj): @@ -1173,6 +1174,9 @@ if m.shape == () and m: return str(f) # convert to object array to make filled work +#CHECK: the two lines below seem more robust than the self._data.astype +# res = numeric.empty(self._data.shape, object_) +# numeric.putmask(res,~m,self._data) res = self._data.astype("|O8") res[self._mask] = f else: From scipy-svn at scipy.org Tue Jan 23 03:21:39 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 02:21:39 -0600 (CST) Subject: [Scipy-svn] r2591 - in trunk/Lib/sandbox/timeseries: . examples Message-ID: <20070123082139.9FCBF39C014@new.scipy.org> Author: pierregm Date: 2007-01-23 02:21:33 -0600 (Tue, 23 Jan 2007) New Revision: 2591 Added: trunk/Lib/sandbox/timeseries/examples/example.wiki Modified: trunk/Lib/sandbox/timeseries/examples/example.py trunk/Lib/sandbox/timeseries/readme.txt trunk/Lib/sandbox/timeseries/tdates.py Log: update readme & example Modified: trunk/Lib/sandbox/timeseries/examples/example.py =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-23 05:45:43 UTC (rev 2590) +++ trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-23 08:21:33 UTC (rev 2591) @@ -1,290 +1,52 @@ - -""" -=== TimeSeries === - -A TimeSeries object is the combination of three ndarrays: - - - `dates`: DateArray object. - - `data` : ndarray. - - `mask` : Boolean ndarray, indicating missing or invalid data. - - -==== Construction ==== - -To construct a TimeSeries, you can use the class constructor: - ->>> TimeSeries(data, dates=None, mask=nomask, - freq=None, observed=None, start_date=None, - dtype=None, copy=False, fill_value=None, - keep_mask=True, small_mask=True, hard_mask=False) - -where `data` is a sequence. -If `dates` is None, a DateArray of the same length as the data is constructed at -a `freq` frequency, starting at `start_date`. - -Alternatively, you can use the `time_series` function: - - -time_series(data, dates=None, freq=None, - start_date=None, end_date=None, length=None, include_last=True, - mask=nomask, dtype=None, copy=False, fill_value=None, - keep_mask=True, small_mask=True, hard_mask=False) - - -Let us construct a series of 600 random elements, starting 600 business days ago, -at a business daily frequency - ->>> import numpy as np ->>> import tseries as ts ->>> import tsdate as td ->>> data = np.random.uniform(-100,100,600) ->>> today = td.thisday('B') ->>> series = ts.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', - start_date=today-600) - -Let us set negative values to zero... - ->>> series[series<0] = 0 - -... and the values falling on Fridays to 100 ->>> series[series.day_of_week == 4] = 100 - -Note that we could also create a temporary array of 'day_of weeks' for the -corresponding period, and use it as condition. - ->>> weekdays = td.day_of_week(series) ->>> series[weekdays == 4] = 100 - -==== Slicing ==== - -Accessing elements of a TimeSeries works just like slicing ->>> series[-30:] - -But you can also use a date: ->>> thirtydaysago = today-30 ->>> series[thirtydaysago:] - -Or even a string ->>> series[thirtydaysago.tostring():] - - -==== Conversions ==== - -To convert a TimeSeries to another frequency, use the `convert` method or function. -The optional argument `func` must be a function that acts on a 1D masked array -and returns a scalar. - ->>> mSer1 = series.convert('M',func=ma.average) - -If `func` is not specified, the default value `'auto'` is used instead. In that case, -the conversion function is estimated from the `observed` attribute of the series. -For example, if `observed='SUMMED'`, then `func='auto'` is in fact `func=sum`. - ->>> mSer1_default = series.convert('M') - -If `func` is None, the convert method/function returns a 2D array, where each row -corresponds to the new frequency, and the columns to the original data. In our -example, convert will return a 2D array with 23 columns, as there are at most -23 business days per month. - ->>> mSer1_2d = series.convert('M',func=None) - -When converting from a lower frequency to a higher frequency, an extra argument -`position` is required. The value of the argument is either 'START' or 'END', -and determines where the data point will be placed in the -period. In the future, interpolation methods will be supported to fill in the -resulting masked values. - -Let us create a second series, this time with a monthly frequency, starting 110 -months ago. ->>> data = np.random.uniform(-100,100,100).astype(np.float_) ->>> today = today.asfreq('M') - 110 ->>> mSer2 = ts.TimeSeries(data, freq='m', observed='END',start_date=today) ->>> sixtymonthsago = today-60 ->>> mSer2[sixtymonthsago:sixtymonthsago+10] = 12 - -""" -import numpy as np -import tseries as ts -reload(ts) -import tsdate as td -reload(td) -#from numpy import ma -import maskedarray as ma - -data = np.random.uniform(-100,100,600) -today = td.thisday('B') -series = ts.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', +import numpy as N +import maskedarray as MA +import tseries as TS +import tdates as TD +D = TD.Date(freq='D', year=2007, month=1, day=1) +M = TD.Date(freq='M', year=2007, month=1, day=1) +Y = TD.Date(freq='A', year=2007, month=1, day=1) +TD.Date(freq='Q',year=2004,quarter=3) +TD.Date(freq='D',year=2001,month=1,day=1) +TD.Date('D', '2007-01-01') +TD.Date('D', mxDate=mx.DateTime.now()) +TD.Date('D', mxDate=datetime.datetime.now()) +data = N.random.uniform(-100,100,600) +today = TD.thisday('B') +series = TS.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', start_date=today-600) -series[series < 0] = 0 - -#WARNING: The ORIGINAL day_of_week version seemed bugged. -#It told me that 2006/12/28 was a Friday. +series[0] +series[-30:] +thirtydaysago = today - 30 +series[thirtydaysago:] +series[thirtydaysago.tostring():] +series[series<0] = 0 +series[series.day_of_week == 4] = 100 weekdays = td.day_of_week(series) series[weekdays == 4] = 100 - -mSer1 = series.convert('M',func=ma.average) -mSer1_2d = series.convert('M',func=None) -mSer1_default = series.convert('M') -mToB = series.convert('M',position='START') - - -# Create another monthly frequency series -data = np.random.uniform(-100,100,100).astype(np.float_) -today = today.asfreq('M') - 110 -mSer2 = ts.TimeSeries(data, freq='m', observed='END',start_date=today) +series_log = N.log(series) +mlist_1 = ['2005-%02i' % i for i in range(1,10)] +mlist_1 += ['2006-%02i' % i for i in range(2,13)] +mdata_1 = N.arange(len(mlist_1)) +mser_1 = TS.time_series(mdata_1, mlist_1, observed='SUMMED') +mser = mser1.asfreq('M') +mser1.has_duplicated_dates() +mser1.has_missing_dates() +mlist_2 = ['2004-%02i' % i for i in range(1,13)] +mlist_2 += ['2005-%02i' % i for i in range(1,13)] +mser_2 = TS.time_series(N.arange(len(mlist_2)), mlist_2, observed='SUMMED') +mser_3 = mser_1 + mser_2 +(malg_1,malg_2) = aligned(mser_1, mser_2) +mser_1_filled = fill_missing_dates(mser_1) +(malg_1,malg_2) = align_series(mser_1_filled, mser_2) +mser_3 = malg_1 + malg_2 +mser_3 = filled(malg_1,0) + filled(malg_2,0) +(malg_1,malg_2) = aligned(mser_1_filled, mser2, + start_date='2004-06', end_date='2006-06') +mseries = series.convert('M',func=ma.average) +mseries_default = series.convert('M') +mseries_2d = series.convert('M',func=None) +data = N.random.uniform(-100,100,100).astype(np.float_) +today = TS.today.asfreq('M') - 110 +nseries = TS.TimeSeries(data, freq='m', observed='END',start_date=today) sixtymonthsago = today-60 -mSer2[sixtymonthsago:sixtymonthsago+10] = 12 - - -""" -==== Operations on TimeSeries ==== - -If you work with only one TimeSeries, you can use regular commands to process -the data. For example: - ->>> mSer2_log = np.log(mSer2) - -Note that invalid values (negative, in that case), are automatically masked. -Note as well that trying to use the maskedarray command directly is unlikely to -work: you would end up with a regular MaskedArray. - -When working with multiple series, only series of the same frequency, size and -starting date can be used in basic operations. The function `align_series` forces -series to have matching starting and ending dates. By default, the starting date -will be set to the smallest starting date of the series, and the ending date to -the largest. [An alias to `align_series` is aligned] - -Let's construct a list of months, starting on Jan 2005 and ending on Dec 2006, -with a gap from Oct 2005 to Dec 2006. - ->>> mlist = ['2005-%02i' % i for i in range(1,10)] ->>> mlist += ['2006-%02i' % i for i in range(2,13)] ->>> mdata = numpy.arange(len(mlist)) ->>> mser1 = time_series(mdata, mlist, observed='SUMMED') - -Note that the frequency is 'U', for undefined. In fact, you have to specify what -kind of data is actually missing by forcing a given frequency. - ->>> mser1 = mser1.asfreq('M') - -Let us check whether there are some duplicated dates (no): - ->>> mser1.has_duplicated_dates() - -...or missing dates (yes): - ->>> mser1.has_missing_dates() - -Let us construct a second monthly series, this time without missing dates - ->>> mlist2 = ['2004-%02i' % i for i in range(1,13)] ->>> mlist2 += ['2005-%02i' % i for i in range(1,13)] ->>> mser2 = time_series(mdata, mlist2, observed='SUMMED') - -Let's try to add the two series: - ->>> mser3 = mser1 + mser2 - -That doesn't work, as the series have different starting dates. We need to align -them first. - ->>> (malg1,malg2) = aligned(mser1, mser2) - -That still doesnt' work, as `malg1` has missing dates. Let us fill it, then: -data falling on a date that was missing will be masked. - ->>> mser1_filled = fill_missing_dates(mser1) ->>> (malg1,malg2) = align_series(mser1_filled, mser2) - -Now we can add the two series. Only the data that fall on dates common to the -original, non-aligned series will be actually added, the others will be masked. -After all, we are adding masked arrays. - ->>> mser3 = malg1 + malg2 - -We could have filled the initial series first: ->>> mser3 = filled(malg1,0) + filled(malg2,0) - -Alternatively, we can force the series to start/end at some given dates - ->>> (malg1,malg2) = aligned(mser1_filled, mser2, ->>> start_date='2004-06', end_date='2006-06') - -""" -mlist = ['2005-%02i' % i for i in range(1,10)] -mlist += ['2006-%02i' % i for i in range(2,13)] -mdata = np.arange(len(mlist)) -mser1 = ts.time_series(mdata, mlist, observed='SUMMED') -mser1 = mser1.asfreq('M') -# -mlist2 = ['2004-%02i' % i for i in range(1,13)] -mlist2 += ['2005-%02i' % i for i in range(1,13)] -mser2 = ts.time_series(np.arange(len(mlist2)), mlist2, observed='SUMMED') -# -mser1_filled = ts.fill_missing_dates(mser1) -(malg1,malg2) = ts.aligned(mser1_filled, mser2) -mser3 = malg1 + malg2 - -""" -# add the two series together, first filling in masked values with zeros -mAdd1_filled = mSer1.filled(fill_value=0, ts=True) + mSer2.filled(fill_value=0, ts=True) - -# adjust the start and end dates of a series -newSer = ts.adjust_endpoints(mSer1, start_date=td.Date(freq='M', year=1954, month=5), end_date=td.Date(freq='M', year=2000, month=6)) - -# calculate the average value in the series. Behaves the same as in ma -bAverage = ma.average(series) - - - - - -# Get the last day of this year, at daily frequency -dLastDayOfYear = td.dateOf(td.thisday('A'),'D','AFTER') - - -# Get the first day of this year, at business frequency -bFirstDayOfYear = td.dateOf(td.thisday('A'),'B','BEFORE') - -# Get the last day of the previous quarter, business frequency -bLastDayOfLastQuarter = td.dateOf(td.thisday('Q')-1,'B','AFTER') - -# dateOf can also go from high frequency to low frequency. In this case, the third parameter has no impact -aTrueValue = (td.thisday('Q') == td.dateOf(td.thisday('b'),'Q')) - -# Dates of the same frequency can be subtracted (but not added obviously) -numberOfBusinessDaysPassedThisYear = td.thisday('b') - bFirstDayOfYear - -# Integers can be added/substracted to/from dates -fiveDaysFromNow = td.thisday('d') + 5 - - -# Get the previous business day, where business day is considered to -# end at day_end_hour and day_end_min -pbd = td.prevbusday(day_end_hour=18,day_end_min=0) -""" -# ------------------------------------------------------------------------------ -""" -=== Date construction === -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 `mxDate` keyword with an existing mx.DateTime.DateTime object, or - even a datetime.datetime object. - - >>> td.Date('D', mxDate=mx.DateTime.now()) - >>> td.Date('D', mxDate=datetime.datetime.now()) -""" - -# Construct a sequence of dates at a given frequency +nseries[sixtymonthsago:sixtymonthsago+10] = 12 Added: trunk/Lib/sandbox/timeseries/examples/example.wiki =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-23 05:45:43 UTC (rev 2590) +++ trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-23 08:21:33 UTC (rev 2591) @@ -0,0 +1,221 @@ + +{{{#!python numbers=disable +>>> import numpy as N +>>> import maskedarray as MA +>>> import tseries as TS +>>> import tdates as TD +}}} + +== Dates == + +A `Date` object combines some date and/or time related information with a given frequency. You can picture the frequency as the unit into which the date is expressed. For example, the three objects: +{{{#!python numbers=disable +>>> D = TD.Date(freq='D', year=2007, month=1, day=1) +>>> M = TD.Date(freq='M', year=2007, month=1, day=1) +>>> Y = TD.Date(freq='A', year=2007, month=1, day=1) +}}} +use the same date information, but different frequencies. They correspond to to the day Jan. 01, 2007, the month Jan. 2007 and the year 2007, respectively. The importance of the frequency will become clearer later on. +~- A more technical note: `Date` objects are internally stored as integers. The conversion to integers and back is controlled by the frequency. In the example above, the internal representation of the three objects `D`, `M` and `Y` are 732677, 24073 and 2007, respectively. -~ + +Date objects are managed through their own class, appropriately named `Date`. + +==== Construction of a `Date` object ==== +Several options are available to construct a Date object explicitly. In each case, the `frequency` argument must be given. + + * Give appropriate values to any of the `year`, `month`, `day`, `quarter`, `hours`, `minutes`, `seconds` arguments. + +{{{#!python numbers=disable +>>> 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 the documentation of this latter. + +{{{#!python numbers=disable +>>> TD.Date('D', string='2007-01-01') + +}}} + + * Use the `mxDate` keyword with an existing `mx.DateTime.DateTime` object, or even a `datetime.datetime` object. +{{{#!python numbers=disable +>>> TD.Date('D', mxDate=mx.DateTime.now()) +>>> TD.Date('D', mxDate=datetime.datetime.now()) +}}} + + +---- + +== DateArray objects == + +DateArrays are simply ndarrays of `Date` objects. + +---- + +== TimeSeries == + +A `TimeSeries` object is the combination of three ndarrays: + + * `dates`: DateArray object. + * `data` : ndarray. + * `mask` : Boolean ndarray, indicating missing or invalid data. + + +==== Construction ==== + +To construct a TimeSeries, you can use the class constructor: + +{{{#!python numbers=disable +TimeSeries(data, dates=None, mask=nomask, + freq=None, observed=None, start_date=None, + dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False) +}}} +where `data` is a sequence, a ndarray or a MaskedArray. If `dates` is None, a DateArray of the same length as the data is constructed at a `freq` frequency, starting at `start_date`. + +Alternatively, you can use the `time_series` function: +{{{#!python numbers=disable +time_series(data, dates=None, freq=None, + start_date=None, end_date=None, length=None, include_last=True, + mask=nomask, dtype=None, copy=False, fill_value=None, + keep_mask=True, small_mask=True, hard_mask=False) +}}} + +Let us construct a series of 600 random elements, starting 600 business days ago, at a business daily frequency +{{{#!python numbers=disable +>>> data = N.random.uniform(-100,100,600) +>>> today = TD.thisday('B') +>>> series = TS.time_series(data, dtype=N.float_, freq='B', observed='SUMMED', +>>> start_date=today-600) +}}} + +==== Indexing ==== + +Elements of a TimeSeries can be accessed just like with regular ndarrrays. Thus, +{{{#!python numbers=disable +>>> series[0] +}}} +outputs the first element, while +{{{#!python numbers=disable +>>> series[-30:] +}}} +outputs the last 30 elements. + +But you can also use a date: +{{{#!python numbers=disable +>>> thirtydaysago = today - 30 +>>> series[thirtydaysago:] +}}} +or even a string... +{{{#!python numbers=disable +>>> series[thirtydaysago.tostring():] +}}} + +In a similar way, setting elements of a TimeSeries works seamlessly. +Let us set negative values to zero... +{{{#!python numbers=disable +>>> series[series<0] = 0 +}}} +... and the values falling on Fridays to 100 +{{{#!python numbers=disable +>>> series[series.day_of_week == 4] = 100 +}}} +Note that we could also create a temporary array of 'day_of weeks' for the +corresponding period, and use it as condition. +{{{#!python numbers=disable +>>> weekdays = TD.day_of_week(series) +>>> series[weekdays == 4] = 100 +}}} +You should keep in mind that TimeSeries are basically MaskedArrays. If some data are masked, you will not be able to use a condition as index, you will have to fill the data first. + +==== Operations on TimeSeries ==== + +If you work with only one TimeSeries, you can use regular commands to process the data. For example: +{{{#!python numbers=disable +>>> series_log = N.log(series) +}}} +Note that invalid values (negative, in that case), are automatically masked. Note also that you could use the corresponding function of the `maskedarray` module. This latter approach is actually recommended when you want to use the `reduce` and `accumulate` methods of some ufuncs (such as add or multiply). ~-The reason is that the methods of the numpy.ufuncs do not communicate well with subclasses: as they do not call the `__array_wrap__` method, there is no postprocessing.-~ + +When working with multiple series, only series of the same frequency, size and starting date can be used in basic operations. The function `align_series` ~-(or its alias `aligned`)-~ forces series to have matching starting and ending dates. By default, the starting date will be set to the smallest starting date of the series, and the ending date to the largest. + +Let's construct a list of months, starting on Jan 2005 and ending on Dec 2006, with a gap from Oct 2005 to Dec 2006. +{{{#!python numbers=disable +>>> mlist_1 = ['2005-%02i' % i for i in range(1,10)] +>>> mlist_1 += ['2006-%02i' % i for i in range(2,13)] +>>> mdata_1 = N.arange(len(mlist_1)) +>>> mser_1 = TS.time_series(mdata_1, mlist_1, observed='SUMMED') +}}} +Note that the frequency is 'U', for undefined. In fact, you have to specify what kind of data is actually missing by forcing a given frequency. +{{{#!python numbers=disable +>>> mser = mser1.asfreq('M') +}}} +Let us check whether there are some duplicated dates (no): +{{{#!python numbers=disable +>>> mser1.has_duplicated_dates() +}}} +...or missing dates (yes): +{{{#!python numbers=disable +>>> mser1.has_missing_dates() +}}} +Let us construct a second monthly series, this time without missing dates +{{{#!python numbers=disable +>>> mlist_2 = ['2004-%02i' % i for i in range(1,13)] +>>> mlist_2 += ['2005-%02i' % i for i in range(1,13)] +>>> mser_2 = TS.time_series(N.arange(len(mlist_2)), mlist_2, observed='SUMMED') +}}} +Let's try to add the two series: +{{{#!python numbers=disable +>>> mser_3 = mser_1 + mser_2 +}}} +That doesn't work, as the series have different starting dates. We need to align them first. +{{{#!python numbers=disable +>>> (malg_1,malg_2) = aligned(mser_1, mser_2) +}}} +That still doesnt' work, as `malg_1` has missing dates. Let us fill it, then: data falling on a date that was missing will be masked. +{{{#!python numbers=disable +>>> mser_1_filled = fill_missing_dates(mser_1) +>>> (malg_1,malg_2) = align_series(mser_1_filled, mser_2) +}}} +Now we can add the two series. Only the data that fall on dates common to the original, non-aligned series will be actually added, the others will be masked. After all, we are adding masked arrays. +{{{#!python numbers=disable +>>> mser_3 = malg_1 + malg_2 +}}} +We could have filled the initial series first: +{{{#!python numbers=disable +>>> mser_3 = filled(malg_1,0) + filled(malg_2,0) +}}} +Alternatively, we can force the series to start/end at some given dates +{{{#!python numbers=disable +>>> (malg_1,malg_2) = aligned(mser_1_filled, mser2, +>>> start_date='2004-06', end_date='2006-06') +}}} + + +==== TimeSeries Conversion ==== + +To convert a TimeSeries to another frequency, use the `convert` method or function. The optional argument `func` must be a function that acts on a 1D masked array and returns a scalar. +{{{#!python numbers=disable +>>> mseries = series.convert('M',func=ma.average) +}}} +If `func` is not specified, the default value `'auto'` is used instead. In that case, +the conversion function is estimated from the `observed` attribute of the series. +For example, if `observed='SUMMED'`, then `func='auto'` is in fact `func=sum`. +{{{#!python numbers=disable +>>> mseries_default = series.convert('M') +}}} +If `func` is None, the convert method/function returns a 2D array, where each row corresponds to the new frequency, and the columns to the original data. In our example, `convert` will return a 2D array with 23 columns, as there are at most 23 business days per month. +{{{#!python numbers=disable +>>> mseries_2d = series.convert('M',func=None) +}}} +When converting from a lower frequency to a higher frequency, an extra argument `position` is required. The value of the argument is either 'START' or 'END', and determines where the data point will be placed in the period. In the future, interpolation methods will be supported to fill in the resulting masked values. + +Let us create a second series, this time with a monthly frequency, starting 110 months ago. +{{{#!python numbers=disable +>>> data = N.random.uniform(-100,100,100).astype(np.float_) +>>> today = TS.today.asfreq('M') - 110 +>>> nseries = TS.TimeSeries(data, freq='m', observed='END',start_date=today) +>>> sixtymonthsago = today-60 +>>> nseries[sixtymonthsago:sixtymonthsago+10] = 12 +}}} + Property changes on: trunk/Lib/sandbox/timeseries/examples/example.wiki ___________________________________________________________________ Name: svn:executable + * Modified: trunk/Lib/sandbox/timeseries/readme.txt =================================================================== --- trunk/Lib/sandbox/timeseries/readme.txt 2007-01-23 05:45:43 UTC (rev 2590) +++ trunk/Lib/sandbox/timeseries/readme.txt 2007-01-23 08:21:33 UTC (rev 2591) @@ -4,7 +4,7 @@ code requires access to a couple of the header files included with this module when compiling 2. Only tested with numpy 1.0.1 3. Only tested with Python 2.4.x -4. Only tested on Windows Platform +4. Only tested on Windows and x86_64 Platform 5. Requires maskedarray from the sandbox (not the standard masked array module with numpy) Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-23 05:45:43 UTC (rev 2590) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-23 08:21:33 UTC (rev 2591) @@ -337,7 +337,7 @@ if self.freq == "A": fmt = "%Y" elif self.freq in ("B","D"): - fmt = "%d-%b-%y" + fmt = "%d-%b-%Y" elif self.freq == "M": fmt = "%b-%Y" elif self.freq == "Q": @@ -541,14 +541,15 @@ index = self.find_dates(index) except AttributeError: pass - r = ndarray.__getitem__(self, index) - + r = ndarray.__getitem__(self, index) if not hasattr(r, "size"): - if type(r) == types.IntType: return Date(self.freq, value=r) - else: return r - elif r.size == 1: + if isinstance(r, int): + return Date(self.freq, value=r) + else: + return r + elif r.size == 1: # Only one element, and it's not a scalar: we have a DateArray of size 1 - if len(r.shape) > 0: + if len(numeric.shape(r)) > 0: r = r.item() return Date(self.freq, value=r) else: From scipy-svn at scipy.org Tue Jan 23 13:05:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 12:05:02 -0600 (CST) Subject: [Scipy-svn] r2592 - trunk/Lib/sandbox/timeseries/examples Message-ID: <20070123180502.7C87339C094@new.scipy.org> Author: pierregm Date: 2007-01-23 12:04:58 -0600 (Tue, 23 Jan 2007) New Revision: 2592 Modified: trunk/Lib/sandbox/timeseries/examples/example.py trunk/Lib/sandbox/timeseries/examples/example.wiki Log: temporary doc update Modified: trunk/Lib/sandbox/timeseries/examples/example.py =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-23 08:21:33 UTC (rev 2591) +++ trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-23 18:04:58 UTC (rev 2592) @@ -1,5 +1,7 @@ import numpy as N import maskedarray as MA +import mx.DateTime +import datetime import tseries as TS import tdates as TD D = TD.Date(freq='D', year=2007, month=1, day=1) @@ -7,12 +9,14 @@ Y = TD.Date(freq='A', year=2007, month=1, day=1) TD.Date(freq='Q',year=2004,quarter=3) TD.Date(freq='D',year=2001,month=1,day=1) -TD.Date('D', '2007-01-01') +TD.Date('D', string='2007-01-01') TD.Date('D', mxDate=mx.DateTime.now()) TD.Date('D', mxDate=datetime.datetime.now()) +mybirthday = D-1 +infivemonths = M + 5 data = N.random.uniform(-100,100,600) today = TD.thisday('B') -series = TS.time_series(data, dtype=np.float_, freq='B', observed='SUMMED', +series = TS.time_series(data, dtype=N.float_, freq='B', observed='SUMMED', start_date=today-600) series[0] series[-30:] @@ -21,7 +25,7 @@ series[thirtydaysago.tostring():] series[series<0] = 0 series[series.day_of_week == 4] = 100 -weekdays = td.day_of_week(series) +weekdays = TD.day_of_week(series) series[weekdays == 4] = 100 series_log = N.log(series) mlist_1 = ['2005-%02i' % i for i in range(1,10)] Modified: trunk/Lib/sandbox/timeseries/examples/example.wiki =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-23 08:21:33 UTC (rev 2591) +++ trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-23 18:04:58 UTC (rev 2592) @@ -1,11 +1,24 @@ +== Requirements == + +In order to use the `TimeSeries` package, you need to have the foloowing packages installed: + * `numpy` + * `maskedarray` : the new implementation where masked arrays are subclasses of regular ndarrays. You can find this version in the sandbox on the scipy SVN server + * `mx.DateTime` : This external module is needed to process some of the dates in C. At term, we hope to be able to get rid of it. In the meanwhile, sorry for the inconvenience. + + +The `TimeSeries` package is organized as a group of modules. Two modules are especially useful: `tdates` for managing `Date` and `DateArray` objects, and `tseries`, for managing time series. {{{#!python numbers=disable >>> import numpy as N >>> import maskedarray as MA +>>> import mx.DateTime +>>> import datetime >>> import tseries as TS >>> import tdates as TD }}} +Note that you could also just import the generic `timeseries` package to achieve the same results. + == Dates == A `Date` object combines some date and/or time related information with a given frequency. You can picture the frequency as the unit into which the date is expressed. For example, the three objects: @@ -14,16 +27,13 @@ >>> M = TD.Date(freq='M', year=2007, month=1, day=1) >>> Y = TD.Date(freq='A', year=2007, month=1, day=1) }}} -use the same date information, but different frequencies. They correspond to to the day Jan. 01, 2007, the month Jan. 2007 and the year 2007, respectively. The importance of the frequency will become clearer later on. +use the same date information, but different frequencies. They correspond to to the day 'Jan. 01, 2007', the month 'Jan. 2007' and the year '2007', respectively. The importance of the frequency will become clearer later on. ~- A more technical note: `Date` objects are internally stored as integers. The conversion to integers and back is controlled by the frequency. In the example above, the internal representation of the three objects `D`, `M` and `Y` are 732677, 24073 and 2007, respectively. -~ -Date objects are managed through their own class, appropriately named `Date`. - ==== Construction of a `Date` object ==== Several options are available to construct a Date object explicitly. In each case, the `frequency` argument must be given. * Give appropriate values to any of the `year`, `month`, `day`, `quarter`, `hours`, `minutes`, `seconds` arguments. - {{{#!python numbers=disable >>> TD.Date(freq='Q',year=2004,quarter=3) @@ -32,7 +42,6 @@ }}} * Use the `string` keyword. This method calls the `mx.DateTime.Parser` submodule, more information is available in the documentation of this latter. - {{{#!python numbers=disable >>> TD.Date('D', string='2007-01-01') @@ -45,12 +54,45 @@ }}} +==== Manipulating dates ==== + +You can add and subtract integers from a `Date` object to get a new `Date` object. The frequency of the new object is the same as the roginal one. For example: +{{{#!python numbers=disable +>>> mybirthday = D-1 + +>>> infivemonths = M + 5 + +}}} + +You can convert a `Date` object from one frequency to another with the `asfreq` method. When converting to a higher frequency (for example, from monthly to daily), the new object will fall on the earliest date possible by default. Thus, if you convert a daily `Date` to a monthly one and back to a daily one, you will lose your day information in the process: +{{{#!python numbers=disable +>>> mybirthday.asfreq('M') + +>>> mybirthday.asfreq('M').asfreq('D') + +}}} + +Some other methods worth mentioning are: + * `toordinal` : converts an object to the equivalent proleptic gregorian date + * `tostring` : converts an object to the corresponding string. + ---- == DateArray objects == -DateArrays are simply ndarrays of `Date` objects. +DateArrays are simply ndarrays of `Date` objects. They accept the same methods as a `Date` object, with the addition of: + * `tovalue` : converts the array to an array of integers. Each integer is the internal representation of the corresponding date + * `has_missing_dates` : outputs a boolean on whether some dates are missing or not. + * `has_duplicated_dates` : outputs a boolean on whether some dates are duplicated or not. +==== Construction ==== + +To construct a `DateArray` object, you can call the class directly +{{{#!python numbers=disable +}}} + + + ---- == TimeSeries == From scipy-svn at scipy.org Tue Jan 23 13:16:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 12:16:28 -0600 (CST) Subject: [Scipy-svn] r2593 - trunk/Lib/odr Message-ID: <20070123181628.0D3B639C100@new.scipy.org> Author: rkern Date: 2007-01-23 12:16:28 -0600 (Tue, 23 Jan 2007) New Revision: 2593 Modified: trunk/Lib/odr/odrpack.py Log: Fix import location of scipy.odr.__odrpack. Modified: trunk/Lib/odr/odrpack.py =================================================================== --- trunk/Lib/odr/odrpack.py 2007-01-23 18:04:58 UTC (rev 2592) +++ trunk/Lib/odr/odrpack.py 2007-01-23 18:16:28 UTC (rev 2593) @@ -100,7 +100,7 @@ """ import numpy -from scipy.sandbox.odr import __odrpack +from scipy.odr import __odrpack odr = __odrpack.odr odr_error = __odrpack.odr_error From scipy-svn at scipy.org Tue Jan 23 14:33:59 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 13:33:59 -0600 (CST) Subject: [Scipy-svn] r2594 - in trunk/Lib/odr: . tests Message-ID: <20070123193359.2E78839C136@new.scipy.org> Author: jarrod.millman Date: 2007-01-23 13:33:57 -0600 (Tue, 23 Jan 2007) New Revision: 2594 Modified: trunk/Lib/odr/models.py trunk/Lib/odr/tests/test_odrpack.py Log: Fix import location of scipy.odr Modified: trunk/Lib/odr/models.py =================================================================== --- trunk/Lib/odr/models.py 2007-01-23 18:16:28 UTC (rev 2593) +++ trunk/Lib/odr/models.py 2007-01-23 19:33:57 UTC (rev 2594) @@ -1,9 +1,8 @@ """ Collection of Model instances for use with the odrpack fitting package. """ -# Scipy imports. -from scipy.sandbox.odr.odrpack import Model import numpy as np +from scipy.odr.odrpack import Model def _lin_fcn(B, x): Modified: trunk/Lib/odr/tests/test_odrpack.py =================================================================== --- trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 18:16:28 UTC (rev 2593) +++ trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 19:33:57 UTC (rev 2594) @@ -7,7 +7,7 @@ import numpy as np from numpy import pi from numpy.testing import assert_array_almost_equal -from scipy.sandbox.odr import Data, Model, ODR, RealData, odr_stop +from scipy.odr import Data, Model, ODR, RealData, odr_stop class ODRTestCase(unittest.TestCase): From scipy-svn at scipy.org Tue Jan 23 14:45:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 13:45:36 -0600 (CST) Subject: [Scipy-svn] r2595 - in trunk/Lib/odr: . tests Message-ID: <20070123194536.E899039C034@new.scipy.org> Author: jarrod.millman Date: 2007-01-23 13:45:34 -0600 (Tue, 23 Jan 2007) New Revision: 2595 Modified: trunk/Lib/odr/__init__.py trunk/Lib/odr/tests/test_odrpack.py Log: starting to enable odr tests using NumpyTest Modified: trunk/Lib/odr/__init__.py =================================================================== --- trunk/Lib/odr/__init__.py 2007-01-23 19:33:57 UTC (rev 2594) +++ trunk/Lib/odr/__init__.py 2007-01-23 19:45:34 UTC (rev 2595) @@ -59,4 +59,6 @@ __all__ = ['odr', 'odr_error', 'odr_stop', 'Data', 'RealData', 'Model', 'Output', 'ODR', 'odrpack'] +from numpy.testing import NumpyTest +test = NumpyTest().test #### EOF ####################################################################### Modified: trunk/Lib/odr/tests/test_odrpack.py =================================================================== --- trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 19:33:57 UTC (rev 2594) +++ trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 19:45:34 UTC (rev 2595) @@ -1,16 +1,15 @@ # Standard library imports. import cPickle -import unittest # Scipy imports. import numpy as np from numpy import pi -from numpy.testing import assert_array_almost_equal +from numpy.testing import NumpyTest, NumpyTestCase, assert_array_almost_equal from scipy.odr import Data, Model, ODR, RealData, odr_stop -class ODRTestCase(unittest.TestCase): +class test_odr(NumpyTestCase): # Explicit Example @@ -312,7 +311,7 @@ ) -if __name__ == '__main__': - unittest.main() +if __name__ == "__main__": + NumpyTest().run() #### EOF ####################################################################### From scipy-svn at scipy.org Tue Jan 23 15:14:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 14:14:54 -0600 (CST) Subject: [Scipy-svn] r2596 - in trunk/Lib/odr: . tests Message-ID: <20070123201454.C755C39C113@new.scipy.org> Author: jarrod.millman Date: 2007-01-23 14:14:51 -0600 (Tue, 23 Jan 2007) New Revision: 2596 Added: trunk/Lib/odr/tests/test_odr.py Removed: trunk/Lib/odr/tests/test_odrpack.py Modified: trunk/Lib/odr/__init__.py trunk/Lib/odr/setup.py Log: more changes to enable tests, created info.py Modified: trunk/Lib/odr/__init__.py =================================================================== --- trunk/Lib/odr/__init__.py 2007-01-23 19:45:34 UTC (rev 2595) +++ trunk/Lib/odr/__init__.py 2007-01-23 20:14:51 UTC (rev 2596) @@ -1,47 +1,9 @@ -""" Orthogonal Distance Regression +# +# odr - Orthogonal Distance Regression +# -Introduction -============ +from info import __doc__ -Why Orthogonal Distance Regression (ODR)? Sometimes one has measurement errors -in the explanatory variable, not just the response variable. Ordinary Least -Squares (OLS) fitting procedures treat the data for explanatory variables as -fixed. Furthermore, OLS procedures require that the response variable be an -explicit function of the explanatory variables; sometimes making the equation -explicit is unwieldy and introduces errors. ODR can handle both of these cases -with ease and can even reduce to the OLS case if necessary. - -ODRPACK is a FORTRAN-77 library for performing ODR with possibly non-linear -fitting functions. It uses a modified trust-region Levenberg-Marquardt-type -algorithm to estimate the function parameters. The fitting functions are -provided by Python functions operating on NumPy arrays. The required derivatives -may be provided by Python functions as well or may be numerically estimated. -ODRPACK can do explicit or implicit ODR fits or can do OLS. Input and output -variables may be multi-dimensional. Weights can be provided to account for -different variances of the observations (even covariances between dimensions of -the variables). - -odr provides two interfaces: a single function and a set of high-level classes -that wrap that function. Please refer to their docstrings for more information. -While the docstring of the function, odr, does not have a full explanation of -its arguments, the classes do, and the arguments with the same name usually have -the same requirements. Furthermore, it is highly suggested that one at least -skim the ODRPACK User's Guide. Know Thy Algorithm. - - -Use -=== - -See the docstrings of odr.odrpack and the functions and classes for -usage instructions. The ODRPACK User's Guide is also quite helpful. It can be -found on one of the ODRPACK's original author's website: - - http://www.boulder.nist.gov/mcsd/Staff/JRogers/odrpack.html - -Robert Kern -robert.kern at gmail.com -""" - __version__ = '0.7' __author__ = 'Robert Kern ' __date__ = '2006-09-21' Modified: trunk/Lib/odr/setup.py =================================================================== --- trunk/Lib/odr/setup.py 2007-01-23 19:45:34 UTC (rev 2595) +++ trunk/Lib/odr/setup.py 2007-01-23 20:14:51 UTC (rev 2596) @@ -38,6 +38,7 @@ **blas_info ) + config.add_data_dir('tests') return config if __name__ == '__main__': Copied: trunk/Lib/odr/tests/test_odr.py (from rev 2595, trunk/Lib/odr/tests/test_odrpack.py) =================================================================== --- trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 19:45:34 UTC (rev 2595) +++ trunk/Lib/odr/tests/test_odr.py 2007-01-23 20:14:51 UTC (rev 2596) @@ -0,0 +1,316 @@ +# Standard library imports. +import cPickle + +# Scipy imports. +import numpy as np +from numpy import pi +from numpy.testing import NumpyTest, NumpyTestCase, assert_array_almost_equal +from scipy.odr import Data, Model, ODR, RealData, odr_stop + + +class test_odr(NumpyTestCase): + + # Explicit Example + + def explicit_fcn(self, B, x): + ret = B[0] + B[1] * np.power(np.exp(B[2]*x) - 1.0, 2) + return ret + + def explicit_fjd(self, B, x): + eBx = np.exp(B[2]*x) + ret = B[1] * 2.0 * (eBx-1.0) * B[2] * eBx + return ret + + def explicit_fjb(self, B, x): + eBx = np.exp(B[2]*x) + res = np.vstack([np.ones(x.shape[-1]), + np.power(eBx-1.0, 2), + B[1]*2.0*(eBx-1.0)*eBx*x]) + return res + + def test_explicit(self): + explicit_mod = Model( + self.explicit_fcn, + fjacb=self.explicit_fjb, + fjacd=self.explicit_fjd, + meta=dict(name='Sample Explicit Model', + ref='ODRPACK UG, pg. 39'), + ) + explicit_dat = Data([0.,0.,5.,7.,7.5,10.,16.,26.,30.,34.,34.5,100.], + [1265.,1263.6,1258.,1254.,1253.,1249.8,1237.,1218.,1220.6, + 1213.8,1215.5,1212.]) + explicit_odr = ODR(explicit_dat, explicit_mod, beta0=[1500.0, -50.0, -0.1], + ifixx=[0,0,1,1,1,1,1,1,1,1,1,0]) + explicit_odr.set_job(deriv=2) + + out = explicit_odr.run() + assert_array_almost_equal( + out.beta, + np.array([ 1.2646548050648876e+03, -5.4018409956678255e+01, + -8.7849712165253724e-02]), + ) + assert_array_almost_equal( + out.sd_beta, + np.array([ 1.0349270280543437, 1.583997785262061 , 0.0063321988657267]), + ) + assert_array_almost_equal( + out.cov_beta, + np.array([[ 4.4949592379003039e-01, -3.7421976890364739e-01, + -8.0978217468468912e-04], + [ -3.7421976890364739e-01, 1.0529686462751804e+00, + -1.9453521827942002e-03], + [ -8.0978217468468912e-04, -1.9453521827942002e-03, + 1.6827336938454476e-05]]), + ) + + + # Implicit Example + + def implicit_fcn(self, B, x): + return (B[2]*np.power(x[0]-B[0], 2) + + 2.0*B[3]*(x[0]-B[0])*(x[1]-B[1]) + + B[4]*np.power(x[1]-B[1], 2) - 1.0) + + def test_implicit(self): + implicit_mod = Model( + self.implicit_fcn, + implicit=1, + meta=dict(name='Sample Implicit Model', + ref='ODRPACK UG, pg. 49'), + ) + implicit_dat = Data([ + [0.5,1.2,1.6,1.86,2.12,2.36,2.44,2.36,2.06,1.74,1.34,0.9,-0.28, + -0.78,-1.36,-1.9,-2.5,-2.88,-3.18,-3.44], + [-0.12,-0.6,-1.,-1.4,-2.54,-3.36,-4.,-4.75,-5.25,-5.64,-5.97,-6.32, + -6.44,-6.44,-6.41,-6.25,-5.88,-5.5,-5.24,-4.86]], + 1, + ) + implicit_odr = ODR(implicit_dat, implicit_mod, + beta0=[-1.0, -3.0, 0.09, 0.02, 0.08]) + + out = implicit_odr.run() + assert_array_almost_equal( + out.beta, + np.array([-0.9993809167281279, -2.9310484652026476, 0.0875730502693354, + 0.0162299708984738, 0.0797537982976416]), + ) + assert_array_almost_equal( + out.sd_beta, + np.array([ 0.1113840353364371, 0.1097673310686467, 0.0041060738314314, + 0.0027500347539902, 0.0034962501532468]), + ) + assert_array_almost_equal( + out.cov_beta, + np.array([[ 2.1089274602333052e+00, -1.9437686411979040e+00, + 7.0263550868344446e-02, -4.7175267373474862e-02, + 5.2515575927380355e-02], + [ -1.9437686411979040e+00, 2.0481509222414456e+00, + -6.1600515853057307e-02, 4.6268827806232933e-02, + -5.8822307501391467e-02], + [ 7.0263550868344446e-02, -6.1600515853057307e-02, + 2.8659542561579308e-03, -1.4628662260014491e-03, + 1.4528860663055824e-03], + [ -4.7175267373474862e-02, 4.6268827806232933e-02, + -1.4628662260014491e-03, 1.2855592885514335e-03, + -1.2692942951415293e-03], + [ 5.2515575927380355e-02, -5.8822307501391467e-02, + 1.4528860663055824e-03, -1.2692942951415293e-03, + 2.0778813389755596e-03]]), + ) + + + # Multi-variable Example + + def multi_fcn(self, B, x): + if (x < 0.0).any(): + raise odr_stop + theta = pi*B[3]/2. + ctheta = np.cos(theta) + stheta = np.sin(theta) + omega = np.power(2.*pi*x*np.exp(-B[2]), B[3]) + phi = np.arctan2((omega*stheta), (1.0 + omega*ctheta)) + r = (B[0] - B[1]) * np.power(np.sqrt(np.power(1.0 + omega*ctheta, 2) + + np.power(omega*stheta, 2)), -B[4]) + ret = np.vstack([B[1] + r*np.cos(B[4]*phi), + r*np.sin(B[4]*phi)]) + return ret + + def test_multi(self): + multi_mod = Model( + self.multi_fcn, + meta=dict(name='Sample Multi-Response Model', + ref='ODRPACK UG, pg. 56'), + ) + + multi_x = np.array([30.0, 50.0, 70.0, 100.0, 150.0, 200.0, 300.0, 500.0, + 700.0, 1000.0, 1500.0, 2000.0, 3000.0, 5000.0, 7000.0, 10000.0, + 15000.0, 20000.0, 30000.0, 50000.0, 70000.0, 100000.0, 150000.0]) + multi_y = np.array([ + [4.22, 4.167, 4.132, 4.038, 4.019, 3.956, 3.884, 3.784, 3.713, + 3.633, 3.54, 3.433, 3.358, 3.258, 3.193, 3.128, 3.059, 2.984, + 2.934, 2.876, 2.838, 2.798, 2.759], + [0.136, 0.167, 0.188, 0.212, 0.236, 0.257, 0.276, 0.297, 0.309, + 0.311, 0.314, 0.311, 0.305, 0.289, 0.277, 0.255, 0.24, 0.218, + 0.202, 0.182, 0.168, 0.153, 0.139], + ]) + n = len(multi_x) + multi_we = np.zeros((2, 2, n), dtype=float) + multi_ifixx = np.ones(n, dtype=int) + multi_delta = np.zeros(n, dtype=float) + + multi_we[0,0,:] = 559.6 + multi_we[1,0,:] = multi_we[0,1,:] = -1634.0 + multi_we[1,1,:] = 8397.0 + + for i in range(n): + if multi_x[i] < 100.0: + multi_ifixx[i] = 0 + elif multi_x[i] <= 150.0: + pass # defaults are fine + elif multi_x[i] <= 1000.0: + multi_delta[i] = 25.0 + elif multi_x[i] <= 10000.0: + multi_delta[i] = 560.0 + elif multi_x[i] <= 100000.0: + multi_delta[i] = 9500.0 + else: + multi_delta[i] = 144000.0 + if multi_x[i] == 100.0 or multi_x[i] == 150.0: + multi_we[:,:,i] = 0.0 + + multi_dat = Data(multi_x, multi_y, wd=1e-4/np.power(multi_x, 2), + we=multi_we) + multi_odr = ODR(multi_dat, multi_mod, beta0=[4.,2.,7.,.4,.5], + delta0=multi_delta, ifixx=multi_ifixx) + multi_odr.set_job(deriv=1, del_init=1) + + out = multi_odr.run() + assert_array_almost_equal( + out.beta, + np.array([ 4.3799880305938963, 2.4333057577497703, 8.0028845899503978, + 0.5101147161764654, 0.5173902330489161]), + ) + assert_array_almost_equal( + out.sd_beta, + np.array([ 0.0130625231081944, 0.0130499785273277, 0.1167085962217757, + 0.0132642749596149, 0.0288529201353984]), + ) + assert_array_almost_equal( + out.cov_beta, + np.array([[ 0.0064918418231375, 0.0036159705923791, 0.0438637051470406, + -0.0058700836512467, 0.011281212888768 ], + [ 0.0036159705923791, 0.0064793789429006, 0.0517610978353126, + -0.0051181304940204, 0.0130726943624117], + [ 0.0438637051470406, 0.0517610978353126, 0.5182263323095322, + -0.0563083340093696, 0.1269490939468611], + [-0.0058700836512467, -0.0051181304940204, -0.0563083340093696, + 0.0066939246261263, -0.0140184391377962], + [ 0.011281212888768 , 0.0130726943624117, 0.1269490939468611, + -0.0140184391377962, 0.0316733013820852]]), + ) + + + # Pearson's Data + # K. Pearson, Philosophical Magazine, 2, 559 (1901) + + def pearson_fcn(self, B, x): + return B[0] + B[1]*x + + def test_pearson(self): + p_x = np.array([0.,.9,1.8,2.6,3.3,4.4,5.2,6.1,6.5,7.4]) + p_y = np.array([5.9,5.4,4.4,4.6,3.5,3.7,2.8,2.8,2.4,1.5]) + p_sx = np.array([.03,.03,.04,.035,.07,.11,.13,.22,.74,1.]) + p_sy = np.array([1.,.74,.5,.35,.22,.22,.12,.12,.1,.04]) + + p_dat = RealData(p_x, p_y, sx=p_sx, sy=p_sy) + + # Reverse the data to test invariance of results + pr_dat = RealData(p_y, p_x, sx=p_sy, sy=p_sx) + + p_mod = Model(self.pearson_fcn, meta=dict(name='Uni-linear Fit')) + + p_odr = ODR(p_dat, p_mod, beta0=[1.,1.]) + pr_odr = ODR(pr_dat, p_mod, beta0=[1.,1.]) + + out = p_odr.run() + assert_array_almost_equal( + out.beta, + np.array([ 5.4767400299231674, -0.4796082367610305]), + ) + assert_array_almost_equal( + out.sd_beta, + np.array([ 0.3590121690702467, 0.0706291186037444]), + ) + assert_array_almost_equal( + out.cov_beta, + np.array([[ 0.0854275622946333, -0.0161807025443155], + [-0.0161807025443155, 0.003306337993922 ]]), + ) + + rout = pr_odr.run() + assert_array_almost_equal( + rout.beta, + np.array([ 11.4192022410781231, -2.0850374506165474]), + ) + assert_array_almost_equal( + rout.sd_beta, + np.array([ 0.9820231665657161, 0.3070515616198911]), + ) + assert_array_almost_equal( + rout.cov_beta, + np.array([[ 0.6391799462548782, -0.1955657291119177], + [-0.1955657291119177, 0.0624888159223392]]), + ) + + # Lorentz Peak + # The data is taken from one of the undergraduate physics labs I performed. + + def lorentz(self, beta, x): + return (beta[0]*beta[1]*beta[2] / np.sqrt(np.power(x*x - + beta[2]*beta[2], 2.0) + np.power(beta[1]*x, 2.0))) + + def test_lorentz(self): + l_sy = np.array([.29]*18) + l_sx = np.array([.000972971,.000948268,.000707632,.000706679, + .000706074, .000703918,.000698955,.000456856, + .000455207,.000662717,.000654619,.000652694, + .000000859202,.00106589,.00106378,.00125483, .00140818,.00241839]) + + l_dat = RealData( + [3.9094, 3.85945, 3.84976, 3.84716, 3.84551, 3.83964, 3.82608, + 3.78847, 3.78163, 3.72558, 3.70274, 3.6973, 3.67373, 3.65982, + 3.6562, 3.62498, 3.55525, 3.41886], + [652, 910.5, 984, 1000, 1007.5, 1053, 1160.5, 1409.5, 1430, 1122, + 957.5, 920, 777.5, 709.5, 698, 578.5, 418.5, 275.5], + sx=l_sx, + sy=l_sy, + ) + l_mod = Model(self.lorentz, meta=dict(name='Lorentz Peak')) + l_odr = ODR(l_dat, l_mod, beta0=(1000., .1, 3.8)) + + out = l_odr.run() + assert_array_almost_equal( + out.beta, + np.array([ 1.4306780846149925e+03, 1.3390509034538309e-01, + 3.7798193600109009e+00]), + ) + assert_array_almost_equal( + out.sd_beta, + np.array([ 7.3621186811330963e-01, 3.5068899941471650e-04, + 2.4451209281408992e-04]), + ) + assert_array_almost_equal( + out.cov_beta, + np.array([[ 2.4714409064597873e-01, -6.9067261911110836e-05, + -3.1236953270424990e-05], + [ -6.9067261911110836e-05, 5.6077531517333009e-08, + 3.6133261832722601e-08], + [ -3.1236953270424990e-05, 3.6133261832722601e-08, + 2.7261220025171730e-08]]), + ) + + +if __name__ == "__main__": + NumpyTest().run() + +#### EOF ####################################################################### Deleted: trunk/Lib/odr/tests/test_odrpack.py =================================================================== --- trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 19:45:34 UTC (rev 2595) +++ trunk/Lib/odr/tests/test_odrpack.py 2007-01-23 20:14:51 UTC (rev 2596) @@ -1,317 +0,0 @@ - -# Standard library imports. -import cPickle - -# Scipy imports. -import numpy as np -from numpy import pi -from numpy.testing import NumpyTest, NumpyTestCase, assert_array_almost_equal -from scipy.odr import Data, Model, ODR, RealData, odr_stop - - -class test_odr(NumpyTestCase): - - # Explicit Example - - def explicit_fcn(self, B, x): - ret = B[0] + B[1] * np.power(np.exp(B[2]*x) - 1.0, 2) - return ret - - def explicit_fjd(self, B, x): - eBx = np.exp(B[2]*x) - ret = B[1] * 2.0 * (eBx-1.0) * B[2] * eBx - return ret - - def explicit_fjb(self, B, x): - eBx = np.exp(B[2]*x) - res = np.vstack([np.ones(x.shape[-1]), - np.power(eBx-1.0, 2), - B[1]*2.0*(eBx-1.0)*eBx*x]) - return res - - def test_explicit(self): - explicit_mod = Model( - self.explicit_fcn, - fjacb=self.explicit_fjb, - fjacd=self.explicit_fjd, - meta=dict(name='Sample Explicit Model', - ref='ODRPACK UG, pg. 39'), - ) - explicit_dat = Data([0.,0.,5.,7.,7.5,10.,16.,26.,30.,34.,34.5,100.], - [1265.,1263.6,1258.,1254.,1253.,1249.8,1237.,1218.,1220.6, - 1213.8,1215.5,1212.]) - explicit_odr = ODR(explicit_dat, explicit_mod, beta0=[1500.0, -50.0, -0.1], - ifixx=[0,0,1,1,1,1,1,1,1,1,1,0]) - explicit_odr.set_job(deriv=2) - - out = explicit_odr.run() - assert_array_almost_equal( - out.beta, - np.array([ 1.2646548050648876e+03, -5.4018409956678255e+01, - -8.7849712165253724e-02]), - ) - assert_array_almost_equal( - out.sd_beta, - np.array([ 1.0349270280543437, 1.583997785262061 , 0.0063321988657267]), - ) - assert_array_almost_equal( - out.cov_beta, - np.array([[ 4.4949592379003039e-01, -3.7421976890364739e-01, - -8.0978217468468912e-04], - [ -3.7421976890364739e-01, 1.0529686462751804e+00, - -1.9453521827942002e-03], - [ -8.0978217468468912e-04, -1.9453521827942002e-03, - 1.6827336938454476e-05]]), - ) - - - # Implicit Example - - def implicit_fcn(self, B, x): - return (B[2]*np.power(x[0]-B[0], 2) + - 2.0*B[3]*(x[0]-B[0])*(x[1]-B[1]) + - B[4]*np.power(x[1]-B[1], 2) - 1.0) - - def test_implicit(self): - implicit_mod = Model( - self.implicit_fcn, - implicit=1, - meta=dict(name='Sample Implicit Model', - ref='ODRPACK UG, pg. 49'), - ) - implicit_dat = Data([ - [0.5,1.2,1.6,1.86,2.12,2.36,2.44,2.36,2.06,1.74,1.34,0.9,-0.28, - -0.78,-1.36,-1.9,-2.5,-2.88,-3.18,-3.44], - [-0.12,-0.6,-1.,-1.4,-2.54,-3.36,-4.,-4.75,-5.25,-5.64,-5.97,-6.32, - -6.44,-6.44,-6.41,-6.25,-5.88,-5.5,-5.24,-4.86]], - 1, - ) - implicit_odr = ODR(implicit_dat, implicit_mod, - beta0=[-1.0, -3.0, 0.09, 0.02, 0.08]) - - out = implicit_odr.run() - assert_array_almost_equal( - out.beta, - np.array([-0.9993809167281279, -2.9310484652026476, 0.0875730502693354, - 0.0162299708984738, 0.0797537982976416]), - ) - assert_array_almost_equal( - out.sd_beta, - np.array([ 0.1113840353364371, 0.1097673310686467, 0.0041060738314314, - 0.0027500347539902, 0.0034962501532468]), - ) - assert_array_almost_equal( - out.cov_beta, - np.array([[ 2.1089274602333052e+00, -1.9437686411979040e+00, - 7.0263550868344446e-02, -4.7175267373474862e-02, - 5.2515575927380355e-02], - [ -1.9437686411979040e+00, 2.0481509222414456e+00, - -6.1600515853057307e-02, 4.6268827806232933e-02, - -5.8822307501391467e-02], - [ 7.0263550868344446e-02, -6.1600515853057307e-02, - 2.8659542561579308e-03, -1.4628662260014491e-03, - 1.4528860663055824e-03], - [ -4.7175267373474862e-02, 4.6268827806232933e-02, - -1.4628662260014491e-03, 1.2855592885514335e-03, - -1.2692942951415293e-03], - [ 5.2515575927380355e-02, -5.8822307501391467e-02, - 1.4528860663055824e-03, -1.2692942951415293e-03, - 2.0778813389755596e-03]]), - ) - - - # Multi-variable Example - - def multi_fcn(self, B, x): - if (x < 0.0).any(): - raise odr_stop - theta = pi*B[3]/2. - ctheta = np.cos(theta) - stheta = np.sin(theta) - omega = np.power(2.*pi*x*np.exp(-B[2]), B[3]) - phi = np.arctan2((omega*stheta), (1.0 + omega*ctheta)) - r = (B[0] - B[1]) * np.power(np.sqrt(np.power(1.0 + omega*ctheta, 2) + - np.power(omega*stheta, 2)), -B[4]) - ret = np.vstack([B[1] + r*np.cos(B[4]*phi), - r*np.sin(B[4]*phi)]) - return ret - - def test_multi(self): - multi_mod = Model( - self.multi_fcn, - meta=dict(name='Sample Multi-Response Model', - ref='ODRPACK UG, pg. 56'), - ) - - multi_x = np.array([30.0, 50.0, 70.0, 100.0, 150.0, 200.0, 300.0, 500.0, - 700.0, 1000.0, 1500.0, 2000.0, 3000.0, 5000.0, 7000.0, 10000.0, - 15000.0, 20000.0, 30000.0, 50000.0, 70000.0, 100000.0, 150000.0]) - multi_y = np.array([ - [4.22, 4.167, 4.132, 4.038, 4.019, 3.956, 3.884, 3.784, 3.713, - 3.633, 3.54, 3.433, 3.358, 3.258, 3.193, 3.128, 3.059, 2.984, - 2.934, 2.876, 2.838, 2.798, 2.759], - [0.136, 0.167, 0.188, 0.212, 0.236, 0.257, 0.276, 0.297, 0.309, - 0.311, 0.314, 0.311, 0.305, 0.289, 0.277, 0.255, 0.24, 0.218, - 0.202, 0.182, 0.168, 0.153, 0.139], - ]) - n = len(multi_x) - multi_we = np.zeros((2, 2, n), dtype=float) - multi_ifixx = np.ones(n, dtype=int) - multi_delta = np.zeros(n, dtype=float) - - multi_we[0,0,:] = 559.6 - multi_we[1,0,:] = multi_we[0,1,:] = -1634.0 - multi_we[1,1,:] = 8397.0 - - for i in range(n): - if multi_x[i] < 100.0: - multi_ifixx[i] = 0 - elif multi_x[i] <= 150.0: - pass # defaults are fine - elif multi_x[i] <= 1000.0: - multi_delta[i] = 25.0 - elif multi_x[i] <= 10000.0: - multi_delta[i] = 560.0 - elif multi_x[i] <= 100000.0: - multi_delta[i] = 9500.0 - else: - multi_delta[i] = 144000.0 - if multi_x[i] == 100.0 or multi_x[i] == 150.0: - multi_we[:,:,i] = 0.0 - - multi_dat = Data(multi_x, multi_y, wd=1e-4/np.power(multi_x, 2), - we=multi_we) - multi_odr = ODR(multi_dat, multi_mod, beta0=[4.,2.,7.,.4,.5], - delta0=multi_delta, ifixx=multi_ifixx) - multi_odr.set_job(deriv=1, del_init=1) - - out = multi_odr.run() - assert_array_almost_equal( - out.beta, - np.array([ 4.3799880305938963, 2.4333057577497703, 8.0028845899503978, - 0.5101147161764654, 0.5173902330489161]), - ) - assert_array_almost_equal( - out.sd_beta, - np.array([ 0.0130625231081944, 0.0130499785273277, 0.1167085962217757, - 0.0132642749596149, 0.0288529201353984]), - ) - assert_array_almost_equal( - out.cov_beta, - np.array([[ 0.0064918418231375, 0.0036159705923791, 0.0438637051470406, - -0.0058700836512467, 0.011281212888768 ], - [ 0.0036159705923791, 0.0064793789429006, 0.0517610978353126, - -0.0051181304940204, 0.0130726943624117], - [ 0.0438637051470406, 0.0517610978353126, 0.5182263323095322, - -0.0563083340093696, 0.1269490939468611], - [-0.0058700836512467, -0.0051181304940204, -0.0563083340093696, - 0.0066939246261263, -0.0140184391377962], - [ 0.011281212888768 , 0.0130726943624117, 0.1269490939468611, - -0.0140184391377962, 0.0316733013820852]]), - ) - - - # Pearson's Data - # K. Pearson, Philosophical Magazine, 2, 559 (1901) - - def pearson_fcn(self, B, x): - return B[0] + B[1]*x - - def test_pearson(self): - p_x = np.array([0.,.9,1.8,2.6,3.3,4.4,5.2,6.1,6.5,7.4]) - p_y = np.array([5.9,5.4,4.4,4.6,3.5,3.7,2.8,2.8,2.4,1.5]) - p_sx = np.array([.03,.03,.04,.035,.07,.11,.13,.22,.74,1.]) - p_sy = np.array([1.,.74,.5,.35,.22,.22,.12,.12,.1,.04]) - - p_dat = RealData(p_x, p_y, sx=p_sx, sy=p_sy) - - # Reverse the data to test invariance of results - pr_dat = RealData(p_y, p_x, sx=p_sy, sy=p_sx) - - p_mod = Model(self.pearson_fcn, meta=dict(name='Uni-linear Fit')) - - p_odr = ODR(p_dat, p_mod, beta0=[1.,1.]) - pr_odr = ODR(pr_dat, p_mod, beta0=[1.,1.]) - - out = p_odr.run() - assert_array_almost_equal( - out.beta, - np.array([ 5.4767400299231674, -0.4796082367610305]), - ) - assert_array_almost_equal( - out.sd_beta, - np.array([ 0.3590121690702467, 0.0706291186037444]), - ) - assert_array_almost_equal( - out.cov_beta, - np.array([[ 0.0854275622946333, -0.0161807025443155], - [-0.0161807025443155, 0.003306337993922 ]]), - ) - - rout = pr_odr.run() - assert_array_almost_equal( - rout.beta, - np.array([ 11.4192022410781231, -2.0850374506165474]), - ) - assert_array_almost_equal( - rout.sd_beta, - np.array([ 0.9820231665657161, 0.3070515616198911]), - ) - assert_array_almost_equal( - rout.cov_beta, - np.array([[ 0.6391799462548782, -0.1955657291119177], - [-0.1955657291119177, 0.0624888159223392]]), - ) - - # Lorentz Peak - # The data is taken from one of the undergraduate physics labs I performed. - - def lorentz(self, beta, x): - return (beta[0]*beta[1]*beta[2] / np.sqrt(np.power(x*x - - beta[2]*beta[2], 2.0) + np.power(beta[1]*x, 2.0))) - - def test_lorentz(self): - l_sy = np.array([.29]*18) - l_sx = np.array([.000972971,.000948268,.000707632,.000706679, - .000706074, .000703918,.000698955,.000456856, - .000455207,.000662717,.000654619,.000652694, - .000000859202,.00106589,.00106378,.00125483, .00140818,.00241839]) - - l_dat = RealData( - [3.9094, 3.85945, 3.84976, 3.84716, 3.84551, 3.83964, 3.82608, - 3.78847, 3.78163, 3.72558, 3.70274, 3.6973, 3.67373, 3.65982, - 3.6562, 3.62498, 3.55525, 3.41886], - [652, 910.5, 984, 1000, 1007.5, 1053, 1160.5, 1409.5, 1430, 1122, - 957.5, 920, 777.5, 709.5, 698, 578.5, 418.5, 275.5], - sx=l_sx, - sy=l_sy, - ) - l_mod = Model(self.lorentz, meta=dict(name='Lorentz Peak')) - l_odr = ODR(l_dat, l_mod, beta0=(1000., .1, 3.8)) - - out = l_odr.run() - assert_array_almost_equal( - out.beta, - np.array([ 1.4306780846149925e+03, 1.3390509034538309e-01, - 3.7798193600109009e+00]), - ) - assert_array_almost_equal( - out.sd_beta, - np.array([ 7.3621186811330963e-01, 3.5068899941471650e-04, - 2.4451209281408992e-04]), - ) - assert_array_almost_equal( - out.cov_beta, - np.array([[ 2.4714409064597873e-01, -6.9067261911110836e-05, - -3.1236953270424990e-05], - [ -6.9067261911110836e-05, 5.6077531517333009e-08, - 3.6133261832722601e-08], - [ -3.1236953270424990e-05, 3.6133261832722601e-08, - 2.7261220025171730e-08]]), - ) - - -if __name__ == "__main__": - NumpyTest().run() - -#### EOF ####################################################################### From scipy-svn at scipy.org Tue Jan 23 15:15:52 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 14:15:52 -0600 (CST) Subject: [Scipy-svn] r2597 - trunk/Lib/odr Message-ID: <20070123201552.0FC5239C113@new.scipy.org> Author: jarrod.millman Date: 2007-01-23 14:15:49 -0600 (Tue, 23 Jan 2007) New Revision: 2597 Added: trunk/Lib/odr/info.py Log: whoops. here is the info.py Added: trunk/Lib/odr/info.py =================================================================== --- trunk/Lib/odr/info.py 2007-01-23 20:14:51 UTC (rev 2596) +++ trunk/Lib/odr/info.py 2007-01-23 20:15:49 UTC (rev 2597) @@ -0,0 +1,44 @@ +"""Orthogonal Distance Regression + +Introduction +============ + +Why Orthogonal Distance Regression (ODR)? Sometimes one has measurement errors +in the explanatory variable, not just the response variable. Ordinary Least +Squares (OLS) fitting procedures treat the data for explanatory variables as +fixed. Furthermore, OLS procedures require that the response variable be an +explicit function of the explanatory variables; sometimes making the equation +explicit is unwieldy and introduces errors. ODR can handle both of these cases +with ease and can even reduce to the OLS case if necessary. + +ODRPACK is a FORTRAN-77 library for performing ODR with possibly non-linear +fitting functions. It uses a modified trust-region Levenberg-Marquardt-type +algorithm to estimate the function parameters. The fitting functions are +provided by Python functions operating on NumPy arrays. The required derivatives +may be provided by Python functions as well or may be numerically estimated. +ODRPACK can do explicit or implicit ODR fits or can do OLS. Input and output +variables may be multi-dimensional. Weights can be provided to account for +different variances of the observations (even covariances between dimensions of +the variables). + +odr provides two interfaces: a single function and a set of high-level classes +that wrap that function. Please refer to their docstrings for more information. +While the docstring of the function, odr, does not have a full explanation of +its arguments, the classes do, and the arguments with the same name usually have +the same requirements. Furthermore, it is highly suggested that one at least +skim the ODRPACK User's Guide. Know Thy Algorithm. + + +Use +=== + +See the docstrings of odr.odrpack and the functions and classes for +usage instructions. The ODRPACK User's Guide is also quite helpful. It can be +found on one of the ODRPACK's original author's website: + + http://www.boulder.nist.gov/mcsd/Staff/JRogers/odrpack.html + +Robert Kern +robert.kern at gmail.com +""" +postpone_import = 1 From scipy-svn at scipy.org Tue Jan 23 15:28:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 14:28:11 -0600 (CST) Subject: [Scipy-svn] r2598 - trunk/Lib/sandbox/timeseries Message-ID: <20070123202811.E8D6E39C12F@new.scipy.org> Author: mattknox_ca Date: 2007-01-23 14:28:08 -0600 (Tue, 23 Jan 2007) New Revision: 2598 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: added None as a synonym for "UNDEFINED" observed setting Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-23 20:15:49 UTC (rev 2597) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-23 20:28:08 UTC (rev 2598) @@ -42,7 +42,7 @@ #####--------------------------------------------------------------------------- #---- --- Option conversion --- #####--------------------------------------------------------------------------- -fmtobs_dict = {'UNDEFINED': ['UNDEF','UNDEFINED'], +fmtobs_dict = {'UNDEFINED': ['UNDEF','UNDEFINED',None], 'BEGINNING': ['BEGIN','BEGINNING'], 'ENDING': ['END','ENDING'], 'AVERAGED': ['AVERAGE','AVERAGE','MEAN'], @@ -50,7 +50,8 @@ 'MAXIMUM': ['MAX','MAXIMUM','HIGH'], 'MINIMUM': ['MIN','MINIMUM','LOW']} -obs_dict = {"UNDEFINED":None, +obs_dict = {None:None, + "UNDEFINED":None, "UNDEF":None, "BEGIN": first_unmasked_val, "BEGINNING": first_unmasked_val, @@ -73,7 +74,7 @@ def fmtObserv(obStr): "Converts a possible 'Observed' string into acceptable values." if obStr is None: - return None + return fmtobs_revdict[None] elif obStr.upper() in fmtobs_revdict: return fmtobs_revdict[obStr.upper()] else: From scipy-svn at scipy.org Tue Jan 23 15:30:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 14:30:33 -0600 (CST) Subject: [Scipy-svn] r2599 - trunk/Lib/sandbox/timeseries Message-ID: <20070123203033.18E5239C12F@new.scipy.org> Author: mattknox_ca Date: 2007-01-23 14:30:30 -0600 (Tue, 23 Jan 2007) New Revision: 2599 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: various bug fixes. Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-23 20:28:08 UTC (rev 2598) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-23 20:30:30 UTC (rev 2599) @@ -146,11 +146,6 @@ ##### -------------------------------------------------------------------------- ##--- ... Time Series ... ##### -------------------------------------------------------------------------- -#if oldma: -# parentclass = ndarray -#else: -# parentclass = MaskedArray -# class TimeSeries(MaskedArray, object): """Base class for the definition of time series. A time series is here defined as the combination of three arrays: @@ -192,8 +187,10 @@ else: freq = newdates.freq # Check observed....... - if observed is not None: - observed = data._observed + if observed is None: + observed = data.observed + else: + observed = corelib.fmtObserv(observed) cls._defaultobserved = observed _data = data._series else: @@ -210,18 +207,8 @@ if hasattr(data, '_mask') : mask = mask_or(data._mask, mask) cls._defaultdates = newdates - cls._defaultobserved = observed -# if oldma: -# newdata = MaskedArray(data, mask=mask, dtype=dtype, -# copy=copy,fill_value=fill_value) -# cls._defaultmask = newdata._mask -# cls._defaulthardmask = True -# cls._fill_value = newdata._fill_value -# assert(_datadatescompat(newdata,dates)) -# return ndarray.__new__(cls,shape=newdata.shape,dtype=newdata.dtype, -# buffer=newdata._data) -# _data = data -# newdata = MaskedArray.__new__(cls, data=_data, mask=mask, **options) + cls._defaultobserved = corelib.fmtObserv(observed) + newdata = super(TimeSeries,cls).__new__(cls, _data, mask=mask, **options) assert(_datadatescompat(newdata._data,newdates)) @@ -229,11 +216,6 @@ #.................................. def __array_wrap__(self, obj, context=None): -# if oldma: -# tmpself = MaskedArray(self._data, mask=self._mask) -# return TimeSeries(MaskedArray.__array_wrap__(tmpself, obj, context), -# dates=self._dates) -# print "__array_wrap__" return TimeSeries(super(TimeSeries,self).__array_wrap__(obj, context), dates=self._dates) #............................................ @@ -605,7 +587,7 @@ else: return instance.__class__(func_series(*args), dates=instance._dates) -#TimeSeries.astype = _tsarraymethod('astype') +TimeSeries.astype = _tsarraymethod('astype') TimeSeries.reshape = _tsarraymethod('reshape', ondates=True) TimeSeries.copy = _tsarraymethod('copy', ondates=True) TimeSeries.compress = _tsarraymethod('compress', ondates=True) @@ -1072,7 +1054,7 @@ tempData = series._series.filled() tempMask = getmaskarray(series) - cRetVal = cseries.reindex(tempData, fromFreq, toFreq, position, + cRetVal = cseries.convert(tempData, fromFreq, toFreq, position, int(start_date), tempMask) _values = cRetVal['values'] _mask = cRetVal['mask'] @@ -1084,13 +1066,12 @@ if tempData.ndim == 2 and func is not None: tempData = MA.apply_along_axis(func, -1, tempData) -# newEnd = series._dates[-1].asfreq(toFreq, "AFTER") - newseries = TimeSeries(tempData, freq=toFreq, observed=series.observed, start_date=start_date) return newseries -# return adjust_endpoints(newseries, end_date=newEnd) + + TimeSeries.convert = convert #.................................................................... def fill_missing_dates(data, dates=None, freq=None,fill_value=None): From scipy-svn at scipy.org Tue Jan 23 15:42:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 14:42:53 -0600 (CST) Subject: [Scipy-svn] r2600 - trunk/Lib/sparse/sparsetools Message-ID: <20070123204253.AE4CD39C091@new.scipy.org> Author: wnbell Date: 2007-01-23 14:42:51 -0600 (Tue, 23 Jan 2007) New Revision: 2600 Modified: trunk/Lib/sparse/sparsetools/numpy.i trunk/Lib/sparse/sparsetools/sparsetools.h trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx Log: Fixed 'unused int i' warning Fixed small bug with istart in sparsetools.h Modified: trunk/Lib/sparse/sparsetools/numpy.i =================================================================== --- trunk/Lib/sparse/sparsetools/numpy.i 2007-01-23 20:30:30 UTC (rev 2599) +++ trunk/Lib/sparse/sparsetools/numpy.i 2007-01-23 20:42:51 UTC (rev 2600) @@ -401,7 +401,6 @@ /* One dimensional input/output arrays */ %define TYPEMAP_INPLACE1(type,typecode) %typemap(in) (type* INPLACE_ARRAY) (PyArrayObject* temp=NULL) { - int i; temp = obj_to_array_no_conversion($input,typecode); if (!temp || !require_contiguous(temp)) SWIG_fail; $1 = (type*) temp->data; Modified: trunk/Lib/sparse/sparsetools/sparsetools.h =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools.h 2007-01-23 20:30:30 UTC (rev 2599) +++ trunk/Lib/sparse/sparsetools/sparsetools.h 2007-01-23 20:42:51 UTC (rev 2600) @@ -227,7 +227,7 @@ std::vector sums(n_col,zero); for(I i = 0; i < n_row; i++){ - I istart = -1; + I istart = -2; I length = 0; for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ @@ -314,7 +314,7 @@ std::vector sums(n_col,zero); for(I i = 0; i < n_row; i++){ - I istart = -1; + I istart = -2; I length = 0; //add a row of A to sums @@ -409,7 +409,7 @@ std::vector B_row(n_col,zero); for(I i = 0; i < n_row; i++){ - I istart = -1; + I istart = -2; I length = 0; //add a row of A to A_row Modified: trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx =================================================================== --- trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-23 20:30:30 UTC (rev 2599) +++ trunk/Lib/sparse/sparsetools/sparsetools_wrap.cxx 2007-01-23 20:42:51 UTC (rev 2600) @@ -21314,7 +21314,6 @@ arg3 = (int*) array3->data; } { - int i; temp4 = obj_to_array_no_conversion(obj3,PyArray_INT); if (!temp4 || !require_contiguous(temp4)) SWIG_fail; arg4 = (int*) temp4->data; @@ -21379,13 +21378,11 @@ arg3 = (int*) array3->data; } { - int i; temp4 = obj_to_array_no_conversion(obj3,PyArray_INT); if (!temp4 || !require_contiguous(temp4)) SWIG_fail; arg4 = (int*) temp4->data; } { - int i; temp5 = obj_to_array_no_conversion(obj4,PyArray_LONG); if (!temp5 || !require_contiguous(temp5)) SWIG_fail; arg5 = (long*) temp5->data; @@ -21445,13 +21442,11 @@ arg3 = (int*) array3->data; } { - int i; temp4 = obj_to_array_no_conversion(obj3,PyArray_INT); if (!temp4 || !require_contiguous(temp4)) SWIG_fail; arg4 = (int*) temp4->data; } { - int i; temp5 = obj_to_array_no_conversion(obj4,PyArray_FLOAT); if (!temp5 || !require_contiguous(temp5)) SWIG_fail; arg5 = (float*) temp5->data; @@ -21511,13 +21506,11 @@ arg3 = (int*) array3->data; } { - int i; temp4 = obj_to_array_no_conversion(obj3,PyArray_INT); if (!temp4 || !require_contiguous(temp4)) SWIG_fail; arg4 = (int*) temp4->data; } { - int i; temp5 = obj_to_array_no_conversion(obj4,PyArray_DOUBLE); if (!temp5 || !require_contiguous(temp5)) SWIG_fail; arg5 = (double*) temp5->data; @@ -21577,13 +21570,11 @@ arg3 = (int*) array3->data; } { - int i; temp4 = obj_to_array_no_conversion(obj3,PyArray_INT); if (!temp4 || !require_contiguous(temp4)) SWIG_fail; arg4 = (int*) temp4->data; } { - int i; temp5 = obj_to_array_no_conversion(obj4,PyArray_CFLOAT); if (!temp5 || !require_contiguous(temp5)) SWIG_fail; arg5 = (npy_cfloat*) temp5->data; @@ -21643,13 +21634,11 @@ arg3 = (int*) array3->data; } { - int i; temp4 = obj_to_array_no_conversion(obj3,PyArray_INT); if (!temp4 || !require_contiguous(temp4)) SWIG_fail; arg4 = (int*) temp4->data; } { - int i; temp5 = obj_to_array_no_conversion(obj4,PyArray_CDOUBLE); if (!temp5 || !require_contiguous(temp5)) SWIG_fail; arg5 = (npy_cdouble*) temp5->data; From scipy-svn at scipy.org Tue Jan 23 16:05:29 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 15:05:29 -0600 (CST) Subject: [Scipy-svn] r2601 - trunk/Lib/sandbox/timeseries Message-ID: <20070123210529.837CA39C091@new.scipy.org> Author: pierregm Date: 2007-01-23 15:05:27 -0600 (Tue, 23 Jan 2007) New Revision: 2601 Modified: trunk/Lib/sandbox/timeseries/CHANGELOG trunk/Lib/sandbox/timeseries/tdates.py Log: cf changelog Modified: trunk/Lib/sandbox/timeseries/CHANGELOG =================================================================== --- trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-23 20:42:51 UTC (rev 2600) +++ trunk/Lib/sandbox/timeseries/CHANGELOG 2007-01-23 21:05:27 UTC (rev 2601) @@ -1,3 +1,4 @@ +#2007-01-23 : tdates : forced a 'U' to 'D' when using asfreq #2007-01-15 : tmulti : Add the module and its tests, to support multi-variable series # : tdates : Some minor bug fixes # : tseries: Fixed a bug in __new__ when data are lists Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-23 20:42:51 UTC (rev 2600) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-23 21:05:27 UTC (rev 2601) @@ -456,7 +456,7 @@ def asfreq(date, toFreq, relation="BEFORE"): """Returns a date converted to another frequency `toFreq`, according to the relation `relation` .""" - toFreq = corelib.fmtFreq(toFreq) + tofreq = corelib.fmtFreq(toFreq) _rel = relation.upper()[0] if _rel not in ['B', 'A']: msg = "Invalid relation '%s': Should be in ['before', 'after']" @@ -465,12 +465,18 @@ if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" - if date.freq == toFreq: + if date.freq == 'U': + warnings.warn("Undefined frequency: assuming daily!") + fromfreq = 'D' + else: + fromfreq = date.freq + + if fromfreq == tofreq: return date else: - value = cseries.asfreq(numeric.asarray(date.value), date.freq, toFreq, _rel) + value = cseries.asfreq(numeric.asarray(date.value), fromfreq, tofreq, _rel) if value > 0: - return Date(freq=toFreq, value=value) + return Date(freq=tofreq, value=value) else: return None @@ -657,11 +663,16 @@ # Note: As we define a new object, we don't need caching if freq is None: return self - freq = corelib.fmtFreq(freq) - if freq == self.freq: + tofreq = corelib.fmtFreq(freq) + if tofreq == self.freq: return self + if self.freq == 'U': + warnings.warn("Undefined frequency: assuming daily!") + fromfreq = 'D' + else: + fromfreq = self.freq _rel = relation.upper()[0] - new = cseries.asfreq(numeric.asarray(self), self.freq, freq, _rel) + new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) return DateArray(new, freq=freq) #...................................................... def find_dates(self, *dates): @@ -676,17 +687,7 @@ if fromnumeric.size(c) == 0: raise ValueError, "Date out of bounds!" return c -# def find_dates_alt(self, *dates): -# "Returns the indices corresponding to given dates, as an array." -# ifreq = self.freq -# c = numpy.zeros(self.shape, bool_) -# dates = date_array([d for d in corelib.flatargs(*dates)]).asfreq(ifreq) -# for d in numeric.asarray(dates): -# c += (self == d) -# c = c.nonzero() -# if fromnumeric.size(c) == 0: -# raise ValueError, "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(): From scipy-svn at scipy.org Tue Jan 23 16:16:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 23 Jan 2007 15:16:01 -0600 (CST) Subject: [Scipy-svn] r2602 - trunk/Lib/sandbox/timeseries Message-ID: <20070123211601.77CBB39C091@new.scipy.org> Author: mattknox_ca Date: 2007-01-23 15:15:58 -0600 (Tue, 23 Jan 2007) New Revision: 2602 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: added missing date info properties for TimeSeries class. Set start_date and end_date methods as properties. Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-23 21:05:27 UTC (rev 2601) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-23 21:15:58 UTC (rev 2602) @@ -109,9 +109,9 @@ return True if a.freq != b.freq: raise TimeSeriesCompatibilityError('freq', a.freq, b.freq) - elif a.start_date() != b.start_date(): + elif a.start_date != b.start_date: raise TimeSeriesCompatibilityError('start_date', - a.start_date(), b.start_date()) + a.start_date, b.start_date) elif (a._dates.get_steps() != b._dates.get_steps()).any(): raise TimeSeriesCompatibilityError('time_steps', a._dates.get_steps(), b._dates.get_steps()) @@ -416,32 +416,70 @@ def freq(self): """Returns the corresponding frequency.""" return self._dates.freq -# @property - def years(self): - """Returns the corresponding years.""" - return self._dates.years -# @property - def months(self): - """Returns the corresponding months.""" - return self._dates.months -# @property - def yeardays(self): - """Returns the corresponding days of year.""" - return self._dates.yeardays - day_of_year = yeardays -# @property - def weekdays(self): - """Returns the corresponding days of weeks.""" + + @property + def day(self): + "Returns the day of month for each date in self._dates." + return self._dates.day + @property + def day_of_week(self): + "Returns the day of week for each date in self._dates." return self._dates.day_of_week - day_of_week = weekdays + @property + 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): + "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." + return self._dates.quarter + @property + 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." + return self._dates.second + @property + def minute(self): + "Returns the minutes for each date in self._dates." + return self._dates.minute + @property + def hour(self): + "Returns the hour for each date in self._dates." + return self._dates.hour + @property + def week(self): + "Returns the week for each date in self._dates." + return self._dates.week + + days = day + weekdays = day_of_week + yeardays = day_of_year + months = month + quarters = quarter + years = year + seconds = second + minutes = minute + hours = hour + weeks = week + + @property def start_date(self): """Returns the first date of the series.""" return self._dates[0] -# + + @property def end_date(self): """Returns the last date of the series.""" return self._dates[-1] + def isvalid(self): """Returns whether the series has no duplicate/missing dates.""" @@ -1003,10 +1041,10 @@ 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 isinstance(start_date,str): start_date = Date(common_freq, string=start_date) - end_date = kwargs.pop('end_date', max([x.end_date() for x in series])) + end_date = kwargs.pop('end_date', max([x.end_date for x in series])) if isinstance(end_date,str): end_date = Date(common_freq, string=end_date) From scipy-svn at scipy.org Wed Jan 24 04:22:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 03:22:15 -0600 (CST) Subject: [Scipy-svn] r2603 - trunk/Lib/cluster Message-ID: <20070124092215.BACC039C015@new.scipy.org> Author: jarrod.millman Date: 2007-01-24 03:21:49 -0600 (Wed, 24 Jan 2007) New Revision: 2603 Modified: trunk/Lib/cluster/vq.py Log: fixed typo in docstring Modified: trunk/Lib/cluster/vq.py =================================================================== --- trunk/Lib/cluster/vq.py 2007-01-23 21:15:58 UTC (rev 2602) +++ trunk/Lib/cluster/vq.py 2007-01-24 09:21:49 UTC (rev 2603) @@ -94,13 +94,13 @@ The code book is usually generated using the kmeans algorithm. Each row of the array holds a different code, and the columns are the features of the code. - # c0 c1 c2 c3 - code_book = [[ 1., 2., 3., 4.], #f0 - [ 1., 2., 3., 4.], #f1 - [ 1., 2., 3., 4.]]) #f2 + # f0 f1 f2 f3 + code_book = [[ 1., 2., 3., 4.], #c0 + [ 1., 2., 3., 4.], #c1 + [ 1., 2., 3., 4.]]) #c2 Outputs: code -- 1D array. - If obs is a NxM array, then a length M array + If obs is a NxM array, then a length N array is returned that holds the selected code book index for each observation. dist -- 1D array. From scipy-svn at scipy.org Wed Jan 24 04:35:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 03:35:03 -0600 (CST) Subject: [Scipy-svn] r2604 - trunk/Lib/cluster Message-ID: <20070124093503.DAA8139C03B@new.scipy.org> Author: jarrod.millman Date: 2007-01-24 03:35:02 -0600 (Wed, 24 Jan 2007) New Revision: 2604 Modified: trunk/Lib/cluster/vq.py Log: added imports to doctests Modified: trunk/Lib/cluster/vq.py =================================================================== --- trunk/Lib/cluster/vq.py 2007-01-24 09:21:49 UTC (rev 2603) +++ trunk/Lib/cluster/vq.py 2007-01-24 09:35:02 UTC (rev 2604) @@ -18,9 +18,9 @@ __all__ = ['whiten', 'vq', 'kmeans'] from numpy.random import randint -from scipy.stats import std, mean from numpy import shape, zeros, subtract, sqrt, argmin, minimum, array, \ newaxis, arange, compress, equal, common_type, single, double, take +from scipy.stats import std, mean def whiten(obs): """ Normalize a group of observations on a per feature basis @@ -54,6 +54,8 @@ Test + >>> from numpy import array + >>> from scipy.cluster.vq import whiten >>> features = array([[ 1.9,2.3,1.7], ... [ 1.5,2.5,2.2], ... [ 0.8,0.6,1.7,]]) @@ -110,6 +112,8 @@ Test + >>> from numpy import array + >>> from scipy.cluster.vq import vq >>> code_book = array([[1.,1.,1.], ... [2.,2.,2.]]) >>> features = array([[ 1.9,2.3,1.7], @@ -192,6 +196,8 @@ Note: not whitened in this example. + >>> from numpy import array + >>> from scipy.cluster.vq import kmeans_ >>> features = array([[ 1.9,2.3], ... [ 1.5,2.5], ... [ 0.8,0.6], @@ -264,6 +270,8 @@ ("Not checked carefully for accuracy..." he said sheepishly) + >>> from numpy import array + >>> from scipy.cluster.vq import vq, kmeans >>> features = array([[ 1.9,2.3], ... [ 1.5,2.5], ... [ 0.8,0.6], From scipy-svn at scipy.org Wed Jan 24 06:35:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 05:35:01 -0600 (CST) Subject: [Scipy-svn] r2605 - trunk/Lib/linsolve/umfpack Message-ID: <20070124113501.E67ADC7C007@new.scipy.org> Author: rc Date: 2007-01-24 05:34:56 -0600 (Wed, 24 Jan 2007) New Revision: 2605 Modified: trunk/Lib/linsolve/umfpack/umfpack.i Log: update for SWIG > 1.3.29 Modified: trunk/Lib/linsolve/umfpack/umfpack.i =================================================================== --- trunk/Lib/linsolve/umfpack/umfpack.i 2007-01-24 09:35:02 UTC (rev 2604) +++ trunk/Lib/linsolve/umfpack/umfpack.i 2007-01-24 11:34:56 UTC (rev 2605) @@ -1,3 +1,6 @@ +/* -*- C -*- */ +#ifdef SWIGPYTHON + %module _umfpack /* @@ -91,7 +94,7 @@ - 30.11.2005, c */ #define ARRAY_IN( rtype, ctype, atype ) \ -%typemap( python, in ) (ctype *array) { \ +%typemap( in ) (ctype *array) { \ PyArrayObject *obj; \ obj = helper_getCArrayObject( $input, PyArray_##atype, 1, 1 ); \ if (!obj) return NULL; \ @@ -104,7 +107,7 @@ - 30.11.2005, c */ #define CONF_IN( arSize ) \ -%typemap( python, in ) (double conf [arSize]) { \ +%typemap( in ) (double conf [arSize]) { \ PyArrayObject *obj; \ obj = helper_getCArrayObject( $input, PyArray_DOUBLE, 1, 1 ); \ if (!obj) return NULL; \ @@ -122,10 +125,10 @@ - 02.12.2005 */ #define OPAQUE_ARGOUT( ttype ) \ -%typemap( python, in, numinputs=0 ) ttype* opaque_argout( ttype tmp ) { \ +%typemap( in, numinputs=0 ) ttype* opaque_argout( ttype tmp ) { \ $1 = &tmp; \ }; \ -%typemap( python, argout ) ttype* opaque_argout { \ +%typemap( argout ) ttype* opaque_argout { \ PyObject *obj; \ obj = SWIG_NewPointerObj( (ttype) (*$1), $*1_descriptor, 1 ); \ $result = helper_appendToTuple( $result, obj ); \ @@ -136,12 +139,12 @@ - 02.12.2005, c */ #define OPAQUE_ARGINOUT( ttype ) \ -%typemap( python, in ) ttype* opaque_arginout( ttype tmp ) { \ +%typemap( in ) ttype* opaque_arginout( ttype tmp ) { \ if ((SWIG_ConvertPtr( $input,(void **) &tmp, $*1_descriptor, \ SWIG_POINTER_EXCEPTION)) == -1) return NULL; \ $1 = &tmp; \ }; \ -%typemap( python, argout ) ttype* opaque_arginout { \ +%typemap( argout ) ttype* opaque_arginout { \ PyObject *obj; \ obj = SWIG_NewPointerObj( (ttype) (*$1), $*1_descriptor, 1 ); \ $result = helper_appendToTuple( $result, obj ); \ @@ -266,3 +269,5 @@ }; %apply int *OUTPUT { int *do_recip}; %include + +#endif From scipy-svn at scipy.org Wed Jan 24 08:53:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 07:53:26 -0600 (CST) Subject: [Scipy-svn] r2606 - in trunk/Lib/linsolve: . umfpack/tests Message-ID: <20070124135326.ADA1239C03B@new.scipy.org> Author: rc Date: 2007-01-24 07:53:11 -0600 (Wed, 24 Jan 2007) New Revision: 2606 Modified: trunk/Lib/linsolve/linsolve.py trunk/Lib/linsolve/umfpack/tests/test_umfpack.py Log: sparse rhs in spsolve Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-01-24 11:34:56 UTC (rev 2605) +++ trunk/Lib/linsolve/linsolve.py 2007-01-24 13:53:11 UTC (rev 2606) @@ -54,6 +54,9 @@ return mat def spsolve(A, b, permc_spec=2): + if isspmatrix( b ): + b = b.toarray() + if b.ndim > 1: if max( b.shape ) == b.size: b = b.squeeze() Modified: trunk/Lib/linsolve/umfpack/tests/test_umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-01-24 11:34:56 UTC (rev 2605) +++ trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-01-24 13:53:11 UTC (rev 2606) @@ -63,6 +63,15 @@ #print "Error: ", a*x-b assert_array_almost_equal(a*x, b) + def check_solve_sparse_rhs(self): + """Solve with UMFPACK: double precision, sparse rhs""" + linsolve.use_solver( useUmfpack = True ) + a = self.a.astype('d') + b = csc_matrix( self.b ) + x = linsolve.spsolve(a, b) + #print x + #print "Error: ", a*x-b + assert_array_almost_equal(a*x, self.b) def setUp(self): self.a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5) From scipy-svn at scipy.org Wed Jan 24 09:35:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 08:35:05 -0600 (CST) Subject: [Scipy-svn] r2607 - in trunk/Lib/linalg: . tests Message-ID: <20070124143505.0909739C1E8@new.scipy.org> Author: edschofield Date: 2007-01-24 08:35:01 -0600 (Wed, 24 Jan 2007) New Revision: 2607 Added: trunk/Lib/linalg/tests/test_iterative.py Modified: trunk/Lib/linalg/iterative.py Log: Added callbacks to linalg.iterative solvers Modified: trunk/Lib/linalg/iterative.py =================================================================== --- trunk/Lib/linalg/iterative.py 2007-01-24 13:53:11 UTC (rev 2606) +++ trunk/Lib/linalg/iterative.py 2007-01-24 14:35:01 UTC (rev 2607) @@ -108,7 +108,7 @@ class get_rpsolveq(get_psolveq): methname = 'rpsolve' -def bicg(A,b,x0=None,tol=1e-5,maxiter=None,xtype=None): +def bicg(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, callback=None): """Use BIConjugate Gradient iteration to solve A x = b Inputs: @@ -133,11 +133,15 @@ x0 -- (0) default starting guess tol -- (1e-5) relative tolerance to achieve maxiter -- (10*n) maximum number of iterations - xtype -- The type of the result. If None, then it will be determined - from A.dtype.char and b. If A does not have a typecode method then it will - compute A.matvec(x0) to get a typecode. To save the extra computation when - A does not have a typecode attribute use xtype=0 for the same type as b or - use xtype='f','d','F',or 'D' + xtype -- The type of the result. If None, then it will be + determined from A.dtype.char and b. If A does not have a + typecode method then it will compute A.matvec(x0) to get a + typecode. To save the extra computation when A does not + have a typecode attribute use xtype=0 for the same type as + b or use xtype='f','d','F',or 'D' + callback -- an optional user-supplied function to call after each + iteration. It is called as callback(xk), where xk is the + current parameter vector. """ b = sb.asarray(b)+0.0 n = len(b) @@ -180,9 +184,12 @@ ftflag = True bnrm2 = -1.0 iter_ = maxiter - while 1: + while True: + olditer = iter_ x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, work, iter_, resid, info, ndx1, ndx2, ijob) + if callback is not None and iter_ > olditer: + callback(x) slice1 = slice(ndx1-1, ndx1-1+n) slice2 = slice(ndx2-1, ndx2-1+n) if (ijob == -1): @@ -219,7 +226,8 @@ return x, info -def bicgstab(A,b,x0=None,tol=1e-5,maxiter=None,xtype=None): + +def bicgstab(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, callback=None): """Use BIConjugate Gradient STABilized iteration to solve A x = b Inputs: @@ -243,11 +251,15 @@ x0 -- (0) default starting guess tol -- (1e-5) relative tolerance to achieve maxiter -- (10*n) maximum number of iterations - xtype -- The type of the result. If None, then it will be determined - from A.dtype.char and b. If A does not have a typecode method then it will - compute A.matvec(x0) to get a typecode. To save the extra computation when - A does not have a typecode attribute use xtype=0 for the same type as b or - use xtype='f','d','F',or 'D' + xtype -- The type of the result. If None, then it will be + determined from A.dtype.char and b. If A does not have a + typecode method then it will compute A.matvec(x0) to get a + typecode. To save the extra computation when A does not + have a typecode attribute use xtype=0 for the same type as + b or use xtype='f','d','F',or 'D' + callback -- an optional user-supplied function to call after each + iteration. It is called as callback(xk), where xk is the + current parameter vector. """ b = sb.asarray(b)+0.0 n = len(b) @@ -290,9 +302,12 @@ ftflag = True bnrm2 = -1.0 iter_ = maxiter - while 1: + while True: + olditer = iter_ x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, work, iter_, resid, info, ndx1, ndx2, ijob) + if callback is not None and iter_ > olditer: + callback(x) slice1 = slice(ndx1-1, ndx1-1+n) slice2 = slice(ndx2-1, ndx2-1+n) if (ijob == -1): @@ -320,7 +335,8 @@ return x, info -def cg(A,b,x0=None,tol=1e-5,maxiter=None,xtype=None): + +def cg(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, callback=None): """Use Conjugate Gradient iteration to solve A x = b (A^H = A) Inputs: @@ -345,11 +361,15 @@ x0 -- (0) default starting guess tol -- (1e-5) relative tolerance to achieve maxiter -- (10*n) maximum number of iterations - xtype -- The type of the result. If None, then it will be determined - from A.dtype.char and b. If A does not have a typecode method then it will - compute A.matvec(x0) to get a typecode. To save the extra computation when - A does not have a typecode attribute use xtype=0 for the same type as b or - use xtype='f','d','F',or 'D' + xtype -- The type of the result. If None, then it will be + determined from A.dtype.char and b. If A does not have a + typecode method then it will compute A.matvec(x0) to get a + typecode. To save the extra computation when A does not + have a typecode attribute use xtype=0 for the same type as + b or use xtype='f','d','F',or 'D' + callback -- an optional user-supplied function to call after each + iteration. It is called as callback(xk), where xk is the + current parameter vector. """ b = sb.asarray(b)+0.0 n = len(b) @@ -392,9 +412,12 @@ ftflag = True bnrm2 = -1.0 iter_ = maxiter - while 1: + while True: + olditer = iter_ x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, work, iter_, resid, info, ndx1, ndx2, ijob) + if callback is not None and iter_ > olditer: + callback(x) slice1 = slice(ndx1-1, ndx1-1+n) slice2 = slice(ndx2-1, ndx2-1+n) if (ijob == -1): @@ -423,7 +446,7 @@ return x, info -def cgs(A,b,x0=None,tol=1e-5,maxiter=None,xtype=None): +def cgs(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, callback=None): """Use Conjugate Gradient Squared iteration to solve A x = b Inputs: @@ -448,11 +471,15 @@ x0 -- (0) default starting guess tol -- (1e-5) relative tolerance to achieve maxiter -- (10*n) maximum number of iterations - xtype -- The type of the result. If None, then it will be determined - from A.dtype.char and b. If A does not have a typecode method then it will - compute A.matvec(x0) to get a typecode. To save the extra computation when - A does not have a typecode attribute use xtype=0 for the same type as b or - use xtype='f','d','F',or 'D' + xtype -- The type of the result. If None, then it will be + determined from A.dtype.char and b. If A does not have a + typecode method then it will compute A.matvec(x0) to get a + typecode. To save the extra computation when A does not + have a typecode attribute use xtype=0 for the same type as + b or use xtype='f','d','F',or 'D' + callback -- an optional user-supplied function to call after each + iteration. It is called as callback(xk), where xk is the + current parameter vector. """ b = sb.asarray(b) + 0.0 n = len(b) @@ -495,9 +522,12 @@ ftflag = True bnrm2 = -1.0 iter_ = maxiter - while 1: + while True: + olditer = iter_ x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, work, iter_, resid, info, ndx1, ndx2, ijob) + if callback is not None and iter_ > olditer: + callback(x) slice1 = slice(ndx1-1, ndx1-1+n) slice2 = slice(ndx2-1, ndx2-1+n) if (ijob == -1): @@ -525,7 +555,8 @@ return x, info -def gmres(A,b,restrt=None,x0=None,tol=1e-5,maxiter=None,xtype=None): + +def gmres(A, b, x0=None, tol=1e-5, restrt=None, maxiter=None, xtype=None, callback=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: @@ -552,11 +583,15 @@ x0 -- (0) default starting guess tol -- (1e-5) relative tolerance to achieve maxiter -- (10*n) maximum number of iterations - xtype -- The type of the result. If None, then it will be determined - from A.dtype.char and b. If A does not have a dtype attribute then it will - compute A.matvec(x0) to get a data type. To save the extra computation when - A does not have a typecode attribute use xtype=0 for the same type as b or - use xtype='f','d','F',or 'D' + xtype -- The type of the result. If None, then it will be + determined from A.dtype.char and b. If A does not have a + typecode method then it will compute A.matvec(x0) to get a + typecode. To save the extra computation when A does not + have a typecode attribute use xtype=0 for the same type as + b or use xtype='f','d','F',or 'D' + callback -- an optional user-supplied function to call after each + iteration. It is called as callback(xk), where xk is the + current parameter vector. """ b = sb.asarray(b)+0.0 n = len(b) @@ -600,9 +635,12 @@ ftflag = True bnrm2 = -1.0 iter_ = maxiter - while 1: + while True: + olditer = iter_ x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, restrt, work, work2, iter_, resid, info, ndx1, ndx2, ijob) + if callback is not None and iter_ > olditer: + callback(x) slice1 = slice(ndx1-1, ndx1-1+n) slice2 = slice(ndx2-1, ndx2-1+n) if (ijob == -1): @@ -631,8 +669,8 @@ return x, info -def qmr(A,b,x0=None,tol=1e-5,maxiter=None,xtype=None): - """Use Quasi-Minimal Residucal iteration to solve A x = b +def qmr(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, callback=None): + """Use Quasi-Minimal Residual iteration to solve A x = b Inputs: @@ -657,11 +695,15 @@ x0 -- (0) default starting guess tol -- (1e-5) relative tolerance to achieve maxiter -- (10*n) maximum number of iterations - xtype -- The type of the result. If None, then it will be determined - from A.dtype.char and b. If A does not have a typecode method then it will - compute A.matvec(x0) to get a typecode. To save the extra computation when - A does not have a typecode attribute use xtype=0 for the same type as b or - use xtype='f','d','F',or 'D' + xtype -- The type of the result. If None, then it will be + determined from A.dtype.char and b. If A does not have a + typecode method then it will compute A.matvec(x0) to get a + typecode. To save the extra computation when A does not + have a typecode attribute use xtype=0 for the same type as + b or use xtype='f','d','F',or 'D' + callback -- an optional user-supplied function to call after each + iteration. It is called as callback(xk), where xk is the + current parameter vector. """ b = sb.asarray(b)+0.0 n = len(b) @@ -705,9 +747,12 @@ ftflag = True bnrm2 = -1.0 iter_ = maxiter - while 1: + while True: + olditer = iter_ x, iter_, resid, info, ndx1, ndx2, sclr1, sclr2, ijob = \ revcom(b, x, work, iter_, resid, info, ndx1, ndx2, ijob) + if callback is not None and iter_ > olditer: + callback(x) slice1 = slice(ndx1-1, ndx1-1+n) slice2 = slice(ndx2-1, ndx2-1+n) if (ijob == -1): Added: trunk/Lib/linalg/tests/test_iterative.py =================================================================== --- trunk/Lib/linalg/tests/test_iterative.py 2007-01-24 13:53:11 UTC (rev 2606) +++ trunk/Lib/linalg/tests/test_iterative.py 2007-01-24 14:35:01 UTC (rev 2607) @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# Created by: Ed Schofield, Jan 2007 +# +""" Test functions for the linalg.iterative module +""" +__usage__ = """ +Build linalg: + python setup_linalg.py build +Run tests if scipy is installed: + python -c 'import scipy;scipy.linalg.test()' +Run tests if linalg is not installed: + python tests/test_iterative.py [] +""" + +from numpy import zeros, dot, diag, ones +from numpy.testing import * +from numpy.random import rand +#from numpy import arange, add, array, dot, zeros, identity, conjugate, transpose + +import sys +set_package_path() +from linalg import iterative, norm, cg, cgs, bicg, bicgstab, gmres, qmr +restore_path() + + +def callback(x): + global A, b + res = b-dot(A,x) + print "||A.x - b|| = " + str(norm(dot(A,x)-b)) + +class test_iterative_solvers(NumpyTestCase): + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + self.setUp() + def setUp (self): + global A, b + n = 10 + self.tol = 1e-5 + self.x0 = zeros(n, float) + A = rand(n, n)+diag(4*ones(n)) + self.A = 0.5 * (A+A.T) + A = self.A + self.b = rand(n) + b = self.b + + def check_cg(self): + x, info = cg(self.A, self.b, self.x0, callback=callback) + assert norm(dot(self.A, x) - self.b) < 5*self.tol + + def check_bicg(self): + x, info = bicg(self.A, self.b, self.x0, callback=callback) + assert norm(dot(self.A, x) - self.b) < 5*self.tol + + def check_cgs(self): + x, info = cgs(self.A, self.b, self.x0, callback=callback) + assert norm(dot(self.A, x) - self.b) < 5*self.tol + + def check_bicgstab(self): + x, info = bicgstab(self.A, self.b, self.x0, callback=callback) + assert norm(dot(self.A, x) - self.b) < 5*self.tol + + def check_gmres(self): + x, info = gmres(self.A, self.b, self.x0, callback=callback) + assert norm(dot(self.A, x) - self.b) < 5*self.tol + + def check_qmr(self): + x, info = qmr(self.A, self.b, self.x0, callback=callback) + assert norm(dot(self.A, x) - self.b) < 5*self.tol + +if __name__ == "__main__": + NumpyTest().run() + From scipy-svn at scipy.org Wed Jan 24 18:27:48 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 17:27:48 -0600 (CST) Subject: [Scipy-svn] r2608 - in trunk/Lib/io: . tests Message-ID: <20070124232748.C45DE39C109@new.scipy.org> Author: matthew.brett at gmail.com Date: 2007-01-24 17:27:14 -0600 (Wed, 24 Jan 2007) New Revision: 2608 Added: trunk/Lib/io/npfile.py trunk/Lib/io/tests/test_npfile.py Modified: trunk/Lib/io/__init__.py trunk/Lib/io/fopen.py Log: Added npfile module with tests; still debugging Modified: trunk/Lib/io/__init__.py =================================================================== --- trunk/Lib/io/__init__.py 2007-01-24 14:35:01 UTC (rev 2607) +++ trunk/Lib/io/__init__.py 2007-01-24 23:27:14 UTC (rev 2608) @@ -9,6 +9,7 @@ convert_objectarray from mio import * from fopen import * +from npfile import npfile from recaster import sctype_attributes, Recaster from array_import import * from data_store import * Modified: trunk/Lib/io/fopen.py =================================================================== --- trunk/Lib/io/fopen.py 2007-01-24 14:35:01 UTC (rev 2607) +++ trunk/Lib/io/fopen.py 2007-01-24 23:27:14 UTC (rev 2608) @@ -10,8 +10,6 @@ LittleEndian = (sys.byteorder == 'little') -_unit_imag = {'f': array(1j,'F'), 'd': 1j} - __all__ = ['fopen'] def getsize_type(mtype): Added: trunk/Lib/io/npfile.py =================================================================== --- trunk/Lib/io/npfile.py 2007-01-24 14:35:01 UTC (rev 2607) +++ trunk/Lib/io/npfile.py 2007-01-24 23:27:14 UTC (rev 2608) @@ -0,0 +1,188 @@ +# Author: Matthew Brett, Travis Oliphant + +""" +Class for reading and writing numpy arrays from / to files +""" + +import sys + +import numpy as N + +sys_endian_code = (sys.byteorder == 'little') and '<' or '>' + +class npfile(object): + ''' Class for reading and writing numpy arrays to/from files + + Inputs: + file_name -- The complete path name to the file to open + or an open file-like object + permission -- Open the file with given permissions: ('r', 'H', 'a') + for reading, writing, or appending. This is the same + as the mode argument in the builtin open command. + format -- The byte-ordering of the file: + (['native', 'n'], ['ieee-le', 'l'], ['ieee-be', 'B']) for + native, little-endian, or big-endian respectively. + + Attributes + endian -- default endian code for reading / writing + order -- default order for reading writing ('C' or 'F') + file -- file object containing read / written data + ''' + + def __init__(self, file_name, + permission='rb', + endian = 'dtype', + order = 'C'): + if 'b' not in permission: permission += 'b' + if isinstance(file_name, basestring): + self.file = file(file_name, permission) + else: + try: + closed = file_name.closed + except AttributeError: + raise TypeError, 'Need filename or file object as input' + if closed: + raise TypeError, 'File object should be open' + self.file = file_name + + self.endian = endian + self.order = order + + def get_endian(self): + return self._endian + def set_endian(self, endian_code): + self._endian = self.parse_endian(endian_code) + endian = property(get_endian, set_endian, None, 'get/set endian code') + + def parse_endian(self, endian_code): + ''' Returns valid endian code from wider input options''' + if endian_code in ['native', 'n', 'N','default', '=']: + return sys_endian_code + elif endian_code in ['swapped', 's', 'S']: + return sys_endian_code == '<' and '>' or '<' + elif endian_code in ['ieee-le','l','L','little-endian', + 'little','le','<']: + return '<' + elif endian_code in ['ieee-be','B','b','big-endian', + 'big','be', '>']: + return '>' + elif endian_code == 'dtype': + return 'dtype' + else: + raise ValueError, "Unrecognized endian code: " + endian_code + return + + def __del__(self): + try: + self.file.close() + except: + pass + + def close(self): + self.file.close() + + def seek(self, *args): + self.file.seek(*args) + + def tell(self): + return self.file.tell() + + def rewind(self,howmany=None): + """Rewind a file to its beginning or by a specified amount. + """ + if howmany is None: + self.seek(0) + else: + self.seek(-howmany,1) + + def size(self): + """Return the size of the file. + + Cached once found + """ + try: + sz = self.thesize + except AttributeError: + curpos = self.tell() + self.seek(0,2) + sz = self.tell() + self.seek(curpos) + self.thesize = sz + return sz + + def raw_read(self, size=-1): + """Read raw bytes from file as string.""" + return self.file.read(size) + + def raw_write(self, str): + """Write string to file as raw bytes.""" + return self.file.write(str) + + def _endian_order(self, endian, order): + ''' Housekeeping function to return endian, order from input args ''' + if endian is None: + endian = self.endian + else: + endian = self.parse_endian(endian) + if order is None: + order = self.order + return endian, order + + def _endian_from_dtype(self, dt): + dt_endian = dt.byteorder + if dt_endian == '=': + dt_endian = sys_endian_code + return dt_endian + + def write(self, data, endian=None, order=None): + ''' Write to open file object the flattened numpy array data + + Inputs + data - numpy array or object convertable to array + endian - endianness of written data + (can be None, 'dtype', '<', '>') + (default from self.endian) + order - order of array to write (C, F) + (default from self.order) + ''' + endian, order = self._endian_order(endian, order) + data = N.asarray(data) + dt_endian = self._endian_from_dtype(data.dtype) + if not endian == 'dtype': + if dt_endian != endian: + data = data.byteswap() + self.file.write(data.tostring(order=order)) + + fwrite = write + + def read(self, shape, dt, endian=None, order=None): + ''' Read data from file and return it in a numpy array + + Inputs + shape - shape of output array, or number of elements + dt - dtype of array to write + endian - endianness of written data + (can be None, 'dtype', '<', '>') + (default from self.endian) + order - order of array to write (C, F) + (default from self.order) + ''' + endian, order = self._endian_order(endian, order) + try: + shape = tuple(shape) + except TypeError: + shape = (shape,) + dt = N.dtype(dt) + dt_endian = self._endian_from_dtype(dt) + if not endian == 'dtype': + if dt_endian != endian: + dt = dt.newbyteorder(endian) + sz = dt.itemsize * N.product(shape) + buf = self.file.read(sz) + return N.ndarray(shape=shape, + dtype=dt, + buffer=buf, + order=order).copy() + + + fread = read Added: trunk/Lib/io/tests/test_npfile.py =================================================================== --- trunk/Lib/io/tests/test_npfile.py 2007-01-24 14:35:01 UTC (rev 2607) +++ trunk/Lib/io/tests/test_npfile.py 2007-01-24 23:27:14 UTC (rev 2608) @@ -0,0 +1,82 @@ +from StringIO import StringIO +import os +from tempfile import mkstemp +from numpy.testing import * +import numpy as N + +set_package_path() +from io.npfile import npfile, sys_endian_code +restore_path() + +class test_npfile(NumpyTestCase): + + def test_init(self): + fd, fname = mkstemp() + npf = npfile(fname) + arr = N.reshape(N.arange(10), (5,2)) + self.assertRaises(IOError, npf.write, arr) + npf.close() + npf = npfile(fname, 'w') + npf.write(arr) + npf.rewind() + self.assertRaises(IOError, npf.read, + arr.shape, + arr.dtype) + npf.close() + os.remove(fname) + + npf = npfile(StringIO(), endian='>', order='F') + assert npf.endian == '>', 'Endian not set correctly' + assert npf.order == 'F', 'Order not set correctly' + npf.endian = '<' + assert npf.endian == '<', 'Endian not set correctly' + + def test_parse_endian(self): + npf = npfile(StringIO()) + swapped_code = sys_endian_code == '<' and '>' or '<' + assert npf.parse_endian('native') == sys_endian_code + assert npf.parse_endian('swapped') == swapped_code + assert npf.parse_endian('l') == '<' + assert npf.parse_endian('B') == '>' + assert npf.parse_endian('dtype') == 'dtype' + self.assertRaises(ValueError, npf.parse_endian, 'nonsense') + + def test_raw_read_write(self): + npf = npfile(StringIO()) + str = 'test me with this string' + npf.raw_write(str) + npf.rewind() + assert str == npf.raw_read(len(str)) + + def test_read_write(self): + npf = npfile(StringIO()) + arr = N.reshape(N.arange(10), (5,2)) + f_arr = arr.reshape((2,5)).T + bo = arr.dtype.byteorder + swapped_code = sys_endian_code == '<' and '>' or '<' + if bo in ['=', sys_endian_code]: + nbo = swapped_code + else: + nbo = sys_endian_code + bs_arr = arr.newbyteorder(nbo) + adt = arr.dtype + shp = arr.shape + npf.write(arr) + npf.rewind() + assert_array_equal(npf.read(shp, adt), arr) + npf.rewind() + assert_array_equal(npf.read(shp, adt, endian=swapped_code), + bs_arr) + npf.rewind() + assert_array_equal(npf.read(shp, adt, order='F'), + f_arr) + + npf = npfile(StringIO(), endian='swapped', order='F') + npf.write(arr) + npf.rewind() + assert_array_equal(npf.read(shp, adt), arr) + npf.rewind() + assert_array_equal(npf.read(shp, adt, endian='dtype'), bs_arr) + npf.rewind() + # assert_array_equal(npf.read(shp, adt, order='C'), f_arr) + From scipy-svn at scipy.org Wed Jan 24 18:37:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 24 Jan 2007 17:37:32 -0600 (CST) Subject: [Scipy-svn] r2609 - trunk/Lib/io Message-ID: <20070124233732.7DC2339C11B@new.scipy.org> Author: matthew.brett at gmail.com Date: 2007-01-24 17:37:12 -0600 (Wed, 24 Jan 2007) New Revision: 2609 Modified: trunk/Lib/io/npfile.py Log: Byteswap array to requred dtype when reading Modified: trunk/Lib/io/npfile.py =================================================================== --- trunk/Lib/io/npfile.py 2007-01-24 23:27:14 UTC (rev 2608) +++ trunk/Lib/io/npfile.py 2007-01-24 23:37:12 UTC (rev 2609) @@ -174,15 +174,14 @@ shape = (shape,) dt = N.dtype(dt) dt_endian = self._endian_from_dtype(dt) - if not endian == 'dtype': - if dt_endian != endian: - dt = dt.newbyteorder(endian) sz = dt.itemsize * N.product(shape) buf = self.file.read(sz) - return N.ndarray(shape=shape, + arr = N.ndarray(shape=shape, dtype=dt, buffer=buf, - order=order).copy() - + order=order) + if (not endian == 'dtype') and (dt_endian != endian): + return arr.byteswap() + return arr.copy() fread = read From scipy-svn at scipy.org Thu Jan 25 07:00:14 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 25 Jan 2007 06:00:14 -0600 (CST) Subject: [Scipy-svn] r2610 - trunk/Lib/io/tests Message-ID: <20070125120014.4FD0D39C0C1@new.scipy.org> Author: matthew.brett at gmail.com Date: 2007-01-25 05:59:47 -0600 (Thu, 25 Jan 2007) New Revision: 2610 Modified: trunk/Lib/io/tests/test_npfile.py Log: Corrected C/F order tests Modified: trunk/Lib/io/tests/test_npfile.py =================================================================== --- trunk/Lib/io/tests/test_npfile.py 2007-01-24 23:37:12 UTC (rev 2609) +++ trunk/Lib/io/tests/test_npfile.py 2007-01-25 11:59:47 UTC (rev 2610) @@ -51,7 +51,11 @@ def test_read_write(self): npf = npfile(StringIO()) arr = N.reshape(N.arange(10), (5,2)) + # Arr as read in fortran order f_arr = arr.reshape((2,5)).T + # Arr written in fortran order read in C order + cf_arr = arr.T.reshape((5,2)) + # Byteswapped array bo = arr.dtype.byteorder swapped_code = sys_endian_code == '<' and '>' or '<' if bo in ['=', sys_endian_code]: @@ -70,6 +74,11 @@ npf.rewind() assert_array_equal(npf.read(shp, adt, order='F'), f_arr) + npf.rewind() + npf.write(arr, order='F') + npf.rewind() + assert_array_equal(npf.read(shp, adt), + cf_arr) npf = npfile(StringIO(), endian='swapped', order='F') npf.write(arr) @@ -78,5 +87,5 @@ npf.rewind() assert_array_equal(npf.read(shp, adt, endian='dtype'), bs_arr) npf.rewind() - # assert_array_equal(npf.read(shp, adt, order='C'), f_arr) + assert_array_equal(npf.read(shp, adt, order='C'), cf_arr) From scipy-svn at scipy.org Thu Jan 25 13:13:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 25 Jan 2007 12:13:41 -0600 (CST) Subject: [Scipy-svn] r2611 - in trunk/Lib/sandbox/timeseries: . io Message-ID: <20070125181341.3EFEA39C067@new.scipy.org> Author: mattknox_ca Date: 2007-01-25 12:13:36 -0600 (Thu, 25 Jan 2007) New Revision: 2611 Added: trunk/Lib/sandbox/timeseries/io/ trunk/Lib/sandbox/timeseries/io/__init__.py trunk/Lib/sandbox/timeseries/io/report.py Log: Added io module Added: trunk/Lib/sandbox/timeseries/io/__init__.py =================================================================== Added: trunk/Lib/sandbox/timeseries/io/report.py =================================================================== --- trunk/Lib/sandbox/timeseries/io/report.py 2007-01-25 11:59:47 UTC (rev 2610) +++ trunk/Lib/sandbox/timeseries/io/report.py 2007-01-25 18:13:36 UTC (rev 2611) @@ -0,0 +1,216 @@ +import cStringIO,operator, types +import timeseries as ts + +def report(*tseries, **kwargs): + """generate a table report of *tseries with dates in the left column. + +:Parameters: + - `*tseries` : time series objects. Must all be at the same frequency, but + do not need to be aligned. + - `dates` (DateArray, *[None]*) : dates at which values of all the series + will be output. If not specified, data will be output from the minimum + start_date to the maximum end_date of all the time series objects + - `header_row` (list, *[None]*) : optional list of column headers. Length + must be equal to len(tseries) (no date column header specified) or + len(tseries)+1 (first header is assumed to be date column header) + - `header_char` : Character to be used for the row separator line + - `justify` (List or String, *[None]*) : Determines how are data justified in + their column. If not specified, the date column and string columns are left + justified, and everything else is right justified. If a string is specified, + it must be one of 'left', 'right', or 'center' and all columns will be + justified the same way. If a list is specified, each column will be justified + according to the specification for that column in the list (specifying the + justification for the date column is optional). + - `prefix` (string, *['']*) : A string prepended to each printed row. + - `postfix` (string, *['']*) : A string appended to each printed row. + - `mask_rep` (string, *['--']*): String used to represent masked values in + output + - `datefmt` (string, *[None]*) : Formatting string used for displaying the + dates in the date column. If None, str() is simply called on the dates + - `fmtfunc` (function, *[str]*): A function f(item) for formatting each data + type in the report into a string. If not specified, str() is simply called + on each item. + - `wrapfunc` (function, *[lambda x:x]*): A function f(text) for wrapping text; + each element in the table is first wrapped by this function. Useful functions + for this are wrap_onspace, wrap_onspace_strict, and wrap_always (which are + part of this module). Eg wrapfunc=lambda x: wrap_onspace(x, 10) + +:Examples: + + import numpy as np + import timeseries as ts + from timeseries.io import report as r + + series1 = ts.time_series(np.random.uniform(-100,100,15), start_date=ts.thisday('b')-15) + series2 = ts.time_series(np.random.uniform(-100,100,13), start_date=ts.thisday('b')-10) + series3 = ts.time_series(['string1', 'another string', 'yet another string']*3, start_date=ts.thisday('b')-10) + + darray = ts.date_array(start_date=ts.thisday('b')-8, end_date=ts.thisday('b')-3) + + # print all values of series1 and series2 and show 2 decimal places. + # show masked values as "N/A" + print r.report(series1, series2, fmtfunc=lambda x:'%.2f' % x, mask_rep='N/A') + + # print an html table of the data over a specified range + print "" + \ + r.report(series1, series2, series3, dates=darray, + delim="") + \ + "
", prefix="
", postfix="
" + + # print a table with columns 10 characters wide when possible, but don't break up a word + print r.report(series1, series3, series2, wrapfunc=lambda x: r.wrap_onspace(x, 10))""" + + dates = kwargs.pop('dates', None) + header_row = kwargs.pop('header_row', None) + header_char = kwargs.pop('header_char', '-') + delim = kwargs.pop('delim', ' | ') + justify = kwargs.pop('justify', None) + prefix = kwargs.pop('prefix', '') + postfix = kwargs.pop('postfix', '') + mask_rep = kwargs.pop('mask_rep', '--') + datefmt = kwargs.pop('datefmt', None) + fmtfunc_temp = kwargs.pop('fmtfunc', str) + + def fmtfunc(item): + if hasattr(item, "_mask") and item._mask: + return mask_rep + else: + return fmtfunc_temp(item) + + wrapfunc = kwargs.pop('wrapfunc', lambda x:x) + + if len(kwargs) > 0: + raise KeyError("Unrecognized keyword(s): %s" % (", ".join(kwargs.keys()))) + + if header_row is not None: + hasHeader=True + if len(header_row) == len(tseries)+1: + # label for date column included + rows = [header_row] + elif len(header_row) == len(tseries): + # label for date column not included + rows = [['']+header_row] + else: + hasHeader=False + rows=[] + + if justify is not None: + if type(justify) == types.StringType: + # justify all columns the the same way + justify = [justify for x in range(len(tseries)+1)] + else: #assume it is a list or tuple, etc + if len(justify) == len(tseries): + # justification for date column not included, so set that + # to left by default + justify = ['left'] + justify + else: + # default column justification + justify = ['left'] + for ser in tseries: + if str(ser.dtype)[:2] == '|S': justify.append('left') + else: justify.append('right') + + + if datefmt is None: + def datefmt_func(date): return str(date) + else: + def datefmt_func(date): return date.strfmt(datefmt) + + tseries = ts.align_series(*tseries) + + if dates is None: + dates = ts.date_array(start_date=tseries[0].start_date, + end_date=tseries[0].end_date) + + for d in dates: + rows.append([datefmt_func(d)]+[fmtfunc(ser[d]) for ser in tseries]) + + return indent(rows, hasHeader=hasHeader, headerChar=header_char, + delim=delim, justify=justify, separateRows=False, + prefix=prefix, postfix=postfix, wrapfunc=wrapfunc) + + + + +# written by George Sakkis +# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662 +def indent(rows, hasHeader=False, headerChar='-', delim=' | ', justify=None, + separateRows=False, prefix='', postfix='', wrapfunc=lambda x:x): + """Indents a table by column. + - rows: A sequence of sequences of items, one sequence per row. + - hasHeader: True if the first row consists of the columns' names. + - headerChar: Character to be used for the row separator line + (if hasHeader==True or separateRows==True). + - delim: The column delimiter. + - justify: Determines how are data justified in their column. + Valid values are 'left','right' and 'center'. + - separateRows: True if rows are to be separated by a line + of 'headerChar's. + - prefix: A string prepended to each printed row. + - postfix: A string appended to each printed row. + - wrapfunc: A function f(text) for wrapping text; each element in + the table is first wrapped by this function.""" + + + def rowWrapper(row): + newRows = [wrapfunc(item).split('\n') for item in row] + return [[substr or '' for substr in item] for item in map(None,*newRows)] + # break each logical row into one or more physical ones + logicalRows = [rowWrapper(row) for row in rows] + # columns of physical rows + columns = map(None,*reduce(operator.add,logicalRows)) + numCols = len(columns) + colNums = list(range(numCols)) + + if justify is None: + justify = ['left' for x in range(numCols)] + + # get the maximum of each column by the string length of its items + maxWidths = [max([len(str(item)) for item in column]) for column in columns] + rowSeparator = headerChar * (len(prefix) + len(postfix) + sum(maxWidths) + \ + len(delim)*(len(maxWidths)-1)) + # select the appropriate justify method + justify_funcs = {'center':str.center, 'right':str.rjust, 'left':str.ljust} + + + output=cStringIO.StringIO() + if separateRows: print >> output, rowSeparator + for physicalRows in logicalRows: + for row in physicalRows: + print >> output, \ + prefix \ + + delim.join([justify_funcs[justify[colNum].lower()](str(item),width) for (colNum,item,width) in zip(colNums,row,maxWidths)]) \ + + postfix + if separateRows or hasHeader: print >> output, rowSeparator; hasHeader=False + return output.getvalue() + +# written by Mike Brown +# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/148061 +def wrap_onspace(text, width): + """ + A word-wrap function that preserves existing line breaks + and most spaces in the text. Expects that existing line + breaks are posix newlines (\n). + """ + return reduce(lambda line, word, width=width: '%s%s%s' % + (line, + ' \n'[(len(line[line.rfind('\n')+1:]) + + len(word.split('\n',1)[0] + ) >= width)], + word), + text.split(' ') + ) + +import re +def wrap_onspace_strict(text, width): + """Similar to wrap_onspace, but enforces the width constraint: + words longer than width are split.""" + wordRegex = re.compile(r'\S{'+str(width)+r',}') + return wrap_onspace(wordRegex.sub(lambda m: wrap_always(m.group(),width),text),width) + +import math +def wrap_always(text, width): + """A simple word-wrap function that wraps text on exactly width characters. + It doesn't split the text in words.""" + return '\n'.join([ text[width*i:width*(i+1)] \ + for i in xrange(int(math.ceil(1.*len(text)/width))) ]) From scipy-svn at scipy.org Thu Jan 25 15:04:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 25 Jan 2007 14:04:03 -0600 (CST) Subject: [Scipy-svn] r2612 - trunk/Lib/sandbox/timeseries/io Message-ID: <20070125200403.4A23739C040@new.scipy.org> Author: mattknox_ca Date: 2007-01-25 14:03:57 -0600 (Thu, 25 Jan 2007) New Revision: 2612 Modified: trunk/Lib/sandbox/timeseries/io/report.py Log: added ability to pass in a list of functions to format each column separately Modified: trunk/Lib/sandbox/timeseries/io/report.py =================================================================== --- trunk/Lib/sandbox/timeseries/io/report.py 2007-01-25 18:13:36 UTC (rev 2611) +++ trunk/Lib/sandbox/timeseries/io/report.py 2007-01-25 20:03:57 UTC (rev 2612) @@ -1,6 +1,27 @@ import cStringIO,operator, types import timeseries as ts +class fmtfunc_wrapper: + """wraps a formatting function such that it handles masked values + +:IVariables: + - `fmtfunc` : formatting function. + - `mask_rep` : string to use for masked values + """ + def __init__ (self, fmtfunc, mask_rep): + self.f = fmtfunc + self.mr = mask_rep + + def __call__ (self, item): + "Execute the call behavior." + + if hasattr(item, "_mask") and item._mask: + return self.mr + else: + return self.f(item) + + + def report(*tseries, **kwargs): """generate a table report of *tseries with dates in the left column. @@ -14,22 +35,23 @@ must be equal to len(tseries) (no date column header specified) or len(tseries)+1 (first header is assumed to be date column header) - `header_char` : Character to be used for the row separator line - - `justify` (List or String, *[None]*) : Determines how are data justified in - their column. If not specified, the date column and string columns are left - justified, and everything else is right justified. If a string is specified, - it must be one of 'left', 'right', or 'center' and all columns will be - justified the same way. If a list is specified, each column will be justified - according to the specification for that column in the list (specifying the - justification for the date column is optional). + - `justify` (List of strings or single string, *[None]*) : Determines how are + data justified in their column. If not specified, the date column and string + columns are left justified, and everything else is right justified. If a + string is specified, it must be one of 'left', 'right', or 'center' and all + columns will be justified the same way. If a list is specified, each column + will be justified according to the specification for that column in the list + (specifying the justification for the date column is optional). - `prefix` (string, *['']*) : A string prepended to each printed row. - `postfix` (string, *['']*) : A string appended to each printed row. - `mask_rep` (string, *['--']*): String used to represent masked values in output - `datefmt` (string, *[None]*) : Formatting string used for displaying the dates in the date column. If None, str() is simply called on the dates - - `fmtfunc` (function, *[str]*): A function f(item) for formatting each data - type in the report into a string. If not specified, str() is simply called - on each item. + - `fmtfunc` (List of functions or single function, *[None]*) : A function or + list of functions for formatting each data column in the report. If not + specified, str() is simply called on each item. If a list of functions is + provided, there must be exactly one function for each column - `wrapfunc` (function, *[lambda x:x]*): A function f(text) for wrapping text; each element in the table is first wrapped by this function. Useful functions for this are wrap_onspace, wrap_onspace_strict, and wrap_always (which are @@ -51,6 +73,9 @@ # show masked values as "N/A" print r.report(series1, series2, fmtfunc=lambda x:'%.2f' % x, mask_rep='N/A') + # same thing, but format one column one with 2 decimal places, and column two with 4 + print r.report(series1, series2, fmtfunc=[(lambda x:'%.2f' % x), (lambda x:'%.4f' % x)], mask_rep='N/A') + # print an html table of the data over a specified range print "" + \ r.report(series1, series2, series3, dates=darray, @@ -69,13 +94,12 @@ postfix = kwargs.pop('postfix', '') mask_rep = kwargs.pop('mask_rep', '--') datefmt = kwargs.pop('datefmt', None) - fmtfunc_temp = kwargs.pop('fmtfunc', str) + fmtfunc = kwargs.pop('fmtfunc', str) - def fmtfunc(item): - if hasattr(item, "_mask") and item._mask: - return mask_rep - else: - return fmtfunc_temp(item) + if type(fmtfunc) != types.ListType: + fmtfunc = [fmtfunc_wrapper(fmtfunc, mask_rep)]*len(tseries) + else: + fmtfunc = [fmtfunc_wrapper(f, mask_rep) for f in fmtfunc] wrapfunc = kwargs.pop('wrapfunc', lambda x:x) @@ -123,7 +147,7 @@ end_date=tseries[0].end_date) for d in dates: - rows.append([datefmt_func(d)]+[fmtfunc(ser[d]) for ser in tseries]) + rows.append([datefmt_func(d)]+[fmtfunc[i](ser[d]) for i, ser in enumerate(tseries)]) return indent(rows, hasHeader=hasHeader, headerChar=header_char, delim=delim, justify=justify, separateRows=False, From scipy-svn at scipy.org Thu Jan 25 20:00:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 25 Jan 2007 19:00:50 -0600 (CST) Subject: [Scipy-svn] r2613 - trunk/Lib/special Message-ID: <20070126010050.2D8A339C0A2@new.scipy.org> Author: rkern Date: 2007-01-25 19:00:44 -0600 (Thu, 25 Jan 2007) New Revision: 2613 Modified: trunk/Lib/special/basic.py Log: Flesh out docstring for sph_harm Modified: trunk/Lib/special/basic.py =================================================================== --- trunk/Lib/special/basic.py 2007-01-25 20:03:57 UTC (rev 2612) +++ trunk/Lib/special/basic.py 2007-01-26 01:00:44 UTC (rev 2613) @@ -329,8 +329,24 @@ return jn[:(n+1)],jnp[:(n+1)] def _sph_harmonic(m,n,theta,phi): - """Spherical harmonic of order m,n (|m|<=n) and argument theta and phi: - Y^m_n(theta,phi) + """Compute spherical harmonics. + + This is a ufunc and may take scalar or array arguments like any other ufunc. + The inputs will be broadcasted against each other. + + :Parameters: + - `m` : int |m| <= n + The order of the harmonic. + - `n` : int >= 0 + The degree of the harmonic. + - `theta` : float [0, pi] + The polar (colatitudinal) coordinate. + - `phi` : float [0, 2*pi] + The azimuthal (longitudinal) coordinate. + + :Returns: + - `y_mn` : complex float + The harmonic $Y^m_n$ sampled at `theta` and `phi`. """ x = cos(phi) m,n = int(m), int(n) From scipy-svn at scipy.org Thu Jan 25 20:17:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 25 Jan 2007 19:17:05 -0600 (CST) Subject: [Scipy-svn] r2614 - trunk/Lib/special Message-ID: <20070126011705.A33C039C0A2@new.scipy.org> Author: rkern Date: 2007-01-25 19:17:04 -0600 (Thu, 25 Jan 2007) New Revision: 2614 Modified: trunk/Lib/special/basic.py Log: Of course, it's nicer if I don't confuse the two things I am trying to disambiguate. Modified: trunk/Lib/special/basic.py =================================================================== --- trunk/Lib/special/basic.py 2007-01-26 01:00:44 UTC (rev 2613) +++ trunk/Lib/special/basic.py 2007-01-26 01:17:04 UTC (rev 2614) @@ -339,10 +339,10 @@ The order of the harmonic. - `n` : int >= 0 The degree of the harmonic. - - `theta` : float [0, pi] + - `theta` : float [0, 2*pi] + The azimuthal (longitudinal) coordinate. + - `phi` : float [0, pi] The polar (colatitudinal) coordinate. - - `phi` : float [0, 2*pi] - The azimuthal (longitudinal) coordinate. :Returns: - `y_mn` : complex float From scipy-svn at scipy.org Fri Jan 26 16:20:14 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 26 Jan 2007 15:20:14 -0600 (CST) Subject: [Scipy-svn] r2615 - trunk/Lib/sandbox/timeseries Message-ID: <20070126212014.8820A39C085@new.scipy.org> Author: mattknox_ca Date: 2007-01-26 15:20:10 -0600 (Fri, 26 Jan 2007) New Revision: 2615 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: fixed bug with start_date and end_date properties where it crashed if series.size == 0 Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-26 01:17:04 UTC (rev 2614) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-26 21:20:10 UTC (rev 2615) @@ -473,12 +473,18 @@ @property def start_date(self): """Returns the first date of the series.""" - return self._dates[0] + if self._dates.size != 0: + return self._dates[0] + else: + return None @property def end_date(self): """Returns the last date of the series.""" - return self._dates[-1] + if self._dates.size != 0: + return self._dates[-1] + else: + return None def isvalid(self): From scipy-svn at scipy.org Fri Jan 26 16:39:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 26 Jan 2007 15:39:53 -0600 (CST) Subject: [Scipy-svn] r2616 - trunk/Lib/sandbox/timeseries Message-ID: <20070126213953.2EB5239C05B@new.scipy.org> Author: mattknox_ca Date: 2007-01-26 15:39:45 -0600 (Fri, 26 Jan 2007) New Revision: 2616 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: fixed bugs with empty DateArray's Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-26 21:20:10 UTC (rev 2615) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-26 21:39:45 UTC (rev 2616) @@ -708,15 +708,20 @@ warnings.warn("Undefined frequency: assuming daily!") if self.__steps is None: val = numeric.asarray(self).ravel() - if val.size > 0: + if val.size > 1: steps = val[1:] - val[:-1] if self.__full is None: self.__full = (steps.max() == 1) if self.__hasdups is None: self.__hasdups = (steps.min() == 0) - else: + elif val.size == 1: self.__full = True self.__hasdups = False + steps = numeric.array([], dtype=int_) + else: + self.__full = False + self.__hasdups = False + steps = None self.__steps = steps return self.__steps From scipy-svn at scipy.org Fri Jan 26 16:40:43 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 26 Jan 2007 15:40:43 -0600 (CST) Subject: [Scipy-svn] r2617 - trunk/Lib/sandbox/timeseries Message-ID: <20070126214043.D4DE339C05B@new.scipy.org> Author: mattknox_ca Date: 2007-01-26 15:40:36 -0600 (Fri, 26 Jan 2007) New Revision: 2617 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: fixed bugs with size 0 TimeSeries objects Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-26 21:39:45 UTC (rev 2616) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-26 21:40:36 UTC (rev 2617) @@ -112,11 +112,13 @@ elif a.start_date != b.start_date: raise TimeSeriesCompatibilityError('start_date', a.start_date, b.start_date) - elif (a._dates.get_steps() != b._dates.get_steps()).any(): - 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), + 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', + a._dates.get_steps(), b._dates.get_steps()) + elif a.shape != b.shape: + raise TimeSeriesCompatibilityError('size', "1: %s" % str(a.shape), "2: %s" % str(b.shape)) return True From scipy-svn at scipy.org Fri Jan 26 16:49:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 26 Jan 2007 15:49:08 -0600 (CST) Subject: [Scipy-svn] r2618 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070126214908.5B7EA39C191@new.scipy.org> Author: mattknox_ca Date: 2007-01-26 15:49:05 -0600 (Fri, 26 Jan 2007) New Revision: 2618 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: added tests for empty datearrays Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-26 21:40:36 UTC (rev 2617) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-26 21:49:05 UTC (rev 2618) @@ -693,6 +693,12 @@ 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(), False) + assert_equal(empty_darray.isvalid(), False) + assert_equal(empty_darray.get_steps(), None) + ############################################################################### From scipy-svn at scipy.org Fri Jan 26 16:56:56 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 26 Jan 2007 15:56:56 -0600 (CST) Subject: [Scipy-svn] r2619 - trunk/Lib/sandbox/timeseries Message-ID: <20070126215656.ADA7239C05B@new.scipy.org> Author: mattknox_ca Date: 2007-01-26 15:56:53 -0600 (Fri, 26 Jan 2007) New Revision: 2619 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: fixed more bugs with empty time series Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-26 21:49:05 UTC (rev 2618) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-26 21:56:53 UTC (rev 2619) @@ -199,8 +199,11 @@ # Check dates ........ if dates is None: length = _getdatalength(data) - newdates = date_array(start_date=start_date, length=length, - freq=freq) + if length > 0: + newdates = date_array(start_date=start_date, length=length, + freq=freq) + else: + newdates = date_array([], freq=freq) elif not hasattr(dates, 'freq'): newdates = date_array(dlist=dates, freq=freq) else: @@ -882,8 +885,12 @@ """ if dates is None: length = _getdatalength(data) - dates = date_array(start_date=start_date, end_date=end_date, - length=length, include_last=include_last, freq=freq) + if length > 0: + dates = date_array(start_date=start_date, end_date=end_date, + length=length, include_last=include_last, freq=freq) + else: + 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, From scipy-svn at scipy.org Fri Jan 26 17:00:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 26 Jan 2007 16:00:01 -0600 (CST) Subject: [Scipy-svn] r2620 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070126220001.4880239C05B@new.scipy.org> Author: mattknox_ca Date: 2007-01-26 15:59:58 -0600 (Fri, 26 Jan 2007) New Revision: 2620 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added tests for handling empty TimeSeries objects Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-26 21:56:53 UTC (rev 2619) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-26 21:59:58 UTC (rev 2620) @@ -297,6 +297,14 @@ assert_equal(tmp._dates, series._dates) assert_equal(tmp._mask, series._mask) + def test_empty_timeseries(self): + "Tests that empty TimeSeries are handled properly" + empty_ts = time_series([], freq='b') + assert_array_equal(empty_ts, empty_ts + 1) + assert_array_equal(empty_ts, empty_ts + empty_ts) + assert_equal(empty_ts.start_date, None) + assert_equal(empty_ts.end_date, None) + ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": From scipy-svn at scipy.org Sat Jan 27 18:00:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 27 Jan 2007 17:00:42 -0600 (CST) Subject: [Scipy-svn] r2621 - trunk/Lib/interpolate Message-ID: <20070127230042.6BD1939C1CD@new.scipy.org> Author: stefan Date: 2007-01-27 16:58:32 -0600 (Sat, 27 Jan 2007) New Revision: 2621 Modified: trunk/Lib/interpolate/__fitpack.h Log: Fix memory leak in fitpack. Closes ticket #248. Modified: trunk/Lib/interpolate/__fitpack.h =================================================================== --- trunk/Lib/interpolate/__fitpack.h 2007-01-26 21:59:58 UTC (rev 2620) +++ trunk/Lib/interpolate/__fitpack.h 2007-01-27 22:58:32 UTC (rev 2621) @@ -210,10 +210,16 @@ ap_c = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE); if (ap_tx == NULL || ap_ty == NULL || ap_c == NULL) goto fail; if ((iopt==0)||(nx>nxo)||(ny>nyo)) { + Py_XDECREF(ap_wrk); ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE); if (ap_wrk == NULL) goto fail; /*ap_iwrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_INT);*/ } + if(ap_wrk->dimensions[0]data,tx,nx*sizeof(double)); memcpy(ap_ty->data,ty,ny*sizeof(double)); memcpy(ap_c->data,c,lc*sizeof(double)); From scipy-svn at scipy.org Sat Jan 27 19:06:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 27 Jan 2007 18:06:42 -0600 (CST) Subject: [Scipy-svn] r2622 - trunk/Lib/optimize Message-ID: <20070128000642.0992A39C00A@new.scipy.org> Author: rkern Date: 2007-01-27 18:06:38 -0600 (Sat, 27 Jan 2007) New Revision: 2622 Modified: trunk/Lib/optimize/lbfgsb.py Log: Make sure x0 is a float64 array. Modified: trunk/Lib/optimize/lbfgsb.py =================================================================== --- trunk/Lib/optimize/lbfgsb.py 2007-01-27 22:58:32 UTC (rev 2621) +++ trunk/Lib/optimize/lbfgsb.py 2007-01-28 00:06:38 UTC (rev 2622) @@ -177,7 +177,7 @@ u = 1 nbd[i] = bounds_map[l, u] - x = array(x0) + x = array(x0, float64) f = array(0.0, float64) g = zeros((n,), float64) wa = zeros((2*m*n+4*n + 12*m**2 + 12*m,), float64) From scipy-svn at scipy.org Sat Jan 27 20:25:40 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 27 Jan 2007 19:25:40 -0600 (CST) Subject: [Scipy-svn] r2623 - trunk/Lib/sandbox/timeseries Message-ID: <20070128012540.49B1D39C00A@new.scipy.org> Author: pierregm Date: 2007-01-27 19:25:37 -0600 (Sat, 27 Jan 2007) New Revision: 2623 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: let strfmt accept an empty format string (forced to default) Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-28 00:06:38 UTC (rev 2622) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-28 01:25:37 UTC (rev 2623) @@ -33,8 +33,7 @@ import logging -logging.basicConfig(level=logging.DEBUG, - format='%(name)-15s %(levelname)s %(message)s',) +logging.basicConfig(level=logging.DEBUG,format='%(name)-15s %(levelname)s %(message)s',) daflog = logging.getLogger('darray_from') dalog = logging.getLogger('DateArray') @@ -125,7 +124,7 @@ self.freq = corelib.fmtFreq(freq.freq) else: self.freq = corelib.fmtFreq(freq) - self.type = corelib.freqToType(self.freq) + self.freqstr = self.freq if value is not None: if self.freq == 'A': @@ -356,9 +355,12 @@ def strfmt(self, fmt): "Formats the date" + if fmt is None: + fmt = self.default_fmtstr() qFmt = fmt.replace("%q", "XXXX") tmpStr = self.mxDate.strftime(qFmt) - if "XXXX" in tmpStr: tmpStr = tmpStr.replace("XXXX", str(self.quarter)) + if "XXXX" in tmpStr: + tmpStr = tmpStr.replace("XXXX", str(self.quarter)) return tmpStr def __str__(self): @@ -505,9 +507,9 @@ accesses the array element by element. Therefore, `d` is a Date object. """ def __new__(cls, dates=None, freq='U', copy=False): - #dalog.info("__new__ received %s [%i]" % (type(dates), numpy.size(dates))) + #logging.debug('DA:__new__ received %s [%i]" % (type(dates), numpy.size(dates))) if isinstance(dates, DateArray): - #dalog.info("__new__ sends %s as %s" % (type(dates), cls)) + #logging.debug('DA:__new__ sends %s as %s" % (type(dates), cls)) cls.__defaultfreq = dates.freq if not copy: return dates.view(cls) @@ -516,7 +518,7 @@ _dates = numeric.asarray(dates, dtype=int_) if copy: _dates = _dates.copy() - #dalog.info("__new__ sends %s as %s" % (type(_dates), cls)) + #logging.debug('DA:__new__ sends %s as %s" % (type(_dates), cls)) if freq is None: freq = 'U' cls.__defaultfreq = corelib.fmtFreq(freq) @@ -531,15 +533,17 @@ raise ArithmeticDateError, "(function %s)" % context[0].__name__ def __array_finalize__(self, obj): - #dalog.info("__array_finalize__ received %s" % type(obj)) + #logging.debug('DA:__array_finalize__ received %s" % type(obj)) if hasattr(obj, 'freq'): self.freq = obj.freq + self.freqstr = obj.freqstr else: self.freq = self.__defaultfreq - #dalog.info("__array_finalize__ sends %s" % type(self)) + self.freqstr = self.__defaultfreq + #logging.debug('DA:__array_finalize__ sends %s" % type(self)) def __getitem__(self, index): - #dalog.info("__getitem__ got index %s (%s)"%(index, type(index))) + #logging.debug('DA:__getitem__ got index %s (%s)"%(index, type(index))) if isinstance(index, Date): index = self.find_dates(index) elif numeric.asarray(index).dtype.kind == 'O': @@ -620,15 +624,6 @@ return numeric.asarray(cseries.getDateInfo(numeric.asarray(self), self.freq, info), dtype=int_) #.... Conversion methods .................... -# def toobject(self): -# "Converts the dates from ordinals to Date objects." -# # Note: we better try to cache the result -# if self.__toobj is None: -## toobj = numeric.empty(self.size, dtype=object_) -## toobj[:] = [Date(self.freq, value=d) for d in self] -## self.__toobj = toobj -# self.__toobj = self -# return self.__toobj # def tovalue(self): "Converts the dates to integer values." @@ -763,7 +758,7 @@ self._asdates = asdates self.__doc__ = getattr(methodname, '__doc__') self.obj = None - #dalog.info('__datearithmetics got method %s' % methodname) + #logging.debug('DA:__datearithmetics got method %s' % methodname) # def __get__(self, obj, objtype=None): self.obj = obj @@ -775,7 +770,7 @@ freq = instance.freq if 'context' not in kwargs: kwargs['context'] = 'DateOK' - #dalog.info('__datearithmetics got other %s' % type(other)) + #logging.debug('DA:__datearithmetics got other %s' % type(other)) method = getattr(super(DateArray,instance), self.methodname) if isinstance(other, DateArray): if other.freq != freq: @@ -787,7 +782,7 @@ raise FrequencyDateError("Cannot operate on dates", \ freq, other.freq) other = other.value - #dalog.info('__datearithmetics got other %s' % type(other)) + #logging.debug('DA:__datearithmetics got other %s' % type(other)) elif isinstance(other, ndarray): if other.dtype.kind not in ['i','f']: raise ArithmeticDateError @@ -901,6 +896,7 @@ - a starting date and either an ending date or a given length. - a list of dates. """ + #TODO: make sure we can use a string for a date! freq = corelib.fmtFreq(freq) # Case #1: we have a list ................... if dlist is not None: From scipy-svn at scipy.org Mon Jan 29 00:34:31 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sun, 28 Jan 2007 23:34:31 -0600 (CST) Subject: [Scipy-svn] r2624 - in trunk/Lib/sandbox/timeseries: archived_version plotlib Message-ID: <20070129053431.A005339C014@new.scipy.org> Author: pierregm Date: 2007-01-28 23:34:25 -0600 (Sun, 28 Jan 2007) New Revision: 2624 Added: trunk/Lib/sandbox/timeseries/archived_version/plot.py trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py Removed: trunk/Lib/sandbox/timeseries/plotlib/plot.py Log: introduce plotlib/mpl_timeseries & moved plot to archived_version Copied: trunk/Lib/sandbox/timeseries/archived_version/plot.py (from rev 2622, trunk/Lib/sandbox/timeseries/plotlib/plot.py) Added: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-01-28 01:25:37 UTC (rev 2623) +++ trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-01-29 05:34:25 UTC (rev 2624) @@ -0,0 +1,705 @@ +""" +Classes to plot TimeSeries w/ matplotlib. + +: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 matplotlib +from matplotlib import pylab, rcParams +from matplotlib.artist import setp +from matplotlib.axes import Subplot, PolarSubplot +from matplotlib.cbook import flatten +from matplotlib.collections import LineCollection +from matplotlib.contour import ContourSet +from matplotlib.dates import DayLocator, MonthLocator, YearLocator, \ + DateFormatter +from matplotlib.figure import Figure +from matplotlib.legend import Legend +from matplotlib.mlab import meshgrid +from matplotlib.ticker import Formatter, ScalarFormatter, FuncFormatter, \ + Locator, FixedLocator + +from matplotlib.transforms import nonsingular + +import numpy as N +import maskedarray as MA + +import tdates +from tdates import date_array, Date +import tseries +from tseries import TimeSeries + +import warnings + +#####--------------------------------------------------------------------------- +#---- --- Matplotlib extensions --- +#####--------------------------------------------------------------------------- + +def add_generic_subplot(figure_instance, *args, **kwargs): + """Generalizes the `add_subplot` figure method to generic subplots. +The specific Subplot object class to add is given through the keywords +`SubplotClass` or `class`. + +:Parameters: + `figure_instance` : Figure object + Figure to which the generic subplot should be attached. + `args` : Misc + Miscellaneous arguments to the subplot. + `kwargs` : Dictionary + Keywords. Same keywords as `Subplot`, with the addition of + - `SubplotClass` : Type of subplot + - `subclass` : Shortcut to `SubplotClass`. + - any keyword required by the `SubplotClass` subclass. + """ + + key = figure_instance._make_key(*args, **kwargs) + #TODO: Find why, sometimes, key is not hashable (even if tuple) + # else, there's a fix below + try: + 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): + return +# if hasattr(args[0], '__array__'): +# fixedargs = args[1:] +# else: +# fixedargs = args + # + SubplotClass = kwargs.pop("SubplotClass", Subplot) + SubplotClass = kwargs.pop("subclass",SubplotClass) + if isinstance(args[0], Subplot) or isinstance(args[0], PolarSubplot): + a = args[0] + assert(a.get_figure() is figure_instance) +# a.set_figure(figure_instance) + else: + ispolar = kwargs.pop('polar', False) + if ispolar: + 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) + figure_instance._seen[key] = a + return a + +##### ------------------------------------------------------------------------- +#---- --- Locators --- +##### ------------------------------------------------------------------------- + +def _get_default_annual_spacing(nyears): + """Returns a default spacing between consecutive ticks for annual data.""" + if nyears < 20: + (min_spacing, maj_spacing) = (1, 2) + elif nyears < 50: + (min_spacing, maj_spacing) = (1, 5) + elif nyears < 100: + (min_spacing, maj_spacing) = (5, 10) + elif nyears < 200: + (min_spacing, maj_spacing) = (5, 20) + elif nyears < 400: + (min_spacing, maj_spacing) = (5, 25) + elif nyears < 1000: + (min_spacing, maj_spacing) = (10, 50) + else: + (min_spacing, maj_spacing) = (20, 100) + return (min_spacing, maj_spacing) + +def _get_default_quarterly_spacing(nquarters): + """Returns a default spacing between consecutive ticks for quarterly data.""" + if nquarters <= 3*4: + (min_spacing, maj_spacing) = (1,4) + elif nquarters <= 11*4: + (min_spacing, maj_spacing) = (1,4) + else: + (min_anndef, maj_anndef) = _get_default_annual_spacing(nquarters//4) + min_spacing = min_anndef * 4 + maj_spacing = maj_anndef * 4 + return (min_spacing, maj_spacing) + +def _get_default_monthly_spacing(nmonths): + """Returns a default spacing between consecutive ticks for monthly data.""" + if nmonths <= 10: + (min_spacing, maj_spacing) = (1,3) + elif nmonths <= 2*12: + (min_spacing, maj_spacing) = (1,6) + elif nmonths <= 3*12: + (min_spacing, maj_spacing) = (1,12) + elif nmonths <= 11*12: + (min_spacing, maj_spacing) = (3,12) + else: + (min_anndef, maj_anndef) = _get_default_annual_spacing(nmonths//12) + min_spacing = min_anndef * 12 + maj_spacing = maj_anndef * 12 + return (min_spacing, maj_spacing) + +#............................................................................... +class TimeSeries_DateLocator(Locator): + "Locates the ticks along an axis controlled by a DateArray." + + def __init__(self, freq, minor_locator=False, dynamic_mode=True, + base=1, quarter=1, month=1, day=1): + self.freqstr = freq + self.base = base + (self.quarter, self.month, self.day) = (quarter, month, day) + self.isminor = minor_locator + self.isdynamic = dynamic_mode + self.offset = 0 + + def _initialize_dates(self, start_val, end_val): + "Returns a DateArray for the current frequency." + freq = self.freqstr + dates = date_array(start_date=Date(freq, value=start_val), + end_date=Date(freq, value=end_val), + freq=freq) + return dates + + def _get_default_spacing(self, span): + "Returns the default ticks spacing." + raise NotImplementedError('Derived must override') + + def __call__(self): + 'Return the locations of the ticks.' + self.verify_intervals() + vmin, vmax = self.viewInterval.get_bounds() + if vmax < vmin: + vmin, vmax = vmax, vmin + if self.isdynamic: + base = self._get_default_spacing(vmax-vmin+1) + else: + base = self.base + d = vmin // base + vmin = (d+1) * base + self.offset + locs = range(vmin, vmax+1, base) + return locs + + def autoscale(self): + """Sets the view limits to the nearest multiples of base that contain + the data. + """ + self.verify_intervals() + dmin, dmax = self.dataInterval.get_bounds() + if self.isdynamic: + base = self._get_default_spacing(dmax-dmin+1) + else: + base = self.base + (d,m) = divmod(dmin, base) + if m < base/2: + vmin = d * base + else: + vmin = (d+1) * base + (d,m) = divmod(dmax, base) + vmax = (d+1) * base + if vmin == vmax: + vmin -= 1 + vmax += 1 + return nonsingular(vmin, vmax) + +#............................................................................... +class TimeSeries_AnnualLocator(TimeSeries_DateLocator): + "Locates the ticks along an axis controlled by an annual DateArray." + + def __init__(self, minor_locator=False, dynamic_mode=True, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self,'A', minor_locator, dynamic_mode, + base, quarter, month, day) + + def _get_default_spacing(self, span): + "Returns the default tick spacing for annual data." + (minor, major) = _get_default_annual_spacing(span) + if self.isminor: + return minor + return major +#............................................................................... +class TimeSeries_QuarterlyLocator(TimeSeries_DateLocator): + "Locates the ticks along an axis controlled by a quarterly DateArray." + + def __init__(self, minor_locator=False, dynamic_mode=True, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self,'Q', minor_locator, dynamic_mode, + base, quarter, month, day) + self.offset=1 + + def _get_default_spacing(self, span): + "Returns the default tick spacing for quarterly data." + (minor, major) = _get_default_quarterly_spacing(span) + if self.isminor: + return minor + return major +#............................................................................... +class TimeSeries_MonthlyLocator(TimeSeries_DateLocator): + "Locates the ticks along an axis controlled by a monthly DateArray." + + def __init__(self, minor_locator=False, dynamic_mode=True, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self,'M', minor_locator, dynamic_mode, + base, quarter, month, day) + self.offset = 1 + + def _get_default_spacing(self, span): + "Returns the default tick spacing for monthly data." + (minor, major) = _get_default_monthly_spacing(span) + if self.isminor: + return minor + return major + +#............................................................................... +class TimeSeries_DailyLocator(TimeSeries_DateLocator): + "Locates the ticks along an axis controlled by a daily DateArray." + + def __init__(self, freq, minor_locator=False, dynamic_mode=True, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self, freq, minor_locator, dynamic_mode, + base, quarter, month, day) + if self.freqstr == 'B': + self.daysinyear = 261 + else: + self.daysinyear = 365 + self._cacheddates = None + + def _get_default_locs(self, vmin, vmax): + "Returns the default tick locations for daily data." + daysperyear = self.daysinyear + span = vmax - vmin + 1 + dates = self._initialize_dates(vmin, vmax) + default = N.arange(vmin, vmax+1) + # + if span <= daysperyear//12: + minor = default + major = default[(dates.day_of_week == 1)] + elif span <= daysperyear//3: + minor = default[(dates.day_of_week == 1)] + major = default[(dates.day == 1)] + elif span <= 1.5 * daysperyear: + minor = default[(dates.day_of_week == 1)] + major = default[(dates.day == 1)] + elif span <= 3 * daysperyear: + minor = default[(dates.day == 1)] + major = default[(dates.day_of_year == 1)] + elif span <= 11 * daysperyear: + minor = default[(dates.quarter != (dates-1).quarter)] + major = default[(dates.day_of_year == 1)] + else: + (min_anndef, maj_anndef) = _get_default_annual_spacing(span/daysperyear) + annual = (dates.day_of_year == 1) + minor = default[annual & (dates.years % min_anndef == 0)] + major = default[annual & (dates.years % maj_anndef == 0)] + if self.isminor: + return minor + return major + + def __call__(self): + 'Return the locations of the ticks' + self.verify_intervals() + vmin, vmax = self.viewInterval.get_bounds() + if vmax < vmin: + vmin, vmax = vmax, vmin + if self.isdynamic: + locs = self._get_default_locs(vmin, vmax) + else: + base = self.base + (d,m) = divmod(vmin, base) + 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 + the data. + """ + self.verify_intervals() + dmin, dmax = self.dataInterval.get_bounds() + locs = self._get_default_locs(dmin, dmax) + (vmin, vmax) = locs[[0,-1]] + if vmin == vmax: + vmin -= 1 + vmax += 1 + return nonsingular(vmin, vmax) + +#............................................................................... +class TimeSeries_YearLocator(TimeSeries_DateLocator): + """Locates ticks along a Date axis, for each (multiple of) year. + +:Ivariables: + - `base` : Integer + Gives the spacing between two consecutive annual ticks. + - `quarter` : Integer *[1]* + Tells on which quarter the ticks should be. + - `month` : Integer *[1]* + Tells on which month the ticks should be. + - `day` : Integer *[1]* + Tells on which day the ticks should be. + """ + def __init__(self, freq, minor_locator=False, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self, freq, minor_locator, False, + base, quarter, month, day) + + def __call__(self): + self.verify_intervals() + vmin, vmax = self.viewInterval.get_bounds() + freq = self.freqstr + if freq == 'A': + return range(vmin, vmax+1, self.base) + else: + dates = self._initialize_dates() + if freq == 'Q': + locs = (dates.quarters == self.quarter) + elif freq == 'M': + locs = (dates.months == self.month) + elif freq in 'BDU': + locs = (dates.months == self.month) & (dates.day == self.day) + if self.base > 1: + locs &= (locs.cumsum() % self.base == 1) + return dates.tovalue()[locs] +#............................................... +class TimeSeries_QuarterLocator(TimeSeries_DateLocator): + """Locates ticks along a Date axis, for each (multiple of) quarter. + +:Ivariables: + - `base` : Integer + Gives the spacing between two consecutive quarter ticks. + - `month` : Integer *[1]* + Tells on which month the ticks should be. + - `day` : Integer *[1]* + Tells on which day the ticks should be. + """ + + def __init__(self, freq, minor_locator=False, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self, freq, minor_locator, False, + base, quarter, month, day) + + def __call__(self): + self.verify_intervals() + vmin, vmax = self.viewInterval.get_bounds() + freq = self.freqstr + if freq == 'A': + msg = "The current frequency ('%s') is too coarse!" % freq + raise ValueError, msg + elif freq == 'Q': + return range(vmin, vmax+1, self.base) + else: + dates = self._initialize_dates() + values = dates.tovalue() + if freq == 'M': + locs = (dates.months % 4 == self.month) + elif freq in 'BDU': + locs = (dates.months % 4 == self.month) & (dates.day == self.day) + if self.base > 1: + locs &= (locs.cumsum() % self.base == 1) + return values[locs] +#............................................................................... +class TimeSeries_MonthLocator(TimeSeries_DateLocator): + """Locates ticks along a Date axis, for each (multiple of) month. + +:Ivariables: + - `base` : Integer + Gives the spacing between two consecutive quarter ticks. + - `month` : Integer *[1]* + Tells on which month the ticks should be. + - `day` : Integer *[1]* + Tells on which day the ticks should be. + """ + + def __init__(self, freq, minor_locator=False, + base=1, quarter=1, month=1, day=1): + TimeSeries_DateLocator.__init__(self, freq, minor_locator, False, + base, quarter, month, day) + + def __call__(self): + self.verify_intervals() + vmin, vmax = self.viewInterval.get_bounds() + freq = self.freqstr + if freq == 'AQ': + msg = "The current frequency ('%s') is too coarse!" % freq + raise ValueError, msg + elif freq == 'M': + return range(vmin, vmax+1, self.base) + else: + dates = self._initialize_dates() + values = dates.tovalue() + if freq in 'BDU': + locs = (dates.months == self.month) & (dates.day == self.day) + if self.base > 1: + locs &= (locs.cumsum() % self.base == 1) + return values[locs] + +#####--------------------------------------------------------------------------- +#---- --- Formatter --- +#####--------------------------------------------------------------------------- +class TimeSeries_DateFormatter(Formatter): + """Formats the ticks along a DateArray axis.""" + + def __init__(self, freq, fmt=None): + if fmt is None: + fmt = Date.default_fmtstr[freq] + self.fmt = fmt + self.freqstr = freq + + def __call__(self, x, pos=0): + return Date(self.freqstr, value=int(x)).strfmt(self.fmt) + + +#####-------------------------------------------------------------------------- +#---- --- TimeSeries plots --- +#####-------------------------------------------------------------------------- +class TimeSeriesPlot(Subplot, object): + """Defines a time series based subclass of Subplot.""" + def __init__(self, fig=None, *args, **kwargs): + """ +Accepts the same keywords as a standard subplot, plus a specific `series` keyword. + +:Parameters: + `fig` : Figure + Base figure. + +:Keywords: + `series` : TimeSeries + Data to plot + + """ + # Retrieve the series ................... + _series = kwargs.pop('series',None) + Subplot.__init__(self,fig,*args,**kwargs) +# # Force fig to be defined ..... +# if fig is None: +# fig = TSFigure(_series) + # Process options ....................... + if _series is not None: + assert hasattr(_series, "dates") + self._series = _series.ravel() + self.xdata = _series.dates + self.freqstr = _series.dates.freqstr + self.xaxis.set_major_locator + + else: + self._series = None + self.xdata = None + self.freqstr = None + self._austoscale = False + # Get the data to plot + self.legendsymbols = [] + self.legendlabels = [] + #............................................ + def set_ydata(self, series=None): + """Sets the base time series.""" + if self._series is not None: + print "WARNING ! Base series is being changed.""" + self._series = series.ravel() + if isinstance(series, TimeSeries): + self.xdata = self.series.dates + #.... + def get_ydata(self): + """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).""" + # At least three arguments .... + if len(args) >= 3: + params = args[:3] + # Two arguments only .......... + elif len(args) == 2: + if isinstance(args[1], str): + # The last argument is a format string + arg = args[0] + if isinstance(arg, TimeSeries): + params = (arg._dates, arg._series, args[1]) + elif self.xdata is None: + raise ValueError, "No date information available!" + else: + params = (self.xdata, args[0], args[1]) + else: + params = args + # One argument only ........... + elif len(args) == 1: + if isinstance(args[0], str): + if self.xdata is None: + raise ValueError, "No date information available!" + else: + params = (self.xdata, self.ydata, args[0]) + elif isinstance(args[0], TimeSeries): + if self.xdata is None: + arg = args[0] + params = (arg._dates, arg._series) + else: + params = (self.xdata, args[0]) + else: + params = (self.xdata, self.ydata) + # Reinitialize the plot if needed + if self.xdata is None: + self.xdata = params[0] + self.freqstr = self.xdata.freqstr + # Force the xdata to the current frequency + elif params[0].freqstr != self.freqstr: + params = list(params) + params[0] = params[0].asfreq(self.freqstr) + return params + #............................................ + def tsplot(self,*parms,**kwargs): + """Plots the data parsed in argument. +This command accepts the same keywords as `matplotlib.plot`.""" + #print "Parameters: %s - %i" % (parms, len(parms)) + parms = self._check_plot_params(*parms) + self.legendlabels.append(kwargs.get('label',None)) + Subplot.plot(self, *parms,**kwargs) + pylab.draw_if_interactive() +# #............................................ +# def ybaseline(self,ybase,**kwargs): +# """Plots an horizontal baseline on each subplot.""" +# self.axhline(ybase,**kwargs) + #............................................ + 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 tick locator, in years (major tick every `major` years). + `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 ................. + if self.freqstr in 'BDU': + locator = TimeSeries_DailyLocator + self.xaxis.set_major_locator(locator(self.freqstr, + minor_locator=False, + dynamic_mode=True)) + self.xaxis.set_minor_locator(locator(self.freqstr, + minor_locator=True, + dynamic_mode=True)) + else: + if self.freqstr == 'A': + locator = TimeSeries_AnnualLocator + elif self.freqstr == 'Q': + locator = TimeSeries_QuarterlyLocator + elif self.freqstr == 'M': + locator = TimeSeries_MonthlyLocator + self.xaxis.set_major_locator(locator(minor_locator=False, + dynamic_mode=True)) + self.xaxis.set_minor_locator(locator(minor_locator=True, + dynamic_mode=True)) + #........................................ + self.xaxis.set_major_formatter(TimeSeries_DateFormatter(self.freqstr)) +# if rcParams['backend'] == 'PS': +# rotate = False +# warnings.warn("dateplot: PS backend detected, rotate disabled") +# if self.is_last_row(): +# if rotate: +# setp(self.get_xticklabels(),rotation=45) +# self.xaxis.set_major_formatter(FuncFormatter(self.dateticks_formatter)) +# self.xaxis.set_minor_formatter(FuncFormatter(self.dateticks_formatter)) +# else: +# self.set_xticklabels([]) +# self.set_xlabel('') +# #............................................ +# def plot_shifts(self,shifts,**kwargs): +# """Plots regime shifts. +#:param shifts: Shifts/trends to plot. +#:type shifts: `RegimeShift` +# """ +# self.tsplot(self.xdata,shifts.regimes,**kwargs) +# for x in shifts.xshifts[0]: +# self.axvline(self.xdata[x],ls=':',c='#999999',lw=0.5) + #............................................ +TSPlot = TimeSeriesPlot + + +#####-------------------------------------------------------------------------- +#---- --- TimeSeries Figures --- +#####-------------------------------------------------------------------------- +class TimeSeriesFigure(Figure): + """Time Series Figure: all subplots share the same time series. + """ + def __init__(self, series=None, **kwargs): + self._series = series + Figure.__init__(self,**kwargs) + fspnum = kwargs.pop('fspnum',None) + if fspnum is not None: + self.add_tsplot(fspnum, series=series) + #......... + def add_tsplot(self, *args, **kwargs): + """Adds a `TimeSeriesPlot` subplot to the figure.""" + kwargs.update(SubplotClass=TimeSeriesPlot, + series=self._series) + return add_generic_subplot(self, *args, **kwargs) + add_plot = add_tsplot +TSFigure = TimeSeriesFigure +#Figure.add_tsplot = +#................................................ +def tsfigure(series, **figargs): + """Creates a new `TimeSeriesFigure` object. + +:Parameters: + `series` : TimeSeries object + Input data. + `figargs` : Dictionary + Figure options [`figsize`, `dpi`, `facecolor`, `edgecolor`, `frameon`]. + """ + figargs.update(FigureClass=TSFigure) + figargs.update(series=series) +# print "figargs:",figargs +# num = figargs.pop('num',None) + fig = pylab.figure(**figargs) + return fig + +def add_tsplot(axes, *args, **kwargs): + kwargs.update(SubplotClass=TimeSeriesPlot) + if 'series' not in kwargs.keys(): + 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() + h = kwargs.pop('hold', None) + if h is not None: + pylab.hold(h) + try: + ret = pylab.gca().add_tsplot(*args, **kwargs) + pylab.draw_if_interactive() + except: + pylab.hold(b) + raise + + pylab.hold(b) + return ret + +################################################################################ +if __name__ == '__main__': + + da = date_array(start_date=Date(freq='D', year=2003, quarter=3, month=1, day=17), + length=51) + ser = tseries.time_series(MA.arange(len(da)), dates=da) + ser[4] = MA.masked + ser_2 = tseries.time_series(MA.arange(len(da)), dates=da.asfreq('M')) + + 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 Property changes on: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Deleted: trunk/Lib/sandbox/timeseries/plotlib/plot.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/plot.py 2007-01-28 01:25:37 UTC (rev 2623) +++ trunk/Lib/sandbox/timeseries/plotlib/plot.py 2007-01-29 05:34:25 UTC (rev 2624) @@ -1,230 +0,0 @@ -import pylab as pl -import timeseries as ts -from matplotlib.ticker import FixedLocator, FuncFormatter -import numpy as np -import types - - -class DateAxis: - def __init__(self, start_date, end_date): - - freq = start_date.freq - numPers = end_date - start_date + 1 - - self.xaxis = np.arange(numPers) - self.xlabel_txt = '' - - tser = ts.tser(start_date, end_date) - - minor_labels = ['' for x in range(numPers)] - major_labels = ['' for x in range(numPers)] - - minor_ticks = [] - major_ticks = [] - - years = ts.year(tser) - year_starts = (years - ts.year(tser-1) != 0) - year_start_inds = [int(x) for x in np.where(year_starts)[0]] - - quarters = ts.quarter(tser) - quarter_starts = (quarters - ts.quarter(tser-1) != 0) - quarter_start_inds = [int(x) for x in np.where(quarter_starts)[0]] - - months = ts.month(tser) - month_starts = (months - ts.month(tser-1) != 0) - month_start_inds = [int(x) for x in np.where(month_starts)[0]] - - - def yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks): - - numYears = end_date.year() - start_date.year() - - if numYears < 20: minor_spacing, major_spacing = 1, 2 - elif numYears < 50: minor_spacing, major_spacing = 1, 5 - elif numYears < 100: minor_spacing, major_spacing = 5, 10 - elif numYears < 200: minor_spacing, major_spacing = 5, 20 - elif numYears < 400: minor_spacing, major_spacing = 5, 25 - elif numYears < 1000: minor_spacing, major_spacing = 10, 50 - else: minor_spacing, major_spacing = 20, 100 - - for x in [y for y in year_start_inds if years[y] % minor_spacing == 0]: - minor_ticks += [x] - if years[x] % major_spacing == 0: - major_ticks += [x] - major_labels[x] += (start_date + x).strfmt('%Y') - - return minor_labels, major_labels, minor_ticks, major_ticks - - if freq == 'A': - minor_labels, major_labels, minor_ticks, major_ticks = \ - yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) - - elif freq == 'Q': - - if numPers <= 3 * 4: - - minor_ticks = list(range(numPers)) - major_ticks = year_start_inds - - for x in range(numPers): - minor_labels[x] = (start_date + x).strfmt('Q%q') - if year_starts[x]: - major_labels[x] += '\n\n'+(start_date + x).strfmt('%Y') - - elif numPers <= 11 * 4: - - minor_ticks = list(range(numPers)) - - for x in [y for y in quarter_start_inds if quarters[y] == 1]: - major_ticks += [x] - major_labels[x] += (start_date + x).strfmt('%Y') - - else: - - minor_labels, major_labels, minor_ticks, major_ticks = \ - yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) - - elif freq == 'M': - - if numPers <= 1.5 * 12: - - minor_ticks = list(range(numPers)) - major_ticks = year_start_inds - - for x in range(numPers): - minor_labels[x] = (start_date + x).strfmt('%b') - if year_starts[x]: - major_labels[x] += '\n\n'+(start_date + x).strfmt('%Y') - - elif numPers <= 3 * 12: - - minor_ticks = list(range(numPers)) - - for x in range(numPers): - - _date = start_date + x - if (_date.month() - 1) % 2 == 0: - minor_labels[x] += _date.strfmt('%b') - - if year_starts[x] == 1: - major_ticks += [x] - major_labels[x] += '\n\n'+_date.strfmt('%Y') - - elif numPers <= 11 * 12: - - minor_ticks = quarter_start_inds - - for x in [y for y in quarter_start_inds if quarters[y] == 1]: - major_ticks += [x] - major_labels[x] += (start_date + x).strfmt('%Y') - - else: - - minor_labels, major_labels, minor_ticks, major_ticks = \ - yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) - - elif freq in ('B', 'D'): - - if freq == 'B': daysInYear = 261 - else: daysInYear = 365 - - if numPers <= daysInYear // 3: - - if numPers < daysInYear // 12: spacing = 1 - else: spacing = 5 - - minor_ticks = list(range(numPers)) - major_ticks = [int(x) for x in month_start_inds] - - for x in range(numPers): - - _date = start_date + x - - if x % spacing == 0: minor_labels[x] = _date.strfmt('%d') - if month_starts[x]: - major_labels[x] += '\n\n'+_date.strfmt('%b') - major_ticks += [x] - - if year_starts[x]: - major_labels[x] += '\n'+_date.strfmt('%Y') - - elif numPers <= 1.5 * daysInYear: - - minor_ticks = list(range(numPers)) - major_ticks = month_start_inds - - for x in month_start_inds: - _date = start_date + x - major_labels[x] += _date.strfmt('%b') - if months[x] == 1: major_labels[x] += '\n'+_date.strfmt('%Y') - - elif numPers <= 3 * daysInYear: - - minor_ticks = month_start_inds - - for x in [y for y in month_start_inds if (months[y] - 1) % 3 == 0]: - - _date = start_date + x - minor_labels[x] += _date.strfmt('%b') - - if months[x] == 1: - major_ticks += [x] - major_labels[x] += '\n\n'+_date.strfmt('%Y') - - elif numPers <= 11 * daysInYear: - - minor_ticks = quarter_start_inds - - for x in [y for y in quarter_start_inds if quarters[y] == 1]: - major_ticks += [x] - major_labels[x] += (start_date + x).strfmt('%Y') - - else: - - minor_labels, major_labels, minor_ticks, major_ticks = \ - yearsOnly(minor_labels, major_labels, minor_ticks, major_ticks) - - else: - raise ValueError("unsupported frequency: "+freq) - - # if date range is such that no year or month is included in the labels, add these to the start - if years[0] == years[-1] and (start_date - 1).year() == start_date.year(): - - breaksBeforeYear = 2 - - if freq in ('B', 'D'): - if months[0] == months[-1] and (start_date - 1).month() == start_date.month(): - major_labels[0] += '\n\n'+start_date.strfmt('%b') - breaksBeforeYear = 1 - - if breaksBeforeYear > 1 and len([x for x in major_labels if x != '']) > 0: breaksBeforeYear += 1 - - major_labels[0] += ('\n' * breaksBeforeYear)+(start_date).strfmt('%Y') - - if 0 not in major_ticks: major_ticks = [0] + major_ticks - - self.major_labels = major_labels - self.major_locator = FixedLocator(major_ticks) - - self.minor_labels = minor_labels - self.minor_locator = FixedLocator(minor_ticks) - - def minor_formatter(self, x, pos): - if type(x) is types.IntType: - return self.minor_labels[x] - else: - return '' - - def major_formatter(self, x, pos): - if type(x) is types.IntType: - return self.major_labels[x] - else: - return '' - - - def set_labels(self, subplot): - subplot.xaxis.set_minor_locator(self.minor_locator) - subplot.xaxis.set_minor_formatter(FuncFormatter(self.minor_formatter)) - - subplot.xaxis.set_major_locator(self.major_locator) - subplot.xaxis.set_major_formatter(FuncFormatter(self.major_formatter)) From scipy-svn at scipy.org Mon Jan 29 09:57:55 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 08:57:55 -0600 (CST) Subject: [Scipy-svn] r2625 - trunk/Lib/sandbox/timeseries Message-ID: <20070129145755.425C039C03B@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 08:57:50 -0600 (Mon, 29 Jan 2007) New Revision: 2625 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: changed adjust_endpoints so that it can handle a zero length time series Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 05:34:25 UTC (rev 2624) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 14:57:50 UTC (rev 2625) @@ -987,7 +987,7 @@ if a.freq == 'U': raise TimeSeriesError, \ "Cannot adjust a series with 'Undefined' frequency." - if not a.dates.isvalid(): + if not a.dates.isvalid() and a.ndim > 0 and a.size > 1: raise TimeSeriesError, \ "Cannot adjust a series with missing or duplicated dates." # Flatten the series if needed .............. @@ -995,39 +995,52 @@ shp_flat = a.shape # Dates validity checks .,................... msg = "%s should be a valid Date instance! (got %s instead)" - (dstart, dend) = a.dates[[0,-1]] - if start_date is None: - start_date = dstart - start_lag = 0 - else: - if not isDateType(start_date): - raise TypeError, msg % ('start_date', type(start_date)) - start_lag = start_date - dstart - #.... - if end_date is None: - end_date = dend - end_lag = 0 - else: - if not isDateType(end_date): - raise TypeError, msg % ('end_date', type(end_date)) - end_lag = end_date - dend - # Check if the new range is included in the old one - if start_lag >= 0: - if end_lag == 0: - return a[start_lag:] - elif end_lag < 0: - return a[start_lag:end_lag] + + (dstart, dend) = a.start_date, a.end_date + if dstart is not None: + + if start_date is None: + start_date = dstart + start_lag = 0 + else: + if not isDateType(start_date): + raise TypeError, msg % ('start_date', type(start_date)) + start_lag = start_date - dstart + #.... + if end_date is None: + end_date = dend + end_lag = 0 + else: + if not isDateType(end_date): + raise TypeError, msg % ('end_date', type(end_date)) + end_lag = end_date - dend + # Check if the new range is included in the old one + if start_lag >= 0: + if end_lag == 0: + return a[start_lag:] + elif end_lag < 0: + return a[start_lag:end_lag] + + else: + if start_date is None or end_date is None: + raise TimeSeriesError, \ + """start_date and end_date must be specified to adjust +endpoints of a zero length series""" + # 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) - + newdata = masked_array(numeric.empty(newshape, dtype=a.dtype), mask=True) newseries = TimeSeries(newdata, newdates) - start_date = max(start_date, dstart) - end_date = min(end_date, dend) + 1 - newseries[start_date:end_date] = a[start_date:end_date] + + if dstart is not None: + start_date = max(start_date, dstart) + end_date = min(end_date, dend) + 1 + newseries[start_date:end_date] = a[start_date:end_date] + return newseries #.................................................................... def align_series(*series, **kwargs): From scipy-svn at scipy.org Mon Jan 29 10:14:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 09:14:08 -0600 (CST) Subject: [Scipy-svn] r2626 - trunk/Lib/sandbox/timeseries Message-ID: <20070129151408.451D939C03B@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 09:14:04 -0600 (Mon, 29 Jan 2007) New Revision: 2626 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: modified align_series so that it can handle series of size zero Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 14:57:50 UTC (rev 2625) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 15:14:04 UTC (rev 2626) @@ -1064,15 +1064,17 @@ if common_freq == 'U': raise TimeSeriesError, \ "Cannot adjust a series with 'Undefined' frequency." - valid_states = [x.isvalid() for x in series] + valid_states = [x.isvalid() or (x.size == 0 and x.ndim > 0) 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])) + print start_date if isinstance(start_date,str): start_date = Date(common_freq, string=start_date) - end_date = kwargs.pop('end_date', max([x.end_date for x in series])) + end_date = kwargs.pop('end_date', max([x.end_date for x in series if x.end_date is not None])) + print end_date if isinstance(end_date,str): end_date = Date(common_freq, string=end_date) From scipy-svn at scipy.org Mon Jan 29 10:18:48 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 09:18:48 -0600 (CST) Subject: [Scipy-svn] r2627 - trunk/Lib/sandbox/timeseries Message-ID: <20070129151848.0814739C03B@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 09:18:45 -0600 (Mon, 29 Jan 2007) New Revision: 2627 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: removed some print statements that I accidentally left in from debugging earlier Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 15:14:04 UTC (rev 2626) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 15:18:45 UTC (rev 2627) @@ -1070,11 +1070,9 @@ "Cannot adjust a series with missing or duplicated dates." start_date = kwargs.pop('start_date', min([x.start_date for x in series if x.start_date is not None])) - print start_date if isinstance(start_date,str): start_date = Date(common_freq, string=start_date) end_date = kwargs.pop('end_date', max([x.end_date for x in series if x.end_date is not None])) - print end_date if isinstance(end_date,str): end_date = Date(common_freq, string=end_date) From scipy-svn at scipy.org Mon Jan 29 10:19:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 09:19:32 -0600 (CST) Subject: [Scipy-svn] r2628 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070129151932.317A939C03B@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 09:19:29 -0600 (Mon, 29 Jan 2007) New Revision: 2628 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added tests for align_series (including a series of size zero also) Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-29 15:18:45 UTC (rev 2627) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-29 15:19:29 UTC (rev 2628) @@ -28,7 +28,7 @@ from timeseries import tseries #reload(tseries) from timeseries.tseries import Date, date_array_fromlist -from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, mask_period +from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, mask_period, align_series class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -270,6 +270,12 @@ end_date=Date('D', string='2007-01-31')) assert_equal(dseries.size, 26) assert_equal(dseries._mask, N.r_[series._mask[5:], [1]*16]) + + empty_series = time_series([], freq='d') + 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_maskperiod(self): "Test mask_period" From scipy-svn at scipy.org Mon Jan 29 16:01:03 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 15:01:03 -0600 (CST) Subject: [Scipy-svn] r2629 - trunk/Lib/sandbox/timeseries Message-ID: <20070129210103.CC92039C11D@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 15:00:59 -0600 (Mon, 29 Jan 2007) New Revision: 2629 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: added tshift function and method. Removed redundant definition of convert as a method in the TimeSeries class Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 15:19:29 UTC (rev 2628) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 21:00:59 UTC (rev 2629) @@ -517,11 +517,8 @@ 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) + ##### -------------------------------------------------------------------------- ##--- ... Additional methods ... ##### -------------------------------------------------------------------------- @@ -1034,8 +1031,12 @@ newshape = tuple(newshape) newdata = masked_array(numeric.empty(newshape, dtype=a.dtype), mask=True) - newseries = TimeSeries(newdata, newdates) + # need to ensure that we preserve attributes of the series in the result + options = dict(fill_value=a.fill_value, observed=a.observed) + + newseries = TimeSeries(newdata, newdates, **options) + if dstart is not None: start_date = max(start_date, dstart) end_date = min(end_date, dend) + 1 @@ -1136,9 +1137,46 @@ observed=series.observed, start_date=start_date) return newseries +#.................................................................... +def tshift(series, nper): + """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) - 1) +:Example: +>>> series = tseries.time_series([0,1,2,3], start_date=tdates.Date(freq='A', year=2005)) +>>> series +timeseries(data = [0 1 2 3], + dates = [2005 ... 2008], + freq = A) +>>> tshift(series, -1) +timeseries(data = [-- 0 1 2], + dates = [2005 ... 2008], + freq = A) +""" + newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) + # need to ensure that we preserve attributes of the series in the result + options = dict(fill_value=series.fill_value, observed=series.observed) + newseries = TimeSeries(newdata, series._dates, **options) + + if nper < 0: + nper = max(-series.shape[0],nper) + newseries[-nper:] = series._series[:nper].copy() + newseries[:-nper] = masked + elif nper > 0: + nper = min(series.shape[0],nper) + newseries[-nper:] = masked + newseries[:-nper] = series._series[nper:].copy() + else: + newseries[:] = self._series[:].copy() + + return newseries +#.................................................................... TimeSeries.convert = convert +TimeSeries.tshift = tshift + #.................................................................... def fill_missing_dates(data, dates=None, freq=None,fill_value=None): """Finds and fills the missing dates in a time series. From scipy-svn at scipy.org Mon Jan 29 16:01:40 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 15:01:40 -0600 (CST) Subject: [Scipy-svn] r2630 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070129210140.37F7A39C11D@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 15:01:36 -0600 (Mon, 29 Jan 2007) New Revision: 2630 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added tests for tshift function Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-29 21:00:59 UTC (rev 2629) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-29 21:01:36 UTC (rev 2630) @@ -276,6 +276,22 @@ 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] + shift_negative = series.tshift(-1) + result_data = [999] + [0,1,2,3,4,5,6,7,8,9,10,11,12,13] + result_mask = [1 ] + [1,0,0,0,0,1,0,0,0,0,1, 0, 0, 0 ] + shift_negative_result = time_series(result_data, series._dates, mask=result_mask) + + shift_positive = series.tshift(1) + 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_maskperiod(self): "Test mask_period" From scipy-svn at scipy.org Mon Jan 29 16:41:44 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 15:41:44 -0600 (CST) Subject: [Scipy-svn] r2631 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070129214144.1B56A39C00C@new.scipy.org> Author: mattknox_ca Date: 2007-01-29 15:41:41 -0600 (Mon, 29 Jan 2007) New Revision: 2631 Modified: trunk/Lib/sandbox/timeseries/tests/test_misc.py Log: Modified: trunk/Lib/sandbox/timeseries/tests/test_misc.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-01-29 21:01:36 UTC (rev 2630) +++ trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-01-29 21:41:41 UTC (rev 2631) @@ -1,12 +1,12 @@ # pylint: disable-msg=W0611, W0612, W0511,R0201 -"""Tests suite for MaskedArray. +"""Tests suite for miscellaneous functions in timeseries module. Adapted from the original test_ma by Pierre Gerard-Marchant -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu -:version: $Id: test_timeseries.py 2578 2007-01-17 19:25:10Z mattknox_ca $ +:author: Matt Knox +:contact: mattknox_ca_at_hotmail_dot_com +:version: $Id: test_misc.py 2578 2007-01-17 19:25:10Z mattknox_ca $ """ -__author__ = "Pierre GF Gerard-Marchant ($Author: mattknox_ca $)" +__author__ = "Matt Knox ($Author: mattknox_ca $)" __version__ = '1.0' __revision__ = "$Revision: 2578 $" __date__ = '$Date: 2007-01-17 14:25:10 -0500 (Wed, 17 Jan 2007) $' From scipy-svn at scipy.org Mon Jan 29 18:03:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 17:03:20 -0600 (CST) Subject: [Scipy-svn] r2632 - trunk/Lib/signal Message-ID: <20070129230320.01DEC39C05C@new.scipy.org> Author: oliphant Date: 2007-01-29 17:03:18 -0600 (Mon, 29 Jan 2007) New Revision: 2632 Modified: trunk/Lib/signal/filter_design.py Log: Fix integer-input problems Modified: trunk/Lib/signal/filter_design.py =================================================================== --- trunk/Lib/signal/filter_design.py 2007-01-29 21:41:41 UTC (rev 2631) +++ trunk/Lib/signal/filter_design.py 2007-01-29 23:03:18 UTC (rev 2632) @@ -624,8 +624,8 @@ passb = tan(wp*pi/2.0) stopb = tan(ws*pi/2.0) else: - passb = wp - stopb = ws + passb = wp*1.0 + stopb = ws*1.0 if filter_type == 1: # low nat = stopb / passb @@ -729,11 +729,11 @@ # Pre-wagpass frequencies if not analog: - passb = tan(pi*wp/2) - stopb = tan(pi*ws/2) + passb = tan(pi*wp/2.) + stopb = tan(pi*ws/2.) else: - passb = wp - stopb = ws + passb = wp*1.0 + stopb = ws*1.0 if filter_type == 1: # low nat = stopb / passb @@ -806,11 +806,11 @@ # Pre-wagpass frequencies if not analog: - passb = tan(pi*wp/2) - stopb = tan(pi*ws/2) + passb = tan(pi*wp/2.0) + stopb = tan(pi*ws/2.0) else: - passb = wp - stopb = ws + passb = wp*1.0 + stopb = ws*1.0 if filter_type == 1: # low nat = stopb / passb @@ -906,8 +906,8 @@ # Pre-wagpass frequencies if analog: - passb = wp - stopb = ws + passb = wp*1.0 + stopb = ws*1.0 else: passb = tan(wp*pi/2.0) stopb = tan(ws*pi/2.0) From scipy-svn at scipy.org Mon Jan 29 23:08:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 29 Jan 2007 22:08:36 -0600 (CST) Subject: [Scipy-svn] r2633 - in trunk/Lib/sandbox/timeseries: . examples tests Message-ID: <20070130040836.C7BCA39C072@new.scipy.org> Author: pierregm Date: 2007-01-29 22:08:29 -0600 (Mon, 29 Jan 2007) New Revision: 2633 Modified: trunk/Lib/sandbox/timeseries/.project trunk/Lib/sandbox/timeseries/examples/example.py trunk/Lib/sandbox/timeseries/examples/example.wiki 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_misc.py trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py trunk/Lib/sandbox/timeseries/tests/test_timeseries.py trunk/Lib/sandbox/timeseries/tmulti.py trunk/Lib/sandbox/timeseries/tseries.py Log: fixed freq/freqstr force DateArray singletons to shape (1,) misc. improvements on tshift Modified: trunk/Lib/sandbox/timeseries/.project =================================================================== --- trunk/Lib/sandbox/timeseries/.project 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/.project 2007-01-30 04:08:29 UTC (rev 2633) @@ -1,6 +1,6 @@ - timeseries + scipy_svn_timeseries Modified: trunk/Lib/sandbox/timeseries/examples/example.py =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/examples/example.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -14,15 +14,20 @@ TD.Date('D', mxDate=datetime.datetime.now()) mybirthday = D-1 infivemonths = M + 5 +mybirthday.asfreq('M') +mybirthday.asfreq('M').asfreq('D') data = N.random.uniform(-100,100,600) today = TD.thisday('B') series = TS.time_series(data, dtype=N.float_, freq='B', observed='SUMMED', start_date=today-600) +isinstance(series.dates, TD.DateArray) +isinstance(series.series, MA.MaskedArray) series[0] series[-30:] thirtydaysago = today - 30 series[thirtydaysago:] series[thirtydaysago.tostring():] +series[[0,-1]] series[series<0] = 0 series[series.day_of_week == 4] = 100 weekdays = TD.day_of_week(series) @@ -32,14 +37,14 @@ mlist_1 += ['2006-%02i' % i for i in range(2,13)] mdata_1 = N.arange(len(mlist_1)) mser_1 = TS.time_series(mdata_1, mlist_1, observed='SUMMED') -mser = mser1.asfreq('M') -mser1.has_duplicated_dates() -mser1.has_missing_dates() +mser_1 = mser_1.asfreq('M') +mser_1.has_duplicated_dates() +mser_1.has_missing_dates() mlist_2 = ['2004-%02i' % i for i in range(1,13)] mlist_2 += ['2005-%02i' % i for i in range(1,13)] mser_2 = TS.time_series(N.arange(len(mlist_2)), mlist_2, observed='SUMMED') -mser_3 = mser_1 + mser_2 -(malg_1,malg_2) = aligned(mser_1, mser_2) +#mser_3 = mser_1 + mser_2 +(malg_1,malg_2) = TS.aligned(mser_1, mser_2) mser_1_filled = fill_missing_dates(mser_1) (malg_1,malg_2) = align_series(mser_1_filled, mser_2) mser_3 = malg_1 + malg_2 Modified: trunk/Lib/sandbox/timeseries/examples/example.wiki =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-30 04:08:29 UTC (rev 2633) @@ -89,20 +89,26 @@ To construct a `DateArray` object, you can call the class directly {{{#!python numbers=disable +DateArray(dates=None, freq='U', copy=False) }}} +where `dates` can be ''(i)'' an existing `DateArray`; ''(ii)'' a sequence of `Date` objects; ''(iii)''' a sequence of objects that `Date` can recognize (such as strings, integers, `mx.DateTime` objects...). +Alternatively, you can use the `date_array` constructor: +{{{#!python numbers=disable +date_array(dlist=None, start_date=None, end_date=None, + include_last=True, length=None, freq=None) +}}} +If `dlist` is None, a new list of dates will be created from `start_date` and `end_date`. You should set `include_last` to True if you want `end_date` to be included. If `end_date` is None, then a series of length `length` will be created. - ---- == TimeSeries == A `TimeSeries` object is the combination of three ndarrays: - * `dates`: DateArray object. * `data` : ndarray. * `mask` : Boolean ndarray, indicating missing or invalid data. - +These three arrays can be accessed as attributes of a TimeSeries object. Another very useful attribute is `series`, that gives you the possibility to directly access `data` and `mask` as a masked array. ==== Construction ==== @@ -131,7 +137,16 @@ >>> series = TS.time_series(data, dtype=N.float_, freq='B', observed='SUMMED', >>> start_date=today-600) }}} +We can check that `series.dates` is a `DateArray` object and that `series.series` is a `MaskedArray` object. +{{{#!python numbers=disable +>>> isinstance(series.dates, TD.DateArray) +True +>>> isinstance(series.series, MA.MaskedArray) +True +}}} +So, if you are already familiar with `MaskedArray`, using `TimeSeries` should be straightforward. Just keep in mind that another attribute is always present, `dates`. + ==== Indexing ==== Elements of a TimeSeries can be accessed just like with regular ndarrrays. Thus, @@ -153,6 +168,11 @@ {{{#!python numbers=disable >>> series[thirtydaysago.tostring():] }}} +or a sequence/ndarray of integers... +{{{#!python numbers=disable +>>> series[[0,-1]] +}}} +~-This latter is quite useful: it gives you the first and last data of your series.-~ In a similar way, setting elements of a TimeSeries works seamlessly. Let us set negative values to zero... @@ -190,16 +210,20 @@ }}} Note that the frequency is 'U', for undefined. In fact, you have to specify what kind of data is actually missing by forcing a given frequency. {{{#!python numbers=disable ->>> mser = mser1.asfreq('M') +>>> mser = mser_1.asfreq('M') }}} Let us check whether there are some duplicated dates (no): {{{#!python numbers=disable ->>> mser1.has_duplicated_dates() +>>> mser_1.has_duplicated_dates() +False }}} ...or missing dates (yes): {{{#!python numbers=disable ->>> mser1.has_missing_dates() +>>> mser_1.has_missing_dates() +True }}} + + Let us construct a second monthly series, this time without missing dates {{{#!python numbers=disable >>> mlist_2 = ['2004-%02i' % i for i in range(1,13)] @@ -227,7 +251,7 @@ {{{#!python numbers=disable >>> mser_3 = filled(malg_1,0) + filled(malg_2,0) }}} -Alternatively, we can force the series to start/end at some given dates +When aligning the series, we could have forced the series to start/end at some given dates: {{{#!python numbers=disable >>> (malg_1,malg_2) = aligned(mser_1_filled, mser2, >>> start_date='2004-06', end_date='2006-06') Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -81,87 +81,114 @@ raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) -fmtfreq_dict = {'A': ['ANNUAL','ANNUALLY','YEAR','YEARLY'], - 'B': ['BUSINESS','BUSINESSLYT'], - 'D': ['DAY','DAILY',], - 'H': ['HOUR','HOURLY',], - 'M': ['MONTH','MONTHLY',], - 'Q': ['QUARTER','QUARTERLY',], - 'S': ['SECOND','SECONDLY',], - 'T': ['MINUTE','MINUTELY',], - 'W': ['WEEK','WEEKLY',], - 'U': ['UNDEF','UNDEFINED'], + +freq_dict = { 1000: ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'], + 2000: ['Q','QUARTER','QUARTERLY',], + 3000: ['M','MONTH','MONTHLY',], + 4000: ['W','WEEK','WEEKLY',], + 5000: ['B','BUSINESS','BUSINESSLYT'], + 6000: ['D','DAY','DAILY',], + 7000: ['H','HOUR','HOURLY',], + 8000: ['T','MINUTE','MINUTELY',], + 9000: ['S','SECOND','SECONDLY',], + -9999: ['U','UNDEF','UNDEFINED'], } -fmtfreq_revdict = reverse_dict(fmtfreq_dict) +freq_revdict = reverse_dict(freq_dict) -def fmtFreq (freqStr): +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 freqStr is None: - return None - elif freqStr.upper() in fmtfreq_dict.keys(): - return freqStr[0].upper() - elif freqStr.upper() in fmtfreq_revdict.keys(): - return fmtfreq_revdict[freqStr.upper()] + 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(freqStr)) - -class DateSpec: - "Fake data type for date variables." - def __init__(self, freq): - self.freq = fmtFreq(freq) - - def __hash__(self): - return hash(self.freq) + raise ValueError("Invalid frequency: %s " % str(freq)) - def __eq__(self, other): - if hasattr(other, "freq"): - return self.freq == other.freq - else: - return False - def __str__(self): - return "Date(%s)" % str(self.freq) - - - -# define custom numpy types. -# Note: A more robust approach would register these as actual valid numpy types -# this is just a hack for now -numpy.dateA = DateSpec("Annual") -numpy.dateB = DateSpec("Business") -numpy.dateD = DateSpec("Daily") -numpy.dateH = DateSpec("Hourly") -numpy.dateM = DateSpec("Monthly") -numpy.dateQ = DateSpec("Quarterly") -numpy.dateS = DateSpec("Secondly") -numpy.dateT = DateSpec("Minutely") -numpy.dateW = DateSpec("Weekly") -numpy.dateU = DateSpec("Undefined") - - -freq_type_mapping = {'A': numpy.dateA, - 'B': numpy.dateB, - 'D': numpy.dateD, - 'H': numpy.dateH, - 'M': numpy.dateM, - 'Q': numpy.dateQ, - 'S': numpy.dateS, - 'T': numpy.dateT, - 'W': numpy.dateW, - 'U': numpy.dateU, - } +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 freqToType(freq): - "Returns the Date dtype corresponding to the given frequency." - return freq_type_mapping[fmtFreq(freq)] +#class DateSpec: +# "Fake data type for date variables." +# def __init__(self, freq): +# self.freq = fmtFreq(freq) +# +# def __hash__(self): +# return hash(self.freq) +# +# def __eq__(self, other): +# if hasattr(other, "freq"): +# return self.freq == other.freq +# else: +# return False +# def __str__(self): +# return "Date(%s)" % str(self.freq) +# +## define custom numpy types. +## Note: A more robust approach would register these as actual valid numpy types +## this is just a hack for now +#numpy.dateA = DateSpec("Annual") +#numpy.dateB = DateSpec("Business") +#numpy.dateD = DateSpec("Daily") +#numpy.dateH = DateSpec("Hourly") +#numpy.dateM = DateSpec("Monthly") +#numpy.dateQ = DateSpec("Quarterly") +#numpy.dateS = DateSpec("Secondly") +#numpy.dateT = DateSpec("Minutely") +#numpy.dateW = DateSpec("Weekly") +#numpy.dateU = DateSpec("Undefined") +# +# +#freq_type_mapping = {'A': numpy.dateA, +# 'B': numpy.dateB, +# 'D': numpy.dateD, +# 'H': numpy.dateH, +# 'M': numpy.dateM, +# 'Q': numpy.dateQ, +# 'S': numpy.dateS, +# 'T': numpy.dateT, +# 'W': numpy.dateW, +# 'U': numpy.dateU, +# } +# +#def freqToType(freq): +# "Returns the Date dtype corresponding to the given frequency." +# return freq_type_mapping[fmtFreq(freq)] +# +#def isDateType(dtype): +# "Returns True whether the argument is the dtype of a Date." +# #TODO: That looks messy. We should simplify that +# if len([x for x in freq_type_mapping.values() if x == dtype]) > 0: +# return True +# else: +# return False -def isDateType(dtype): - "Returns True whether the argument is the dtype of a Date." - #TODO: That looks messy. We should simplify that - if len([x for x in freq_type_mapping.values() if x == dtype]) > 0: - return True - else: - return False - #####--------------------------------------------------------------------------- #---- --- Misc functions --- #####--------------------------------------------------------------------------- Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -32,10 +32,6 @@ import cseries -import logging -logging.basicConfig(level=logging.DEBUG,format='%(name)-15s %(levelname)s %(message)s',) -daflog = logging.getLogger('darray_from') -dalog = logging.getLogger('DateArray') __all__ = [ @@ -116,38 +112,54 @@ >>> td.Date('D', mxDate=mx.DateTime.now()) >>> td.Date('D', mxDate=datetime.datetime.now()) """ - def __init__(self, freq, year=None, month=None, day=None, quarter=None, + 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, - mxDate=None, value=None, string=None): + mxDate=None): if hasattr(freq, 'freq'): - self.freq = corelib.fmtFreq(freq.freq) + self.freq = corelib.check_freq(freq.freq) else: - self.freq = corelib.fmtFreq(freq) - self.freqstr = self.freq + self.freq = corelib.check_freq(freq) + self.freqstr = corelib.freq_tostr(self.freq) if value is not None: - if self.freq == 'A': + if isinstance(value, str): + self.mxDate = mxDFromString(string) + elif self.freqstr == 'A': self.mxDate = mxD.Date(value, -1, -1) - elif self.freq == 'B': + elif self.freqstr == 'B': valtmp = (value - 1)//5 - self.mxDate = mxD.DateTimeFromAbsDateTime(value + valtmp*7 - valtmp*5) - elif self.freq in ['D','U']: + #... (value + valtmp*7 - valtmp*5) + self.mxDate = mxD.DateTimeFromAbsDateTime(value + valtmp*2) + elif self.freqstr in ['D','U']: self.mxDate = mxD.DateTimeFromAbsDateTime(value) - elif self.freq == 'H': + elif self.freqstr == 'H': self.mxDate = hourlyOriginDate + mxD.DateTimeDeltaFrom(hours=value) - elif self.freq == 'M': + elif self.freqstr == 'M': self.mxDate = mxD.DateTimeFromAbsDateTime(1) + \ mxD.RelativeDateTime(months=value-1, day=-1) - elif self.freq == 'Q': + elif self.freqstr == 'Q': self.mxDate = mxD.DateTimeFromAbsDateTime(1) + \ mxD.RelativeDateTime(years=(value // 4), month=((value * 3) % 12), day=-1) - elif self.freq == 'S': + elif self.freqstr == 'S': self.mxDate = secondlyOriginDate + mxD.DateTimeDeltaFromSeconds(value) - elif self.freq == 'T': + elif self.freqstr == 'T': self.mxDate = minutelyOriginDate + mxD.DateTimeDeltaFrom(minutes=value) - elif self.freq == 'W': + elif self.freqstr == 'W': self.mxDate = mxD.Date(1,1,7) + \ mxD.RelativeDateTime(weeks=value-1) @@ -163,31 +175,31 @@ # First, some basic checks..... if year is None: raise InsufficientDateError - if self.freq in ('B', 'D', 'W'): + if self.freqstr in 'BDWU': if month is None or day is None: raise InsufficientDateError - elif self.freq == 'M': + elif self.freqstr == 'M': if month is None: raise InsufficientDateError day = -1 - elif self.freq == 'Q': + elif self.freqstr == 'Q': if quarter is None: raise InsufficientDateError month = quarter * 3 day = -1 - elif self.freq == 'A': + elif self.freqstr == 'A': month = -1 day = -1 - elif self.freq == 'S': + elif self.freqstr == 'S': if month is None or day is None or second is None: raise InsufficientDateError - if self.freq in ['A','B','D','M','Q','W']: + if self.freqstr in ['A','B','D','M','Q','W']: self.mxDate = truncateDate(self.freq, mxD.Date(year, month, day)) - if self.freq == 'B': + if self.freqstr == 'B': if self.mxDate.day_of_week in [5,6]: raise ValueError("Weekend passed as business day") - elif self.freq in ['H','S','T']: + elif self.freqstr in 'HTS': if hour is None: if minute is None: if second is None: @@ -205,7 +217,7 @@ second = 0 else: second = second % 60 - self.mxDate = truncateDate(self.freq, + self.mxDate = truncateDate(self.freqstr, mxD.Date(year, month, day, hour, minute, second)) self.value = self.__value() @@ -252,11 +264,13 @@ return self.__getDateInfo('I') def __getDateInfo(self, info): - return int(cseries.getDateInfo(numpy.asarray(self.value), self.freq, info)) + return int(cseries.getDateInfo(numpy.asarray(self.value), + self.freqstr, info)) def __add__(self, other): if isinstance(other, Date): - raise FrequencyDateError("Cannot add dates", self.freq, other.freq) + raise FrequencyDateError("Cannot add dates", + self.freqstr, other.freqstr) return Date(freq=self.freq, value=int(self) + other) def __radd__(self, other): @@ -266,7 +280,7 @@ if isinstance(other, Date): if self.freq != other.freq: raise FrequencyDateError("Cannot subtract dates", \ - self.freq, other.freq) + self.freqstr, other.freqstr) else: return int(self) - int(other) else: @@ -276,16 +290,16 @@ if not hasattr(other, 'freq'): return False elif self.freq != other.freq: - raise FrequencyDateError("Cannot subtract dates", \ - 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 subtract dates", \ - self.freq, other.freq) + raise FrequencyDateError("Cannot compare dates", \ + self.freqstr, other.freqstr) return int(self)-int(other) def __hash__(self): @@ -300,63 +314,41 @@ def __value(self): "Converts the date to an integer, depending on the current frequency." # Annual ....... - if self.freq == 'A': + if self.freqstr == 'A': val = self.mxDate.year # Business days. - elif self.freq == 'B': + elif self.freqstr == 'B': days = self.mxDate.absdate weeks = days // 7 val = days - weeks*2 # (weeks*5) + (days - weeks*7) # Daily/undefined - elif self.freq in ['D', 'U']: + elif self.freqstr in 'DU': val = self.mxDate.absdate # Hourly........ - elif self.freq == 'H': + elif self.freqstr == 'H': val = (self.mxDate - hourlyOriginDate).hours # Monthly....... - elif self.freq == 'M': + elif self.freqstr == 'M': val = (self.mxDate.year-1)*12 + self.mxDate.month # Quarterly..... - elif self.freq == 'Q': + elif self.freqstr == 'Q': val = (self.mxDate.year-1)*4 + self.mxDate.month//3 # Secondly...... - elif self.freq == 'S': + elif self.freqstr == 'S': val = (self.mxDate - secondlyOriginDate).seconds # Minutely...... - elif self.freq == 'T': + elif self.freqstr == 'T': val = (self.mxDate - minutelyOriginDate).minutes # Weekly........ - elif self.freq == 'W': + elif self.freqstr == 'W': val = self.mxDate.absdate//7 return int(val) - #...................................................... - def default_fmtstr(self): - "Defines the default formats for printing Dates." - if self.freq == "A": - fmt = "%Y" - elif self.freq in ("B","D"): - fmt = "%d-%b-%Y" - elif self.freq == "M": - fmt = "%b-%Y" - elif self.freq == "Q": - fmt = "%YQ%q" - elif self.freq == 'H': - fmt = "%d-%b-%Y %H:00" - elif self.freq == 'T': - fmt = "%d-%b-%Y %H:%M" - elif self.freq == "S": - fmt = "%d-%b-%Y %H:%M:%S" - elif self.freq == "W": - fmt = "%YW%W" - else: - fmt = "%d-%b-%y" - return fmt - + #...................................................... def strfmt(self, fmt): "Formats the date" if fmt is None: - fmt = self.default_fmtstr() + fmt = self.default_fmtstr[self.freqstr] qFmt = fmt.replace("%q", "XXXX") tmpStr = self.mxDate.strftime(qFmt) if "XXXX" in tmpStr: @@ -364,10 +356,10 @@ return tmpStr def __str__(self): - return self.strfmt(self.default_fmtstr()) + return self.strfmt(self.default_fmtstr[self.freqstr]) def __repr__(self): - return "<%s : %s>" % (str(self.freq), str(self)) + return "<%s : %s>" % (str(self.freqstr), str(self)) #...................................................... def toordinal(self): "Returns the date as an ordinal." @@ -400,24 +392,24 @@ #####--------------------------------------------------------------------------- def truncateDate(freq, mxDate): """Chops off the irrelevant information from the mxDate passed in.""" - freq = corelib.fmtFreq(freq) - if freq == 'A': + freqstr = corelib.check_freqstr(freq) + if freqstr == 'A': return mxD.Date(mxDate.year) - elif freq == 'Q': + elif freqstr == 'Q': return mxD.Date(mxDate.year, monthToQuarter(mxDate.month)*3) - elif freq == 'M': + elif freqstr == 'M': return mxD.Date(mxDate.year, mxDate.month) - elif freq == 'W': + elif freqstr == 'W': d = mxDate.absdate return mxD.DateTimeFromAbsDateTime(d + (7 - d % 7) % 7) - elif freq in ('B', 'D'): + elif freqstr in 'BD': if freq == 'B' and mxDate.day_of_week in [5,6]: raise ValueError("Weekend passed as business day") return mxD.Date(mxDate.year, mxDate.month, mxDate.day) - elif freq == 'H': + elif freqstr == 'H': return mxD.Date(mxDate.year, mxDate.month, mxDate.day, \ mxDate.hour) - elif freq == 'T': + elif freqstr == 'T': return mxD.Date(mxDate.year, mxDate.month, mxDate.day, \ mxDate.hour, mxDate.minute) else: @@ -430,18 +422,18 @@ def thisday(freq): "Returns today's date, at the given frequency `freq`." - freq = corelib.fmtFreq(freq) + freqstr = corelib.check_freqstr(freq) tempDate = mxD.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freq == 'B' and tempDate.day_of_week >= 5: + if freqstr == 'B' and tempDate.day_of_week >= 5: tempDate -= (tempDate.day_of_week - 4) - if freq in ('B','D','H','S','T','W'): + if freqstr in ('B','D','H','S','T','W','U'): return Date(freq, mxDate=tempDate) - elif freq == 'M': + elif freqstr == 'M': return Date(freq, year=tempDate.year, month=tempDate.month) - elif freq == 'Q': + elif freqstr == 'Q': return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freq == 'A': + elif freqstr == 'A': return Date(freq, year=tempDate.year) today = thisday @@ -458,7 +450,7 @@ def asfreq(date, toFreq, relation="BEFORE"): """Returns a date converted to another frequency `toFreq`, according to the relation `relation` .""" - tofreq = corelib.fmtFreq(toFreq) + tofreq = corelib.check_freqstr(toFreq) _rel = relation.upper()[0] if _rel not in ['B', 'A']: msg = "Invalid relation '%s': Should be in ['before', 'after']" @@ -467,11 +459,11 @@ if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" - if date.freq == 'U': + if date.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") fromfreq = 'D' else: - fromfreq = date.freq + fromfreq = date.freqstr if fromfreq == tofreq: return date @@ -507,21 +499,20 @@ accesses the array element by element. Therefore, `d` is a Date object. """ def __new__(cls, dates=None, freq='U', copy=False): - #logging.debug('DA:__new__ received %s [%i]" % (type(dates), numpy.size(dates))) if isinstance(dates, DateArray): - #logging.debug('DA:__new__ sends %s as %s" % (type(dates), cls)) cls.__defaultfreq = dates.freq if not copy: return dates.view(cls) return dates.copy().view(cls) else: _dates = numeric.asarray(dates, dtype=int_) + if _dates.ndim == 0: + _dates.shape = (1,) if copy: _dates = _dates.copy() - #logging.debug('DA:__new__ sends %s as %s" % (type(_dates), cls)) if freq is None: freq = 'U' - cls.__defaultfreq = corelib.fmtFreq(freq) + cls.__defaultfreq = corelib.check_freq(freq) (cls.__toobj, cls.__toord, cls.__tostr) = (None, None, None) (cls.__steps, cls.__full, cls.__hasdups) = (None, None, None) return _dates.view(cls) @@ -533,25 +524,22 @@ raise ArithmeticDateError, "(function %s)" % context[0].__name__ def __array_finalize__(self, obj): - #logging.debug('DA:__array_finalize__ received %s" % type(obj)) if hasattr(obj, 'freq'): self.freq = obj.freq self.freqstr = obj.freqstr else: self.freq = self.__defaultfreq - self.freqstr = self.__defaultfreq - #logging.debug('DA:__array_finalize__ sends %s" % type(self)) + self.freqstr = corelib.freq_tostr(self.__defaultfreq) - def __getitem__(self, index): - #logging.debug('DA:__getitem__ got index %s (%s)"%(index, type(index))) - if isinstance(index, Date): - index = self.find_dates(index) - elif numeric.asarray(index).dtype.kind == 'O': + def __getitem__(self, indx): + if isinstance(indx, Date): + index = self.find_dates(indx) + elif numeric.asarray(indx).dtype.kind == 'O': try: - index = self.find_dates(index) + indx = self.find_dates(indx) except AttributeError: pass - r = ndarray.__getitem__(self, index) + r = ndarray.__getitem__(self, indx) if not hasattr(r, "size"): if isinstance(r, int): return Date(self.freq, value=r) @@ -661,7 +649,7 @@ tofreq = corelib.fmtFreq(freq) if tofreq == self.freq: return self - if self.freq == 'U': + if self.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") fromfreq = 'D' else: @@ -709,14 +697,15 @@ self.__full = (steps.max() == 1) if self.__hasdups is None: self.__hasdups = (steps.min() == 0) - elif val.size == 1: + else: +# elif val.size == 1: self.__full = True self.__hasdups = False steps = numeric.array([], dtype=int_) - else: - self.__full = False - self.__hasdups = False - steps = None +# else: +# self.__full = False +# self.__hasdups = False +# steps = None self.__steps = steps return self.__steps @@ -758,7 +747,6 @@ self._asdates = asdates self.__doc__ = getattr(methodname, '__doc__') self.obj = None - #logging.debug('DA:__datearithmetics got method %s' % methodname) # def __get__(self, obj, objtype=None): self.obj = obj @@ -770,7 +758,6 @@ freq = instance.freq if 'context' not in kwargs: kwargs['context'] = 'DateOK' - #logging.debug('DA:__datearithmetics got other %s' % type(other)) method = getattr(super(DateArray,instance), self.methodname) if isinstance(other, DateArray): if other.freq != freq: @@ -782,7 +769,6 @@ raise FrequencyDateError("Cannot operate on dates", \ freq, other.freq) other = other.value - #logging.debug('DA:__datearithmetics got other %s' % type(other)) elif isinstance(other, ndarray): if other.dtype.kind not in ['i','f']: raise ArithmeticDateError @@ -848,6 +834,8 @@ "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 @@ -860,7 +848,7 @@ #...construct a list of dates dates = [Date(freq, string=s) for s in dlist] # Case #2: dates as numbers ................. - elif dlist.dtype.kind in ['i','f']: + elif dlist.dtype.kind in 'if': #...hopefully, they are values if freq is None: freq = guess_freq(dlist) @@ -868,9 +856,17 @@ # Case #3: dates as objects ................. elif dlist.dtype.kind == 'O': template = dlist[0] +# if dlist.size > 1: +# template = dlist[0] +# else: +# template = dlist.item() #...as Date objects if isinstance(template, Date): - dates = numpy.fromiter((d.value for d in dlist), float_) + dates = numpy.fromiter((d.value for d in dlist), int_) +# if dlist.size > 1: +# dates = numpy.fromiter((d.value for d in dlist), int_) +# else: +# dates = [template] #...as mx.DateTime objects elif hasattr(template,'absdays'): # no freq given: try to guess it from absdays @@ -880,7 +876,7 @@ freq = guess_freq(ords) dates = [Date(freq, mxDate=m) for m in dlist] #...as datetime objects - elif hasattr(dlist[0], 'toordinal'): + elif hasattr(template, 'toordinal'): ords = numpy.fromiter((d.toordinal() for d in dlist), float_) if freq is None: freq = guess_freq(ords) @@ -896,8 +892,7 @@ - a starting date and either an ending date or a given length. - a list of dates. """ - #TODO: make sure we can use a string for a date! - freq = corelib.fmtFreq(freq) + freq = corelib.check_freq(freq) # Case #1: we have a list ................... if dlist is not None: # Already a DateArray.................... Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -26,8 +26,9 @@ from maskedarray.testutils import assert_equal, assert_array_equal from timeseries import tdates +reload(tdates) from timeseries import tcore -reload(tdates) +reload(tcore) from timeseries.tdates import date_array_fromlist, Date, DateArray, mxDFromString class test_creation(NumpyTestCase): @@ -41,33 +42,33 @@ dlist = ['2007-01-%02i' % i for i in range(1,15)] # A simple case: daily data dates = date_array_fromlist(dlist, 'D') - assert_equal(dates.freq,'D') + assert_equal(dates.freqstr,'D') assert(dates.isfull()) assert(not dates.has_duplicated_dates()) assert_equal(dates, 732677+numpy.arange(len(dlist))) # as simple, but we need to guess the frequency this time dates = date_array_fromlist(dlist, 'D') - assert_equal(dates.freq,'D') + assert_equal(dates.freqstr,'D') assert(dates.isfull()) assert(not dates.has_duplicated_dates()) assert_equal(dates, 732677+numpy.arange(len(dlist))) # Still daily data, that we force to month dates = date_array_fromlist(dlist, 'M') - assert_equal(dates.freq,'M') + assert_equal(dates.freqstr,'M') assert(not dates.isfull()) assert(dates.has_duplicated_dates()) assert_equal(dates, [24073]*len(dlist)) # Now, for monthly data dlist = ['2007-%02i' % i for i in range(1,13)] dates = date_array_fromlist(dlist, 'M') - assert_equal(dates.freq,'M') + assert_equal(dates.freqstr,'M') assert(dates.isfull()) assert(not dates.has_duplicated_dates()) assert_equal(dates, 24073 + numpy.arange(12)) # Monthly data w/ guessing dlist = ['2007-%02i' % i for i in range(1,13)] dates = date_array_fromlist(dlist, ) - assert_equal(dates.freq,'M') + assert_equal(dates.freqstr,'M') assert(dates.isfull()) assert(not dates.has_duplicated_dates()) assert_equal(dates, 24073 + numpy.arange(12)) @@ -76,18 +77,18 @@ "Tests creation from list of strings w/ missing dates" 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.freq,'U') + assert_equal(dates.freqstr,'U') assert(not dates.isfull()) assert(not dates.has_duplicated_dates()) assert_equal(dates.tovalue(),732676+numpy.array([1,2,4,5,7,8,10,11,13])) # ddates = date_array_fromlist(dlist, 'D') - assert_equal(ddates.freq,'D') + assert_equal(ddates.freqstr,'D') assert(not ddates.isfull()) assert(not ddates.has_duplicated_dates()) # mdates = date_array_fromlist(dlist, 'M') - assert_equal(mdates.freq,'M') + assert_equal(mdates.freqstr,'M') assert(not dates.isfull()) assert(mdates.has_duplicated_dates()) # @@ -105,7 +106,8 @@ def test_consistent_value(self): "Tests that values don't get mutated when constructing dates from a value" - freqs = [x for x in list(tcore.fmtfreq_dict) if x != 'U'] + freqs = [x[0] for x in tcore.freq_dict.values() if x[0] != 'U'] + print freqs for f in freqs: today = tdates.thisday(f) assert(tdates.Date(freq=f, value=today.value) == today) Modified: trunk/Lib/sandbox/timeseries/tests/test_misc.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -2,11 +2,11 @@ """Tests suite for miscellaneous functions in timeseries module. Adapted from the original test_ma by Pierre Gerard-Marchant -:author: Matt Knox -:contact: mattknox_ca_at_hotmail_dot_com -:version: $Id: test_misc.py 2578 2007-01-17 19:25:10Z mattknox_ca $ +:author: Pierre Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com +:version: $Id: test_timeseries.py 2578 2007-01-17 19:25:10Z mattknox_ca $ """ -__author__ = "Matt Knox ($Author: mattknox_ca $)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: mattknox_ca $)" __version__ = '1.0' __revision__ = "$Revision: 2578 $" __date__ = '$Date: 2007-01-17 14:25:10 -0500 (Wed, 17 Jan 2007) $' Modified: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -1,11 +1,11 @@ # pylint: disable-msg=W0611, W0612, W0511,R0201 """Tests suite for mrecarray. -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu +: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 ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" __version__ = '1.0' __revision__ = "$Revision$" __date__ = '$Date$' Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -2,11 +2,11 @@ """Tests suite for MaskedArray. Adapted from the original test_ma by Pierre Gerard-Marchant -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu +: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 ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" __version__ = '1.0' __revision__ = "$Revision$" __date__ = '$Date$' @@ -28,7 +28,8 @@ from timeseries import tseries #reload(tseries) from timeseries.tseries import Date, date_array_fromlist -from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, mask_period, align_series +from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, \ + mask_period, align_series class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -47,7 +48,7 @@ assert_equal(series._mask, [1,0,0,0,0]*3) assert_equal(series._series, data) assert_equal(series._dates, date_array_fromlist(dlist)) - assert_equal(series.freq, 'D') + assert_equal(series.freqstr, 'D') def test_fromrange (self): "Base data definition." @@ -57,7 +58,7 @@ assert_equal(series._mask, [1,0,0,0,0]*3) assert_equal(series._series, data) assert_equal(series._dates, dates) - assert_equal(series.freq, 'D') + assert_equal(series.freqstr, 'D') def test_fromseries (self): "Base data definition." @@ -69,7 +70,7 @@ assert_equal(series._mask, [1,0,0,0,0]*3) assert_equal(series._series, data) assert_equal(series._dates, dates) - assert_equal(series.freq, 'D') + assert_equal(series.freqstr, 'D') def test_fromdatearray(self): @@ -81,7 +82,7 @@ assert(isinstance(series, TimeSeries)) assert_equal(series._dates, dates) assert_equal(series._data, data) - assert_equal(series.freq, 'D') + assert_equal(series.freqstr, 'D') series[5] = MA.masked @@ -270,12 +271,12 @@ end_date=Date('D', string='2007-01-31')) assert_equal(dseries.size, 26) assert_equal(dseries._mask, N.r_[series._mask[5:], [1]*16]) - + # empty_series = time_series([], freq='d') 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] @@ -291,7 +292,6 @@ assert_array_equal(shift_negative, shift_negative_result) assert_array_equal(shift_positive, shift_positive_result) - # def test_maskperiod(self): "Test mask_period" Modified: trunk/Lib/sandbox/timeseries/tmulti.py =================================================================== --- trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -51,8 +51,6 @@ reserved_fields = MR.reserved_fields + ['_dates'] import warnings -import logging -logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) __all__ = [ @@ -103,7 +101,6 @@ mroptions = dict(fill_value=fill_value, hard_mask=hard_mask, formats=formats, names=names, titles=titles, byteorder=byteorder, aligned=aligned) - logging.debug("__new__ received %s" % type(data)) # if isinstance(data, MultiTimeSeries): cls._defaultfieldmask = data._series._fieldmask @@ -142,7 +139,6 @@ """ # mclass = self.__class__ #.......... - logging.debug("__wrap__ received %s" % type(obj)) if context is None: # return mclass(obj, mask=self._mask, copy=False) return MaskedArray(obj, mask=self._mask, copy=False, @@ -157,7 +153,6 @@ def __array_finalize__(self,obj): - logging.debug("__array_finalize__ received %s" % type(obj)) if isinstance(obj, MultiTimeSeries): self.__dict__.update(_dates=obj._dates, _series=obj._series, @@ -167,8 +162,6 @@ _fill_value=obj._fill_value ) else: - logging.debug("__array_finalize__ dtype %s" % obj.dtype) - logging.debug("__array_finalize__ mask %s" % self._defaultfieldmask) self.__dict__.update(_data = obj.view(recarray), _dates = self._defaultdates, _series = MaskedRecords(obj, dtype=obj.dtype), @@ -178,11 +171,9 @@ ) MultiTimeSeries._defaultfieldmask = nomask MultiTimeSeries._defaulthardmask = False -# logging.debug("__array_finalize__ exit ") return #...................................................... def __getattribute__(self, attr): -# logging.debug('__getattribute__ %s' % attr) try: # Returns a generic attribute return object.__getattribute__(self,attr) @@ -190,7 +181,6 @@ # OK, so attr must be a field name pass # Get the list of fields ...... -# logging.debug('__getattribute__ %s listfield' % attr) _names = self.dtype.names _local = self.__dict__ _mask = _local['_fieldmask'] @@ -200,21 +190,18 @@ obj._mask = make_mask(_mask.__getattribute__(attr)) return obj elif attr == '_mask': -# logging.debug('__getattribute__ return mask') if self.size > 1: return _mask.view((bool_, len(self.dtype))).all(1) return _mask.view((bool_, len(self.dtype))) raise AttributeError,"No attribute '%s' !" % attr def __setattr__(self, attr, val): -# logging.debug('__setattribute__ %s' % attr) newattr = attr not in self.__dict__ try: # Is attr a generic attribute ? ret = object.__setattr__(self, attr, val) except: # Not a generic attribute: exit if it's not a valid field -# logging.debug('__setattribute__ %s' % attr) fielddict = self.dtype.names or {} if attr not in fielddict: exctype, value = sys.exc_info()[:2] @@ -242,16 +229,12 @@ elif attr == '_mask': if self._hardmask: val = make_mask(val) - logging.debug("setattr: object has hardmask %s" % val) - logging.debug("setattr: val is nomask: %s" % (val is nomask)) if val is not nomask: # mval = getmaskarray(val) for k in _names: m = mask_or(val, base_fmask.__getattr__(k)) - logging.debug("setattr: %k to: %s" % (k,m)) base_fmask.__setattr__(k, m) else: - logging.debug("setattr: VAL IS NOMASK: %s" % (val is nomask)) return else: mval = getmaskarray(val) @@ -262,14 +245,11 @@ def __getitem__(self, indx): """Returns all the fields sharing the same fieldname base. The fieldname base is either `_data` or `_mask`.""" - logging.debug('__getitem__(%s)' % indx) _localdict = self.__dict__ # We want a field ........ if indx in self.dtype.names: - logging.debug('__getitem__ getfield %s' % indx) obj = _localdict['_series'][indx].view(TimeSeries) obj._mask = make_mask(_localdict['_fieldmask'][indx]) - logging.debug('__getitem__ field %s mask %s:' % (indx, obj._mask)) return obj # We want some elements .. indx = super(MultiTimeSeries, self)._TimeSeries__checkindex(indx) @@ -280,7 +260,6 @@ def __getslice__(self, i, j): """Returns the slice described by [i,j].""" - logging.debug("__Getslice__ [%i,%i]" % (i,j)) _localdict = self.__dict__ return MultiTimeSeries(_localdict['_data'][i:j], mask=_localdict['_fieldmask'][i:j], @@ -358,7 +337,6 @@ """Returns a view of the mrecarray.""" try: if issubclass(obj, ndarray): -# logging.debug('direct view as %s' % obj) return ndarray.view(self, obj) except TypeError: pass @@ -426,7 +404,6 @@ # Define formats from scratch ............... if formats is None and dtype is None: formats = _getformats(arraylist) -# logging.debug("fromarrays: formats",formats) # Define the dtype .......................... if dtype is not None: descr = numeric.dtype(dtype) @@ -545,7 +522,6 @@ line = f.readline() firstline = line[:line.find(commentchar)].strip() _varnames = firstline.split(delimitor) -# logging.debug("_VARNAMES:%s-%s"% (_varnames,len(_varnames))) if len(_varnames) > 1: break if varnames is None: @@ -586,7 +562,6 @@ vartypes = _guessvartypes(_variables[0]) # Construct the descriptor .................. mdescr = [(n,f) for (n,f) in zip(varnames, vartypes)] -# logging.debug("fromtextfile: descr: %s" % mdescr) # Get the data and the mask ................. # We just need a list of masked_arrays. It's easier to create it like that: _mask = (_variables.T == missingchar) Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-29 23:03:18 UTC (rev 2632) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 04:08:29 UTC (rev 2633) @@ -42,11 +42,11 @@ masked_array import tcore as corelib -#reload(corelib) +reload(corelib) from tcore import * import tdates -#reload(tdates) +reload(tdates) from tdates import DateError, InsufficientDateError from tdates import Date, isDate, DateArray, isDateArray, \ date_array, date_array_fromlist, date_array_fromrange, thisday @@ -64,12 +64,7 @@ ] #............................................................................... -import logging -logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) -talog = logging.getLogger('log.TimeArray') -tslog = logging.getLogger('TimeSeries') -btslog = logging.getLogger('BaseTimeSeries') ufunc_domain = {} ufunc_fills = {} @@ -183,7 +178,7 @@ cls._defaultdates = newdates # Check frequency...... if freq is not None: - freq = corelib.fmtFreq(freq) + freq = corelib.check_freq(freq)[0] if freq != newdates.freq: _dates = newdates.tofreq(freq) else: @@ -265,32 +260,32 @@ super(self._series.__class__, self._series).__setattribute__(attr, value) setattr(self._series, attr, value) #............................................ - def __checkindex(self, index): + def __checkindex(self, indx): "Checks the validity of an index." - if isinstance(index, int): - return index - if isinstance(index, str): - return self._dates.date_to_index(Date(self._dates.freq, string=index)) - elif isDate(index) or isDateArray(index): - return self._dates.date_to_index(index) - elif isinstance(index,slice): - slice_start = self.__checkindex(index.start) - slice_stop = self.__checkindex(index.stop) - return slice(slice_start, slice_stop, index.step) - elif isTimeSeries(index): - index = index._series - if getmask(index) is not nomask: + if isinstance(indx, int): + return indx + if isinstance(indx, str): + return self._dates.date_to_index(Date(self._dates.freq, string=indx)) + elif isDate(indx) or isDateArray(indx): + return self._dates.date_to_index(indx) + elif isinstance(indx,slice): + slice_start = self.__checkindex(indx.start) + slice_stop = self.__checkindex(indx.stop) + return slice(slice_start, slice_stop, indx.step) + elif isTimeSeries(indx): + indx = indx._series + if getmask(indx) is not nomask: msg = "Masked arrays must be filled before they can be used as indices!" raise IndexError, msg - return index + return indx - def __getitem__(self, index): + def __getitem__(self, indx): """x.__getitem__(y) <==> x[y] Returns the item described by i. Not a copy as in previous versions. """ - index = self.__checkindex(index) - data = self._series[index] - date = self._dates[index] + indx = self.__checkindex(indx) + data = self._series[indx] + date = self._dates[indx] m = self._mask scalardata = (len(numeric.shape(data))==0) # @@ -301,7 +296,7 @@ return TimeSeries(data, dates=date, mask=nomask, keep_mask=True, copy=False) #.... - mi = m[index] + mi = m[indx] if mi.size == 1: if mi: return TimeSeries(data, dates=date, mask=True) @@ -309,19 +304,19 @@ else: return TimeSeries(data, dates=date, mask=mi) #........................ - def __setitem__(self, index, value): + def __setitem__(self, indx, value): """x.__setitem__(i, y) <==> x[i]=y Sets item described by index. If value is masked, masks those locations. """ if self is masked: raise MAError, 'Cannot alter the masked element.' - index = self.__checkindex(index) + indx = self.__checkindex(indx) #.... if isinstance(value, TimeSeries): - assert(_timeseriescompat(self[index], value)) - self._series[index] = value._series + assert(_timeseriescompat(self[indx], value)) + self._series[indx] = value._series else: - self._series[index] = value + self._series[indx] = value # Don't forget to update the mask ! self._mask = self._series._mask @@ -338,7 +333,7 @@ i = self.__checkindex(i) j = self.__checkindex(j) #.... - data = self._series[i:j] +# data = self._series[i:j] if isinstance(value, TimeSeries): assert(_timeseriescompat(self[i:j], value)) self._series[i:j] = value._series @@ -379,10 +374,10 @@ if self.ndim <= 1: return desc_short % {'data': str(self._series), 'time': timestr, - 'freq': self.freq, } + 'freq': self.freqstr, } return desc % {'data': str(self._series), 'time': timestr, - 'freq': self.freq, } + 'freq': self.freqstr, } #............................................ def _get_mask(self): """Returns the current mask.""" @@ -419,8 +414,12 @@ return self._dates @property def freq(self): - """Returns the corresponding frequency.""" + """Returns the corresponding frequency (as an integer).""" return self._dates.freq + @property + def freqstr(self): + """Returns the corresponding frequency (as a string).""" + return self._dates.freqstr @property def day(self): @@ -474,7 +473,6 @@ hours = hour weeks = week - @property def start_date(self): """Returns the first date of the series.""" @@ -482,7 +480,6 @@ return self._dates[0] else: return None - @property def end_date(self): """Returns the last date of the series.""" @@ -490,7 +487,6 @@ return self._dates[-1] else: return None - def isvalid(self): """Returns whether the series has no duplicate/missing dates.""" @@ -517,8 +513,16 @@ 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) + #..................................................... + 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() - ##### -------------------------------------------------------------------------- ##--- ... Additional methods ... ##### -------------------------------------------------------------------------- @@ -681,7 +685,10 @@ TimeSeries.varu = _tsaxismethod('varu') TimeSeries.std = _tsaxismethod('std') TimeSeries.stdu = _tsaxismethod('stdu') +TimeSeries.all = _tsaxismethod('all') +TimeSeries.any = _tsaxismethod('any') + class _tsblockedmethods(object): """Defines a wrapper for array methods that should be temporarily disabled. """ @@ -930,16 +937,16 @@ start_date = data._dates[0] elif isinstance(start_date, str): start_date = Date(data.freq, string=start_date) - elif not isDateType(start_date): - raise DateError,"Starting date should be a valid 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] elif isinstance(end_date, str): end_date = Date(data.freq, string=end_date) - elif not isDateType(end_date): - raise DateError,"Starting date should be a valid 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 ......... if inside: @@ -984,64 +991,65 @@ if a.freq == 'U': raise TimeSeriesError, \ "Cannot adjust a series with 'Undefined' frequency." - if not a.dates.isvalid() and a.ndim > 0 and a.size > 1: + if not a.dates.isvalid(): raise TimeSeriesError, \ "Cannot adjust a series with missing or duplicated dates." # Flatten the series if needed .............. a = a.flatten() shp_flat = a.shape # Dates validity checks .,................... - msg = "%s should be a valid Date instance! (got %s instead)" - - (dstart, dend) = a.start_date, a.end_date - if dstart is not None: - - if start_date is None: - start_date = dstart - start_lag = 0 - else: - if not isDateType(start_date): - raise TypeError, msg % ('start_date', type(start_date)) + msg = "%s should be a valid Date object! (got %s instead)" + if a.dates.size >= 1: + (dstart, dend) = a.dates[[0,-1]] + else: + (dstart, dend) = (None, None) + # 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!" + #.... + if start_date is None: + start_date = dstart + start_lag = 0 + else: + if not isinstance(start_date, Date): + raise TypeError, msg % ('start_date', type(start_date)) + if dstart is not None: start_lag = start_date - dstart - #.... - if end_date is None: - end_date = dend - end_lag = 0 else: - if not isDateType(end_date): - raise TypeError, msg % ('end_date', type(end_date)) + start_lag = start_date + #.... + 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 - # Check if the new range is included in the old one - if start_lag >= 0: - if end_lag == 0: - return a[start_lag:] - elif end_lag < 0: - return a[start_lag:end_lag] - - else: - if start_date is None or end_date is None: - raise TimeSeriesError, \ - """start_date and end_date must be specified to adjust -endpoints of a zero length series""" - + else: + end_lag = end_date + # Check if the new range is included in the old one + if start_lag >= 0: + if end_lag == 0: + return a[start_lag:] + elif end_lag < 0: + 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) - + newdata = masked_array(numeric.empty(newshape, dtype=a.dtype), mask=True) - - # need to ensure that we preserve attributes of the series in the result + #backup the series attributes options = dict(fill_value=a.fill_value, observed=a.observed) - newseries = TimeSeries(newdata, newdates, **options) - if dstart is not None: start_date = max(start_date, dstart) end_date = min(end_date, dend) + 1 newseries[start_date:end_date] = a[start_date:end_date] - return newseries #.................................................................... def align_series(*series, **kwargs): @@ -1056,7 +1064,7 @@ """ if len(series) < 2: return series - unique_freqs = numpy.unique([x.freq for x in series]) + unique_freqs = numpy.unique([x.freqstr for x in series]) try: common_freq = unique_freqs.item() except ValueError: @@ -1065,15 +1073,19 @@ if common_freq == 'U': raise TimeSeriesError, \ "Cannot adjust a series with 'Undefined' frequency." - valid_states = [x.isvalid() or (x.size == 0 and x.ndim > 0) for x in 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 if x.start_date is not None])) + 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', max([x.end_date for x in series if x.end_date is not None])) + 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) @@ -1137,7 +1149,9 @@ observed=series.observed, start_date=start_date) return newseries -#.................................................................... +TimeSeries.convert = convert + +#............................................................................... def tshift(series, nper): """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 @@ -1155,28 +1169,26 @@ dates = [2005 ... 2008], freq = A) """ - newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) - - # need to ensure that we preserve attributes of the series in the result + #Backup series attributes options = dict(fill_value=series.fill_value, observed=series.observed) - newseries = TimeSeries(newdata, series._dates, **options) - + newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), + mask=True) + inidata = series._series.copy() if nper < 0: - nper = max(-series.shape[0],nper) - newseries[-nper:] = series._series[:nper].copy() - newseries[:-nper] = masked + nper = max(-len(series), nper) + newdata[-nper:] = inidata[:nper] elif nper > 0: - nper = min(series.shape[0],nper) - newseries[-nper:] = masked - newseries[:-nper] = series._series[nper:].copy() + nper = min(len(series), nper) + newdata[:-nper] = inidata[nper:] else: - newseries[:] = self._series[:].copy() - + newdata = inidata + newseries = TimeSeries(newdata, series._dates, **options) return newseries +TimeSeries.tshift = tshift #.................................................................... -TimeSeries.convert = convert -TimeSeries.tshift = tshift + + #.................................................................... def fill_missing_dates(data, dates=None, freq=None,fill_value=None): """Finds and fills the missing dates in a time series. @@ -1193,10 +1205,10 @@ `fill_value` : float *[None]* Default value for missing data. If None, the data are just masked. """ - freq = corelib.fmtFreq(freq) - if freq == 'U': + (freq, freqstr) = corelib.check_freq(freq) + if freqstr == 'U': raise ValueError,\ - "Unable to define a proper date resolution (found %s)." % freq + "Unable to define a proper date resolution (found %s)." % freqstr if dates is None: if not isTimeSeries(data): raise InsufficientDateError @@ -1272,7 +1284,6 @@ ################################################################################ if __name__ == '__main__': - logging.basicConfig(level=logging.DEBUG) from maskedarray.testutils import assert_equal # if 0: # dlist = ['2007-01-%02i' % i for i in range(1,16)] @@ -1331,7 +1342,14 @@ dates = date_array_fromlist(dlist) data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3, dtype=float_) self_d = (time_series(range(15), dlist), data, dates) - (series, data, dates) = self_d + (ser, data, dates) = self_d + + if 1: + hodie = tdates.today('M') + ser_0 = time_series([], [], freq='M') + ser_2 = time_series([1,2], start_date=hodie) + ser_1 = time_series([1], hodie, freq='M') + # # Testing a basic condition on data # cond = (series<8).filled(False) # dseries = series[cond] From scipy-svn at scipy.org Tue Jan 30 07:16:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 06:16:36 -0600 (CST) Subject: [Scipy-svn] r2634 - trunk/Lib/interpolate Message-ID: <20070130121636.D285539C106@new.scipy.org> Author: jtravs Date: 2007-01-30 06:16:32 -0600 (Tue, 30 Jan 2007) New Revision: 2634 Modified: trunk/Lib/interpolate/__fitpack.h trunk/Lib/interpolate/_fitpackmodule.c trunk/Lib/interpolate/fitpack.py Log: Added patch for 'insert' funtion from dierckx fitpack for Zachary Pincus. Modified: trunk/Lib/interpolate/__fitpack.h =================================================================== --- trunk/Lib/interpolate/__fitpack.h 2007-01-30 04:08:29 UTC (rev 2633) +++ trunk/Lib/interpolate/__fitpack.h 2007-01-30 12:16:32 UTC (rev 2634) @@ -16,6 +16,7 @@ {"_parcur", fitpack_parcur, METH_VARARGS, doc_parcur}, {"_surfit", fitpack_surfit, METH_VARARGS, doc_surfit}, {"_bispev", fitpack_bispev, METH_VARARGS, doc_bispev}, + {"_insert", fitpack_insert, METH_VARARGS, doc_insert}, */ /* link libraries: (one item per line) ddierckx @@ -36,6 +37,7 @@ #define SURFIT surfit #define BISPEV bispev #define PARDER parder +#define INSERT insert #else #define CURFIT curfit_ #define PERCUR percur_ @@ -49,6 +51,7 @@ #define SURFIT surfit_ #define BISPEV bispev_ #define PARDER parder_ +#define INSERT insert_ #endif void CURFIT(int*,int*,double*,double*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*); void PERCUR(int*,int*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*); @@ -62,6 +65,7 @@ void SURFIT(int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,double*,int*,int*,int*,double*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,int*,int*); void BISPEV(double*,int*,double*,int*,double*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*); void PARDER(double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*); +void INSERT(int*,double*,int*,double*,int*,double*,double*,int*,double*,int*,int*); /* Note that curev, cualde need no interface. */ @@ -545,6 +549,43 @@ return NULL; } +static char doc_insert[] = " [tt,cc,ier] = _insert(iopt,t,c,k,x,m)"; +static PyObject *fitpack_insert(PyObject *dummy, PyObject*args) { + int iopt, n, nn, k, nest, ier, m; + double x; + double *t, *c, *tt, *cc; + PyArrayObject *ap_t = NULL, *ap_c = NULL, *ap_tt = NULL, *ap_cc = NULL; + PyObject *t_py = NULL, *c_py = NULL; + if (!PyArg_ParseTuple(args, "iOOidi",&iopt,&t_py,&c_py,&k, &x, &m)) return NULL; + ap_t = (PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1); + ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1); + if (ap_t == NULL || ap_c == NULL) goto fail; + t = (double *) ap_t->data; + c = (double *) ap_c->data; + n = ap_t->dimensions[0]; + nest = n + m; + ap_tt = (PyArrayObject *)PyArray_FromDims(1,&nest,PyArray_DOUBLE); + ap_cc = (PyArrayObject *)PyArray_FromDims(1,&nest,PyArray_DOUBLE); + if (ap_tt == NULL || ap_cc == NULL) goto fail; + tt = (double *) ap_tt->data; + cc = (double *) ap_cc->data; + for ( ; n < nest; n++) { + INSERT(&iopt, t, &n, c, &k, &x, tt, &nn, cc, &nest, &ier); + if (ier) break; + t = tt; + c = cc; + } + Py_DECREF(ap_c); + Py_DECREF(ap_t); + PyObject* ret = Py_BuildValue("NNi",PyArray_Return(ap_tt),PyArray_Return(ap_cc),ier); + return ret; + + fail: + Py_XDECREF(ap_c); + Py_XDECREF(ap_t); + return NULL; + } + Modified: trunk/Lib/interpolate/_fitpackmodule.c =================================================================== --- trunk/Lib/interpolate/_fitpackmodule.c 2007-01-30 04:08:29 UTC (rev 2633) +++ trunk/Lib/interpolate/_fitpackmodule.c 2007-01-30 12:16:32 UTC (rev 2634) @@ -14,6 +14,7 @@ {"_parcur", fitpack_parcur, METH_VARARGS, doc_parcur}, {"_surfit", fitpack_surfit, METH_VARARGS, doc_surfit}, {"_bispev", fitpack_bispev, METH_VARARGS, doc_bispev}, +{"_insert", fitpack_insert, METH_VARARGS, doc_insert}, {NULL, NULL, 0, NULL} }; PyMODINIT_FUNC init_fitpack(void) { Modified: trunk/Lib/interpolate/fitpack.py =================================================================== --- trunk/Lib/interpolate/fitpack.py 2007-01-30 04:08:29 UTC (rev 2633) +++ trunk/Lib/interpolate/fitpack.py 2007-01-30 12:16:32 UTC (rev 2634) @@ -29,7 +29,7 @@ """ __all__ = ['splrep', 'splprep', 'splev', 'splint', 'sproot', 'spalde', - 'bisplrep', 'bisplev'] + 'bisplrep', 'bisplev', 'insert'] __version__ = "$Revision$"[10:-1] import _fitpack from numpy import atleast_1d, array, ones, zeros, sqrt, ravel, transpose, \ @@ -751,7 +751,50 @@ if len(z[0])>1: return z[0] return z[0][0] +def insert(x,tck,m=1,per=0): + """Insert knots into a B-spline. + Description: + + Given the knots and coefficients of a B-spline representation, create a + new B-spline with a knot inserted m times at point x. + This is a wrapper around the FORTRAN routine insert of FITPACK. + + Inputs: + + x (u) -- A 1-D point at which to insert a new knot(s). If tck was returned + from splprep, then the parameter values, u should be given. + tck -- A sequence of length 3 returned by splrep or splprep containg the + knots, coefficients, and degree of the spline. + m -- The number of times to insert the given knot (its multiplicity). + per -- If non-zero, input spline is considered periodic. + + Outputs: tck + + tck -- (t,c,k) a tuple containing the vector of knots, the B-spline + coefficients, and the degree of the new spline. + + Requirements: + t(k+1) <= x <= t(n-k), where k is the degree of the spline. + In case of a periodic spline (per != 0) there must be + either at least k interior knots t(j) satisfying t(k+1) Author: mattknox_ca Date: 2007-01-30 08:23:19 -0600 (Tue, 30 Jan 2007) New Revision: 2635 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: updated test_empty_datearray Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 12:16:32 UTC (rev 2634) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 14:23:19 UTC (rev 2635) @@ -697,8 +697,8 @@ def test_empty_datearray(self): empty_darray = DateArray([], freq='b') - assert_equal(empty_darray.isfull(), False) - assert_equal(empty_darray.isvalid(), False) + assert_equal(empty_darray.isfull(), True) + assert_equal(empty_darray.isvalid(), True) assert_equal(empty_darray.get_steps(), None) From scipy-svn at scipy.org Tue Jan 30 09:26:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 08:26:50 -0600 (CST) Subject: [Scipy-svn] r2636 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070130142650.D342E39C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 08:26:48 -0600 (Tue, 30 Jan 2007) New Revision: 2636 Modified: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py Log: fixed problems with this Modified: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-30 14:23:19 UTC (rev 2635) +++ trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-30 14:26:48 UTC (rev 2636) @@ -24,15 +24,15 @@ import maskedarray.core as MA import maskedarray.mrecords as MR -from maskedarray.core import getmaskarray, nomask +from maskedarray.core import getmaskarray, nomask, masked_array ##reload(MA) #import maskedarray.mrecords ##reload(maskedarray.mrecords) #from maskedarray.mrecords import mrecarray, fromarrays, fromtextfile, fromrecords -import multitimeseries -reload(multitimeseries) -from multitimeseries import MultiTimeSeries, TimeSeries,\ +from timeseries import tmulti +reload(tmulti) +from timeseries.tmulti import MultiTimeSeries, TimeSeries,\ fromarrays, fromtextfile, fromrecords, \ date_array, time_series From scipy-svn at scipy.org Tue Jan 30 09:28:37 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 08:28:37 -0600 (CST) Subject: [Scipy-svn] r2637 - trunk/Lib/sandbox/timeseries Message-ID: <20070130142837.C218E39C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 08:28:32 -0600 (Tue, 30 Jan 2007) New Revision: 2637 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: commented out line with syntax error Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 14:26:48 UTC (rev 2636) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 14:28:32 UTC (rev 2637) @@ -64,7 +64,7 @@ ] #............................................................................... - format='%(name)-15s %(levelname)s %(message)s',) +# format='%(name)-15s %(levelname)s %(message)s',) ufunc_domain = {} ufunc_fills = {} From scipy-svn at scipy.org Tue Jan 30 09:29:12 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 08:29:12 -0600 (CST) Subject: [Scipy-svn] r2638 - trunk/Lib/sandbox/timeseries Message-ID: <20070130142912.A4C5E39C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 08:29:09 -0600 (Tue, 30 Jan 2007) New Revision: 2638 Modified: trunk/Lib/sandbox/timeseries/tmulti.py Log: fixed syntax errors Modified: trunk/Lib/sandbox/timeseries/tmulti.py =================================================================== --- trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-30 14:28:32 UTC (rev 2637) +++ trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-30 14:29:09 UTC (rev 2638) @@ -51,7 +51,7 @@ reserved_fields = MR.reserved_fields + ['_dates'] import warnings - format='%(name)-15s %(levelname)s %(message)s',) +# format='%(name)-15s %(levelname)s %(message)s',) __all__ = [ 'MultiTimeSeries','fromarrays','fromrecords','fromtextfile', @@ -235,7 +235,7 @@ m = mask_or(val, base_fmask.__getattr__(k)) base_fmask.__setattr__(k, m) else: - return + return else: mval = getmaskarray(val) for k in _names: From scipy-svn at scipy.org Tue Jan 30 10:48:06 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 09:48:06 -0600 (CST) Subject: [Scipy-svn] r2639 - trunk/Lib/sandbox/timeseries Message-ID: <20070130154806.B320539C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 09:48:00 -0600 (Tue, 30 Jan 2007) New Revision: 2639 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: added copy flag to tshift function (True by default) Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 14:29:09 UTC (rev 2638) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 15:48:00 UTC (rev 2639) @@ -1152,12 +1152,22 @@ TimeSeries.convert = convert #............................................................................... -def tshift(series, nper): +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) - 1) +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. +: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. + :Example: >>> series = tseries.time_series([0,1,2,3], start_date=tdates.Date(freq='A', year=2005)) >>> series @@ -1173,7 +1183,11 @@ options = dict(fill_value=series.fill_value, observed=series.observed) newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) - inidata = series._series.copy() + if copy: + inidata = series._series.copy() + else: + inidata = series._series + if nper < 0: nper = max(-len(series), nper) newdata[-nper:] = inidata[:nper] From scipy-svn at scipy.org Tue Jan 30 13:38:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 12:38:53 -0600 (CST) Subject: [Scipy-svn] r2640 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070130183853.4359E39C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 12:38:49 -0600 (Tue, 30 Jan 2007) New Revision: 2640 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: updated code to work with integer frequencies instead of strings Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-30 15:48:00 UTC (rev 2639) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-01-30 18:38:49 UTC (rev 2640) @@ -12,6 +12,29 @@ to frequencies higher than daily (ie. Hourly, Minutely, Secondly) */ +#define FANN 1000 /* Annual */ +#define FQTR 2000 /* Quarterly */ +#define FMTH 3000 /* Monthly */ +#define FWK 4000 /* Weekly */ +#define FBUS 5000 /* Business days */ +#define FDL 6000 /* Daily */ +#define FHR 7000 /* Hourly */ +#define FMIN 8000 /* Minutely */ +#define FSEC 9000 /* Secondly */ +#define FUND -9999 /* Undefined */ +/* +static long FANN = 1000; +static long FQTR = 2000; +static long FMTH = 3000; +static long FWK = 4000; +static long FBUS = 5000; +static long FDL = 6000; +static long FHR = 7000; +static long FMIN = 8000; +static long FSEC = 9000; +static long FUND = -9999; +*/ + static long minval_D_toHighFreq = 719163; /////////////////////////////////////////////////////////////////////// @@ -399,142 +422,142 @@ // end of frequency specific conversion routines // return a pointer to appropriate conversion function -static long (*get_asfreq_func(char fromFreq, char toFreq, int forConvert))(long, char) { +static long (*get_asfreq_func(int fromFreq, int toFreq, int forConvert))(long, char) { switch(fromFreq) { - case 'A': + case FANN: switch(toFreq) { - case 'Q': return &asfreq_AtoQ; - case 'M': return &asfreq_AtoM; - case 'W': return &asfreq_AtoW; - case 'B': return &asfreq_AtoB; - case 'D': return &asfreq_AtoD; - case 'H': return &asfreq_AtoH; - case 'T': return &asfreq_AtoT; - case 'S': return &asfreq_AtoS; + case FQTR: return &asfreq_AtoQ; + case FMTH: return &asfreq_AtoM; + case FWK: return &asfreq_AtoW; + case FBUS: return &asfreq_AtoB; + case FDL: return &asfreq_AtoD; + case FHR: return &asfreq_AtoH; + case FMIN: return &asfreq_AtoT; + case FSEC: return &asfreq_AtoS; default: return &nofunc; } - case 'Q': + case FQTR: switch(toFreq) { - case 'A': return &asfreq_QtoA; - case 'M': return &asfreq_QtoM; - case 'W': return &asfreq_QtoW; - case 'B': return &asfreq_QtoB; - case 'D': return &asfreq_QtoD; - case 'H': return &asfreq_QtoH; - case 'T': return &asfreq_QtoT; - case 'S': return &asfreq_QtoS; + case FANN: return &asfreq_QtoA; + case FMTH: return &asfreq_QtoM; + case FWK: return &asfreq_QtoW; + case FBUS: return &asfreq_QtoB; + case FDL: return &asfreq_QtoD; + case FHR: return &asfreq_QtoH; + case FMIN: return &asfreq_QtoT; + case FSEC: return &asfreq_QtoS; default: return &nofunc; } - case 'M': + case FMTH: switch(toFreq) { - case 'A': return &asfreq_MtoA; - case 'Q': return &asfreq_MtoQ; - case 'W': return &asfreq_MtoW; - case 'B': return &asfreq_MtoB; - case 'D': return &asfreq_MtoD; - case 'H': return &asfreq_MtoH; - case 'T': return &asfreq_MtoT; - case 'S': return &asfreq_MtoS; + case FANN: return &asfreq_MtoA; + case FQTR: return &asfreq_MtoQ; + case FWK: return &asfreq_MtoW; + case FBUS: return &asfreq_MtoB; + case FDL: return &asfreq_MtoD; + case FHR: return &asfreq_MtoH; + case FMIN: return &asfreq_MtoT; + case FSEC: return &asfreq_MtoS; default: return &nofunc; } - case 'W': + case FWK: switch(toFreq) { - case 'A': return &asfreq_WtoA; - case 'Q': return &asfreq_WtoQ; - case 'M': return &asfreq_WtoM; - case 'B': return &asfreq_WtoB; - case 'D': return &asfreq_WtoD; - case 'H': return &asfreq_WtoH; - case 'T': return &asfreq_WtoT; - case 'S': return &asfreq_WtoS; + case FANN: return &asfreq_WtoA; + case FQTR: return &asfreq_WtoQ; + case FMTH: return &asfreq_WtoM; + case FBUS: return &asfreq_WtoB; + case FDL: return &asfreq_WtoD; + case FHR: return &asfreq_WtoH; + case FMIN: return &asfreq_WtoT; + case FSEC: return &asfreq_WtoS; default: return &nofunc; } - case 'B': + case FBUS: switch(toFreq) { - case 'A': return &asfreq_BtoA; - case 'Q': return &asfreq_BtoQ; - case 'M': return &asfreq_BtoM; - case 'W': return &asfreq_BtoW; - case 'D': return &asfreq_BtoD; - case 'H': return &asfreq_BtoH; - case 'T': return &asfreq_BtoT; - case 'S': return &asfreq_BtoS; + case FANN: return &asfreq_BtoA; + case FQTR: return &asfreq_BtoQ; + case FMTH: return &asfreq_BtoM; + case FWK: return &asfreq_BtoW; + case FDL: return &asfreq_BtoD; + case FHR: return &asfreq_BtoH; + case FMIN: return &asfreq_BtoT; + case FSEC: return &asfreq_BtoS; default: return &nofunc; } - case 'D': + case FDL: switch(toFreq) { - case 'A': return &asfreq_DtoA; - case 'Q': return &asfreq_DtoQ; - case 'M': return &asfreq_DtoM; - case 'W': return &asfreq_DtoW; - case 'B': + case FANN: return &asfreq_DtoA; + case FQTR: return &asfreq_DtoQ; + case FMTH: return &asfreq_DtoM; + case FWK: return &asfreq_DtoW; + case FBUS: if (forConvert) { return &asfreq_DtoB_forConvert; } else { return &asfreq_DtoB; } - case 'D': return &asfreq_DtoD; - case 'H': return &asfreq_DtoH; - case 'T': return &asfreq_DtoT; - case 'S': return &asfreq_DtoS; + case FDL: return &asfreq_DtoD; + case FHR: return &asfreq_DtoH; + case FMIN: return &asfreq_DtoT; + case FSEC: return &asfreq_DtoS; default: return &nofunc; } - case 'H': + case FHR: switch(toFreq) { - case 'A': return &asfreq_HtoA; - case 'Q': return &asfreq_HtoQ; - case 'M': return &asfreq_HtoM; - case 'W': return &asfreq_HtoW; - case 'B': + case FANN: return &asfreq_HtoA; + case FQTR: return &asfreq_HtoQ; + case FMTH: return &asfreq_HtoM; + case FWK: return &asfreq_HtoW; + case FBUS: if (forConvert) { return &asfreq_HtoB_forConvert; } else { return &asfreq_HtoB; } - case 'D': return &asfreq_HtoD; - case 'T': return &asfreq_HtoT; - case 'S': return &asfreq_HtoS; + case FDL: return &asfreq_HtoD; + case FMIN: return &asfreq_HtoT; + case FSEC: return &asfreq_HtoS; default: return &nofunc; } - case 'T': + case FMIN: switch(toFreq) { - case 'A': return &asfreq_TtoA; - case 'Q': return &asfreq_TtoQ; - case 'M': return &asfreq_TtoM; - case 'W': return &asfreq_TtoW; - case 'B': + case FANN: return &asfreq_TtoA; + case FQTR: return &asfreq_TtoQ; + case FMTH: return &asfreq_TtoM; + case FWK: return &asfreq_TtoW; + case FBUS: if (forConvert) { return &asfreq_TtoB_forConvert; } else { return &asfreq_TtoB; } - case 'D': return &asfreq_TtoD; - case 'H': return &asfreq_TtoH; - case 'S': return &asfreq_TtoS; + case FDL: return &asfreq_TtoD; + case FHR: return &asfreq_TtoH; + case FSEC: return &asfreq_TtoS; default: return &nofunc; } - case 'S': + case FSEC: switch(toFreq) { - case 'A': return &asfreq_StoA; - case 'Q': return &asfreq_StoQ; - case 'M': return &asfreq_StoM; - case 'W': return &asfreq_StoW; - case 'B': + case FANN: return &asfreq_StoA; + case FQTR: return &asfreq_StoQ; + case FMTH: return &asfreq_StoM; + case FWK: return &asfreq_StoW; + case FBUS: if (forConvert) { return &asfreq_StoB_forConvert; } else { return &asfreq_StoB; } - case 'D': return &asfreq_StoD; - case 'H': return &asfreq_StoH; - case 'T': return &asfreq_StoT; + case FDL: return &asfreq_StoD; + case FHR: return &asfreq_StoH; + case FMIN: return &asfreq_StoT; default: return &nofunc; } default: return &nofunc; @@ -546,7 +569,7 @@ determine the size of the second dimension for the resulting converted array */ -static long get_height(char fromFreq, char toFreq) { +static long get_height(int fromFreq, int toFreq) { int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; @@ -561,80 +584,80 @@ switch(fromFreq) { - case 'A': return 1; - case 'Q': + case FANN: return 1; + case FQTR: switch(toFreq) { - case 'A': return 4; + case FANN: return 4; default: return 1; } - case 'M': //monthly + case FMTH: //monthly switch(toFreq) { - case 'A': return 12; - case 'Q': return 3; + case FANN: return 12; + case FQTR: return 3; default: return 1; } - case 'W': //monthly + case FWK: //monthly switch(toFreq) { - case 'A': return 53; - case 'Q': return 13; - case 'M': return 4; + case FANN: return 53; + case FQTR: return 13; + case FMTH: return 4; default: return 1; } - case 'B': //business + case FBUS: //business switch(toFreq) { - case 'A': return maxBusDaysPerYear;; - case 'Q': return maxBusDaysPerQuarter; - case 'M': return maxBusDaysPerMonth; - case 'W': return 5; + case FANN: return maxBusDaysPerYear;; + case FQTR: return maxBusDaysPerQuarter; + case FMTH: return maxBusDaysPerMonth; + case FWK: return 5; default: return 1; } - case 'D': //daily + case FDL: //daily switch(toFreq) { - case 'A': return maxDaysPerYear;; - case 'Q': return maxDaysPerQuarter; - case 'M': return maxDaysPerMonth; - case 'W': return 7; + case FANN: return maxDaysPerYear;; + case FQTR: return maxDaysPerQuarter; + case FMTH: return maxDaysPerMonth; + case FWK: return 7; default: return 1; } - case 'H': //hourly + case FHR: //hourly switch(toFreq) { - case 'A': return 24 * maxDaysPerYear;; - case 'Q': return 24 * maxDaysPerQuarter; - case 'M': return 24 * maxDaysPerMonth; - case 'W': return 24 * 7; - case 'D': return 24; - case 'B': return 24; + case FANN: return 24 * maxDaysPerYear;; + case FQTR: return 24 * maxDaysPerQuarter; + case FMTH: return 24 * maxDaysPerMonth; + case FWK: return 24 * 7; + case FDL: return 24; + case FBUS: return 24; default: return 1; } - case 'T': //minutely + case FMIN: //minutely switch(toFreq) { - case 'A': return 24 * 60 * maxDaysPerYear;; - case 'Q': return 24 * 60 * maxDaysPerQuarter; - case 'M': return 24 * 60 * maxDaysPerMonth; - case 'W': return 24 * 60 * 7; - case 'D': return 24 * 60; - case 'B': return 24 * 60; - case 'H': return 60; + case FANN: return 24 * 60 * maxDaysPerYear;; + case FQTR: return 24 * 60 * maxDaysPerQuarter; + case FMTH: return 24 * 60 * maxDaysPerMonth; + case FWK: return 24 * 60 * 7; + case FDL: return 24 * 60; + case FBUS: return 24 * 60; + case FHR: return 60; default: return 1; } - case 'S': //minutely + case FSEC: //minutely switch(toFreq) { - case 'A': return 24 * 60 * 60 * maxDaysPerYear;; - case 'Q': return 24 * 60 * 60 * maxDaysPerQuarter; - case 'M': return 24 * 60 * 60 * maxDaysPerMonth; - case 'W': return 24 * 60 * 60 * 7; - case 'D': return 24 * 60 * 60; - case 'B': return 24 * 60 * 60; - case 'H': return 60 * 60; - case 'T': return 60; + case FANN: return 24 * 60 * 60 * maxDaysPerYear;; + case FQTR: return 24 * 60 * 60 * maxDaysPerQuarter; + case FMTH: return 24 * 60 * 60 * maxDaysPerMonth; + case FWK: return 24 * 60 * 60 * 7; + case FDL: return 24 * 60 * 60; + case FBUS: return 24 * 60 * 60; + case FHR: return 60 * 60; + case FMIN: return 60; default: return 1; } default: return 1; @@ -651,6 +674,7 @@ PyArrayObject *mask, *newMask; PyObject *returnVal = NULL; + PyObject *start_index_retval; long startIndex; long newStart, newStartTemp; @@ -660,7 +684,8 @@ long nd; npy_intp *dim, *newIdx; long currPerLen; - char *fromFreq, *toFreq, *position; + char *position; + int fromFreq, toFreq; char relation; PyObject *val, *valMask; @@ -671,13 +696,16 @@ returnVal = PyDict_New(); - if (!PyArg_ParseTuple(args, "OssslO:convert(array, fromfreq, tofreq, position, startIndex, mask)", &array, &fromFreq, &toFreq, &position, &startIndex, &mask)) return NULL; + if (!PyArg_ParseTuple(args, "OiislO:convert(array, fromfreq, tofreq, position, startIndex, mask)", &array, &fromFreq, &toFreq, &position, &startIndex, &mask)) return NULL; - if (toFreq[0] == fromFreq[0]) + if (toFreq == fromFreq) { PyDict_SetItemString(returnVal, "values", (PyObject*)array); PyDict_SetItemString(returnVal, "mask", (PyObject*)mask); + Py_DECREF(array); + Py_DECREF(mask); + return returnVal; } @@ -696,8 +724,8 @@ break; } - asfreq_main = get_asfreq_func(fromFreq[0], toFreq[0], 1); - asfreq_endpoints = get_asfreq_func(fromFreq[0], toFreq[0], 0); + asfreq_main = get_asfreq_func(fromFreq, toFreq, 1); + asfreq_endpoints = get_asfreq_func(fromFreq, toFreq, 0); //convert start index to new frequency newStartTemp = asfreq_main(startIndex, 'B'); @@ -715,11 +743,11 @@ } newLen = newEnd - newStart + 1; - newHeight = get_height(fromFreq[0], toFreq[0]); + newHeight = get_height(fromFreq, toFreq); if (newHeight > 1) { - asfreq_reverse = get_asfreq_func(toFreq[0], fromFreq[0], 0); + asfreq_reverse = get_asfreq_func(toFreq, fromFreq, 0); currPerLen = startIndex - asfreq_reverse(newStart, 'B'); nd = 2; @@ -778,10 +806,16 @@ PyDimMem_FREE(newIdx); + start_index_retval = (PyObject*)PyInt_FromLong(newStart); + PyDict_SetItemString(returnVal, "values", (PyObject*)newArray); PyDict_SetItemString(returnVal, "mask", (PyObject*)newMask); - PyDict_SetItemString(returnVal, "startindex", (PyObject*)PyInt_FromLong(newStart)); + PyDict_SetItemString(returnVal, "startindex", start_index_retval); + Py_DECREF(newArray); + Py_DECREF(newMask); + Py_DECREF(start_index_retval); + return returnVal; } @@ -794,13 +828,14 @@ PyArrayObject *fromDates, *toDates; PyArrayIterObject *iterFrom, *iterTo; PyObject *fromDateObj, *toDateObj; - char *fromFreq, *toFreq, *relation; + char *relation; + int fromFreq, toFreq; long fromDate, toDate; long (*asfreq_main)(long, char) = NULL; - if (!PyArg_ParseTuple(args, "Osss: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; - asfreq_main = get_asfreq_func(fromFreq[0], toFreq[0], 0); + asfreq_main = get_asfreq_func(fromFreq, toFreq, 0); toDates = (PyArrayObject *)PyArray_Copy(fromDates); @@ -841,35 +876,34 @@ static long dInfo_day_of_week(mxDateTimeObject *dateObj) { return dateObj->day_of_week; } static long dInfo_week(mxDateTimeObject *dateObj) { - long year, week, day; + int year, week, day; PyObject *ISOWeekTuple = NULL; - ISOWeekTuple = PyObject_GetAttrString(dateObj, "iso_week"); + ISOWeekTuple = PyObject_GetAttrString((PyObject*)dateObj, "iso_week"); if (!PyArg_ParseTuple(ISOWeekTuple,"iii;need a ISO Week 3-tuple (year,week,day)", - &year,&week,&day)) return NULL; + &year, &week, &day)) return NULL; Py_DECREF(ISOWeekTuple); - return week; + return (long)week; } static long dInfo_hour(mxDateTimeObject *dateObj) { return dateObj->hour; } static long dInfo_minute(mxDateTimeObject *dateObj) { return dateObj->minute; } -static long dInfo_second(mxDateTimeObject *dateObj) { return dateObj->second; } +static long dInfo_second(mxDateTimeObject *dateObj) { return (long)dateObj->second; } -static double getAbsTime(char freq, long dailyDate, long originalDate) { +static double getAbsTime(int freq, long dailyDate, long originalDate) { - double periodsPerDay, result; - long startOfDay; + long startOfDay, periodsPerDay; switch(freq) { - case 'H': + case FHR: periodsPerDay = 24; break; - case 'T': + case FMIN: periodsPerDay = 24*60; break; - case 'S': + case FSEC: periodsPerDay = 24*60*60; break; default: @@ -877,7 +911,7 @@ } startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay); - return (24*60*60)*((double)(originalDate - startOfDay))/periodsPerDay; + return (24*60*60)*((double)(originalDate - startOfDay))/((double)periodsPerDay); } @@ -886,7 +920,7 @@ static PyObject * cseries_getDateInfo(PyObject *self, PyObject *args) { - char *freq; + int freq; char *info; PyArrayObject *array; @@ -896,18 +930,20 @@ PyObject *val; long dateNum, dInfo; - double absdate, abstime; + long absdate; + //double absdate, abstime; + double abstime; long (*toDaily)(long, char) = NULL; long (*getDateInfo)(mxDateTimeObject*) = NULL; - if (!PyArg_ParseTuple(args, "Oss:getDateInfo(array, freq, info)", &array, &freq, &info)) return NULL; + 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, 'D', 0); + toDaily = get_asfreq_func(freq, FDL, 0); switch(*info) { @@ -949,8 +985,9 @@ val = PyArray_GETITEM(array, iterSource->dataptr); dateNum = PyInt_AsLong(val); - absdate = (double)toDaily(dateNum, 'B'); - abstime = getAbsTime(*freq, absdate, dateNum); + //absdate = (double)toDaily(dateNum, 'B'); + absdate = toDaily(dateNum, 'B'); + abstime = getAbsTime(freq, absdate, dateNum); convDate = (mxDateTimeObject *)mxDateTime.DateTime_FromAbsDateAndTime(absdate, abstime); dInfo = getDateInfo(convDate); From scipy-svn at scipy.org Tue Jan 30 13:40:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 12:40:20 -0600 (CST) Subject: [Scipy-svn] r2641 - trunk/Lib/sandbox/timeseries Message-ID: <20070130184020.AEAD739C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 12:40:17 -0600 (Tue, 30 Jan 2007) New Revision: 2641 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: updated various functions that called c code to pass frequency integers instead of strings Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 18:38:49 UTC (rev 2640) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 18:40:17 UTC (rev 2641) @@ -265,7 +265,7 @@ def __getDateInfo(self, info): return int(cseries.getDateInfo(numpy.asarray(self.value), - self.freqstr, info)) + self.freq, info)) def __add__(self, other): if isinstance(other, Date): @@ -377,15 +377,12 @@ "Returns the date as itself." return self - def asfreq(self, toFreq, relation='before'): - """Converts the date to a new frequency.""" - return asfreq(self, toFreq, relation) - 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 --- @@ -450,7 +447,7 @@ def asfreq(date, toFreq, relation="BEFORE"): """Returns a date converted to another frequency `toFreq`, according to the relation `relation` .""" - tofreq = corelib.check_freqstr(toFreq) + tofreq = corelib.check_freq(toFreq) _rel = relation.upper()[0] if _rel not in ['B', 'A']: msg = "Invalid relation '%s': Should be in ['before', 'after']" @@ -461,9 +458,9 @@ if date.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") - fromfreq = 'D' + fromfreq = corelib.check_freq('D') else: - fromfreq = date.freqstr + fromfreq = date.freq if fromfreq == tofreq: return date @@ -474,6 +471,8 @@ else: return None +Date.asfreq = asfreq + def isDate(data): "Returns whether `data` is an instance of Date." return isinstance(data, Date) @@ -646,12 +645,12 @@ # Note: As we define a new object, we don't need caching if freq is None: return self - tofreq = corelib.fmtFreq(freq) + tofreq = corelib.check_freq(freq) if tofreq == self.freq: return self if self.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") - fromfreq = 'D' + fromfreq = corelib.check_freq('D') else: fromfreq = self.freq _rel = relation.upper()[0] From scipy-svn at scipy.org Tue Jan 30 13:40:47 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 12:40:47 -0600 (CST) Subject: [Scipy-svn] r2642 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070130184047.298FA39C01C@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 12:40:43 -0600 (Tue, 30 Jan 2007) New Revision: 2642 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: added tests for asfreq method of DateArray Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 18:40:17 UTC (rev 2641) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 18:40:43 UTC (rev 2642) @@ -29,7 +29,7 @@ reload(tdates) from timeseries import tcore reload(tcore) -from timeseries.tdates import date_array_fromlist, Date, DateArray, mxDFromString +from timeseries.tdates import date_array_fromlist, Date, DateArray, date_array, mxDFromString class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -200,465 +200,482 @@ assert_equal(s_date.second, 0) +def dArrayWrap(date): + "wrap a date into a DateArray of length 1" + return date_array(start_date=date,length=1) + +def noWrap(item): return item + class test_freq_conversion(NumpyTestCase): "Test frequency conversion of date objects" def __init__(self, *args, **kwds): - NumpyTestCase.__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" - date_A = Date(freq='A', year=2007) - date_A_to_Q_before = Date(freq='Q', year=2007, quarter=1) - date_A_to_Q_after = Date(freq='Q', year=2007, quarter=4) - date_A_to_M_before = Date(freq='M', year=2007, month=1) - date_A_to_M_after = Date(freq='M', year=2007, month=12) - date_A_to_W_before = Date(freq='W', year=2007, month=1, day=1) - date_A_to_W_after = Date(freq='W', year=2007, month=12, day=31) - date_A_to_B_before = Date(freq='B', year=2007, month=1, day=1) - date_A_to_B_after = Date(freq='B', year=2007, month=12, day=31) - date_A_to_D_before = Date(freq='D', year=2007, month=1, day=1) - date_A_to_D_after = Date(freq='D', year=2007, month=12, day=31) - date_A_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_A_to_H_after = Date(freq='H', year=2007, month=12, day=31, - hour=23) - date_A_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_A_to_T_after = Date(freq='T', year=2007, month=12, day=31, - hour=23, minute=59) - date_A_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_A_to_S_after = Date(freq='S', year=2007, month=12, day=31, - hour=23, minute=59, second=59) - - assert_equal(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) - assert_equal(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) - assert_equal(date_A.asfreq('M', "BEFORE"), date_A_to_M_before) - assert_equal(date_A.asfreq('M', "AFTER"), date_A_to_M_after) - assert_equal(date_A.asfreq('W', "BEFORE"), date_A_to_W_before) - assert_equal(date_A.asfreq('W', "AFTER"), date_A_to_W_after) - assert_equal(date_A.asfreq('B', "BEFORE"), date_A_to_B_before) - assert_equal(date_A.asfreq('B', "AFTER"), date_A_to_B_after) - assert_equal(date_A.asfreq('D', "BEFORE"), date_A_to_D_before) - assert_equal(date_A.asfreq('D', "AFTER"), date_A_to_D_after) - assert_equal(date_A.asfreq('H', "BEFORE"), date_A_to_H_before) - assert_equal(date_A.asfreq('H', "AFTER"), date_A_to_H_after) - assert_equal(date_A.asfreq('T', "BEFORE"), date_A_to_T_before) - assert_equal(date_A.asfreq('T', "AFTER"), date_A_to_T_after) - assert_equal(date_A.asfreq('S', "BEFORE"), date_A_to_S_before) - assert_equal(date_A.asfreq('S', "AFTER"), date_A_to_S_after) + for dWrap, assert_func in self.dateWrap: + date_A = dWrap(Date(freq='A', 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)) + date_A_to_M_after = dWrap(Date(freq='M', year=2007, month=12)) + date_A_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_A_to_W_after = dWrap(Date(freq='W', year=2007, month=12, day=31)) + date_A_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) + 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, + hour=0)) + 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, + hour=0, minute=0)) + 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, + hour=0, minute=0, second=0)) + 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) + assert_func(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) + assert_func(date_A.asfreq('M', "BEFORE"), date_A_to_M_before) + assert_func(date_A.asfreq('M', "AFTER"), date_A_to_M_after) + assert_func(date_A.asfreq('W', "BEFORE"), date_A_to_W_before) + assert_func(date_A.asfreq('W', "AFTER"), date_A_to_W_after) + assert_func(date_A.asfreq('B', "BEFORE"), date_A_to_B_before) + assert_func(date_A.asfreq('B', "AFTER"), date_A_to_B_after) + assert_func(date_A.asfreq('D', "BEFORE"), date_A_to_D_before) + assert_func(date_A.asfreq('D', "AFTER"), date_A_to_D_after) + assert_func(date_A.asfreq('H', "BEFORE"), date_A_to_H_before) + assert_func(date_A.asfreq('H', "AFTER"), date_A_to_H_after) + assert_func(date_A.asfreq('T', "BEFORE"), date_A_to_T_before) + assert_func(date_A.asfreq('T', "AFTER"), date_A_to_T_after) + 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" - date_Q = Date(freq='Q', year=2007, quarter=1) - date_Q_end_of_year = Date(freq='Q', year=2007, quarter=4) - date_Q_to_A = Date(freq='A', year=2007) - date_Q_to_M_before = Date(freq='M', year=2007, month=1) - date_Q_to_M_after = Date(freq='M', year=2007, month=3) - date_Q_to_W_before = Date(freq='W', year=2007, month=1, day=1) - date_Q_to_W_after = Date(freq='W', year=2007, month=3, day=31) - date_Q_to_B_before = Date(freq='B', year=2007, month=1, day=1) - date_Q_to_B_after = Date(freq='B', year=2007, month=3, day=30) - date_Q_to_D_before = Date(freq='D', year=2007, month=1, day=1) - date_Q_to_D_after = Date(freq='D', year=2007, month=3, day=31) - date_Q_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_Q_to_H_after = Date(freq='H', year=2007, month=3, day=31, - hour=23) - date_Q_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_Q_to_T_after = Date(freq='T', year=2007, month=3, day=31, - hour=23, minute=59) - date_Q_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_Q_to_S_after = Date(freq='S', year=2007, month=3, day=31, - hour=23, minute=59, second=59) + 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_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)) + date_Q_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_Q_to_W_after = dWrap(Date(freq='W', year=2007, month=3, day=31)) + date_Q_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) + 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, + hour=0)) + 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, + hour=0, minute=0)) + 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, + hour=0, minute=0, second=0)) + 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) + assert_func(date_Q_end_of_year.asfreq('A'), date_Q_to_A) + + assert_func(date_Q.asfreq('M', "BEFORE"), date_Q_to_M_before) + assert_func(date_Q.asfreq('M', "AFTER"), date_Q_to_M_after) + assert_func(date_Q.asfreq('W', "BEFORE"), date_Q_to_W_before) + assert_func(date_Q.asfreq('W', "AFTER"), date_Q_to_W_after) + assert_func(date_Q.asfreq('B', "BEFORE"), date_Q_to_B_before) + assert_func(date_Q.asfreq('B', "AFTER"), date_Q_to_B_after) + assert_func(date_Q.asfreq('D', "BEFORE"), date_Q_to_D_before) + assert_func(date_Q.asfreq('D', "AFTER"), date_Q_to_D_after) + assert_func(date_Q.asfreq('H', "BEFORE"), date_Q_to_H_before) + assert_func(date_Q.asfreq('H', "AFTER"), date_Q_to_H_after) + assert_func(date_Q.asfreq('T', "BEFORE"), date_Q_to_T_before) + 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) - assert_equal(date_Q.asfreq('A'), date_Q_to_A) - assert_equal(date_Q_end_of_year.asfreq('A'), date_Q_to_A) - - assert_equal(date_Q.asfreq('M', "BEFORE"), date_Q_to_M_before) - assert_equal(date_Q.asfreq('M', "AFTER"), date_Q_to_M_after) - assert_equal(date_Q.asfreq('W', "BEFORE"), date_Q_to_W_before) - assert_equal(date_Q.asfreq('W', "AFTER"), date_Q_to_W_after) - assert_equal(date_Q.asfreq('B', "BEFORE"), date_Q_to_B_before) - assert_equal(date_Q.asfreq('B', "AFTER"), date_Q_to_B_after) - assert_equal(date_Q.asfreq('D', "BEFORE"), date_Q_to_D_before) - assert_equal(date_Q.asfreq('D', "AFTER"), date_Q_to_D_after) - assert_equal(date_Q.asfreq('H', "BEFORE"), date_Q_to_H_before) - assert_equal(date_Q.asfreq('H', "AFTER"), date_Q_to_H_after) - assert_equal(date_Q.asfreq('T', "BEFORE"), date_Q_to_T_before) - assert_equal(date_Q.asfreq('T', "AFTER"), date_Q_to_T_after) - assert_equal(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before) - assert_equal(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after) - def test_conv_monthly(self): "frequency conversion tests: from Monthly Frequency" - date_M = Date(freq='M', year=2007, month=1) - date_M_end_of_year = Date(freq='M', year=2007, month=12) - date_M_end_of_quarter = Date(freq='M', year=2007, month=3) - date_M_to_A = Date(freq='A', year=2007) - date_M_to_Q = Date(freq='Q', year=2007, quarter=1) - date_M_to_W_before = Date(freq='W', year=2007, month=1, day=1) - date_M_to_W_after = Date(freq='W', year=2007, month=1, day=31) - date_M_to_B_before = Date(freq='B', year=2007, month=1, day=1) - date_M_to_B_after = Date(freq='B', year=2007, month=1, day=31) - date_M_to_D_before = Date(freq='D', year=2007, month=1, day=1) - date_M_to_D_after = Date(freq='D', year=2007, month=1, day=31) - date_M_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_M_to_H_after = Date(freq='H', year=2007, month=1, day=31, - hour=23) - date_M_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_M_to_T_after = Date(freq='T', year=2007, month=1, day=31, - hour=23, minute=59) - date_M_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_M_to_S_after = Date(freq='S', year=2007, month=1, day=31, - hour=23, minute=59, second=59) - - assert_equal(date_M.asfreq('A'), date_M_to_A) - assert_equal(date_M_end_of_year.asfreq('A'), date_M_to_A) - assert_equal(date_M.asfreq('Q'), date_M_to_Q) - assert_equal(date_M_end_of_quarter.asfreq('Q'), date_M_to_Q) + 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)) + date_M_end_of_quarter = dWrap(Date(freq='M', year=2007, month=3)) + date_M_to_A = dWrap(Date(freq='A', year=2007)) + date_M_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_M_to_W_before = dWrap(Date(freq='W', year=2007, month=1, day=1)) + date_M_to_W_after = dWrap(Date(freq='W', year=2007, month=1, day=31)) + date_M_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) + 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, + hour=0)) + 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, + hour=0, minute=0)) + 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, + hour=0, minute=0, second=0)) + date_M_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=31, + hour=23, minute=59, second=59)) - assert_equal(date_M.asfreq('W', "BEFORE"), date_M_to_W_before) - assert_equal(date_M.asfreq('W', "AFTER"), date_M_to_W_after) - assert_equal(date_M.asfreq('B', "BEFORE"), date_M_to_B_before) - assert_equal(date_M.asfreq('B', "AFTER"), date_M_to_B_after) - assert_equal(date_M.asfreq('D', "BEFORE"), date_M_to_D_before) - assert_equal(date_M.asfreq('D', "AFTER"), date_M_to_D_after) - assert_equal(date_M.asfreq('H', "BEFORE"), date_M_to_H_before) - assert_equal(date_M.asfreq('H', "AFTER"), date_M_to_H_after) - assert_equal(date_M.asfreq('T', "BEFORE"), date_M_to_T_before) - assert_equal(date_M.asfreq('T', "AFTER"), date_M_to_T_after) - assert_equal(date_M.asfreq('S', "BEFORE"), date_M_to_S_before) - assert_equal(date_M.asfreq('S', "AFTER"), date_M_to_S_after) + assert_func(date_M.asfreq('A'), date_M_to_A) + assert_func(date_M_end_of_year.asfreq('A'), date_M_to_A) + assert_func(date_M.asfreq('Q'), date_M_to_Q) + assert_func(date_M_end_of_quarter.asfreq('Q'), date_M_to_Q) + assert_func(date_M.asfreq('W', "BEFORE"), date_M_to_W_before) + assert_func(date_M.asfreq('W', "AFTER"), date_M_to_W_after) + assert_func(date_M.asfreq('B', "BEFORE"), date_M_to_B_before) + assert_func(date_M.asfreq('B', "AFTER"), date_M_to_B_after) + assert_func(date_M.asfreq('D', "BEFORE"), date_M_to_D_before) + assert_func(date_M.asfreq('D', "AFTER"), date_M_to_D_after) + assert_func(date_M.asfreq('H', "BEFORE"), date_M_to_H_before) + assert_func(date_M.asfreq('H', "AFTER"), date_M_to_H_after) + assert_func(date_M.asfreq('T', "BEFORE"), date_M_to_T_before) + assert_func(date_M.asfreq('T', "AFTER"), date_M_to_T_after) + 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" - date_W = Date(freq='W', year=2007, month=1, day=1) - date_W_end_of_year = Date(freq='W', year=2007, month=12, day=31) - date_W_end_of_quarter = Date(freq='W', year=2007, month=3, day=31) - date_W_end_of_month = Date(freq='W', year=2007, month=1, day=31) - date_W_to_A = Date(freq='A', year=2007) - date_W_to_Q = Date(freq='Q', year=2007, quarter=1) - date_W_to_M = Date(freq='M', year=2007, month=1) + 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)) + 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)) + date_W_to_A = dWrap(Date(freq='A', year=2007)) + date_W_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_W_to_M = dWrap(Date(freq='M', year=2007, month=1)) - if Date(freq='D', year=2007, month=12, day=31).day_of_week == 6: - date_W_to_A_end_of_year = Date(freq='A', year=2007) - else: - date_W_to_A_end_of_year = Date(freq='A', year=2008) + if Date(freq='D', year=2007, month=12, day=31).day_of_week == 6: + date_W_to_A_end_of_year = dWrap(Date(freq='A', year=2007)) + else: + date_W_to_A_end_of_year = dWrap(Date(freq='A', year=2008)) - if Date(freq='D', year=2007, month=3, day=31).day_of_week == 6: - date_W_to_Q_end_of_quarter = Date(freq='Q', year=2007, quarter=1) - else: - date_W_to_Q_end_of_quarter = Date(freq='Q', year=2007, quarter=2) + if Date(freq='D', year=2007, month=3, day=31).day_of_week == 6: + date_W_to_Q_end_of_quarter = dWrap(Date(freq='Q', year=2007, quarter=1)) + else: + date_W_to_Q_end_of_quarter = dWrap(Date(freq='Q', year=2007, quarter=2)) - if Date(freq='D', year=2007, month=1, day=31).day_of_week == 6: - date_W_to_M_end_of_month = Date(freq='M', year=2007, month=1) - else: - date_W_to_M_end_of_month = Date(freq='M', year=2007, month=2) + if Date(freq='D', year=2007, month=1, day=31).day_of_week == 6: + date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=1)) + else: + date_W_to_M_end_of_month = dWrap(Date(freq='M', year=2007, month=2)) - date_W_to_B_before = Date(freq='B', year=2007, month=1, day=1) - date_W_to_B_after = Date(freq='B', year=2007, month=1, day=5) - date_W_to_D_before = Date(freq='D', year=2007, month=1, day=1) - date_W_to_D_after = Date(freq='D', year=2007, month=1, day=7) - date_W_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_W_to_H_after = Date(freq='H', year=2007, month=1, day=7, - hour=23) - date_W_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_W_to_T_after = Date(freq='T', year=2007, month=1, day=7, - hour=23, minute=59) - date_W_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_W_to_S_after = Date(freq='S', year=2007, month=1, day=7, - hour=23, minute=59, second=59) - - assert_equal(date_W.asfreq('A'), date_W_to_A) - assert_equal(date_W_end_of_year.asfreq('A'), date_W_to_A_end_of_year) - assert_equal(date_W.asfreq('Q'), date_W_to_Q) - assert_equal(date_W_end_of_quarter.asfreq('Q'), date_W_to_Q_end_of_quarter) - assert_equal(date_W.asfreq('M'), date_W_to_M) - assert_equal(date_W_end_of_month.asfreq('M'), date_W_to_M_end_of_month) + date_W_to_B_before = dWrap(Date(freq='B', year=2007, month=1, day=1)) + 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, + hour=0)) + 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, + hour=0, minute=0)) + 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, + hour=0, minute=0, second=0)) + date_W_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=7, + hour=23, minute=59, second=59)) - assert_equal(date_W.asfreq('B', "BEFORE"), date_W_to_B_before) - assert_equal(date_W.asfreq('B', "AFTER"), date_W_to_B_after) - assert_equal(date_W.asfreq('D', "BEFORE"), date_W_to_D_before) - assert_equal(date_W.asfreq('D', "AFTER"), date_W_to_D_after) - assert_equal(date_W.asfreq('H', "BEFORE"), date_W_to_H_before) - assert_equal(date_W.asfreq('H', "AFTER"), date_W_to_H_after) - assert_equal(date_W.asfreq('T', "BEFORE"), date_W_to_T_before) - assert_equal(date_W.asfreq('T', "AFTER"), date_W_to_T_after) - assert_equal(date_W.asfreq('S', "BEFORE"), date_W_to_S_before) - assert_equal(date_W.asfreq('S', "AFTER"), date_W_to_S_after) + assert_func(date_W.asfreq('A'), date_W_to_A) + assert_func(date_W_end_of_year.asfreq('A'), date_W_to_A_end_of_year) + assert_func(date_W.asfreq('Q'), date_W_to_Q) + assert_func(date_W_end_of_quarter.asfreq('Q'), date_W_to_Q_end_of_quarter) + assert_func(date_W.asfreq('M'), date_W_to_M) + assert_func(date_W_end_of_month.asfreq('M'), date_W_to_M_end_of_month) + + 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_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) + 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" - date_B = Date(freq='B', year=2007, month=1, day=1) - date_B_end_of_year = Date(freq='B', year=2007, month=12, day=31) - date_B_end_of_quarter = Date(freq='B', year=2007, month=3, day=30) - date_B_end_of_month = Date(freq='B', year=2007, month=1, day=31) - date_B_end_of_week = Date(freq='B', year=2007, month=1, day=5) - - date_B_to_A = Date(freq='A', year=2007) - date_B_to_Q = Date(freq='Q', year=2007, quarter=1) - date_B_to_M = Date(freq='M', year=2007, month=1) - date_B_to_W = Date(freq='W', year=2007, month=1, day=7) - date_B_to_D = Date(freq='D', year=2007, month=1, day=1) - date_B_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_B_to_H_after = Date(freq='H', year=2007, month=1, day=1, - hour=23) - date_B_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_B_to_T_after = Date(freq='T', year=2007, month=1, day=1, - hour=23, minute=59) - date_B_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_B_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hour=23, minute=59, second=59) - - assert_equal(date_B.asfreq('A'), date_B_to_A) - assert_equal(date_B_end_of_year.asfreq('A'), date_B_to_A) - assert_equal(date_B.asfreq('Q'), date_B_to_Q) - assert_equal(date_B_end_of_quarter.asfreq('Q'), date_B_to_Q) - assert_equal(date_B.asfreq('M'), date_B_to_M) - assert_equal(date_B_end_of_month.asfreq('M'), date_B_to_M) - assert_equal(date_B.asfreq('W'), date_B_to_W) - assert_equal(date_B_end_of_week.asfreq('W'), date_B_to_W) + 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)) + date_B_end_of_quarter = dWrap(Date(freq='B', year=2007, month=3, day=30)) + date_B_end_of_month = dWrap(Date(freq='B', year=2007, month=1, day=31)) + date_B_end_of_week = dWrap(Date(freq='B', year=2007, month=1, day=5)) - assert_equal(date_B.asfreq('D'), date_B_to_D) + date_B_to_A = dWrap(Date(freq='A', year=2007)) + date_B_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + 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, + hour=0)) + 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, + hour=0, minute=0)) + 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, + hour=0, minute=0, second=0)) + date_B_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + hour=23, minute=59, second=59)) - assert_equal(date_B.asfreq('H', "BEFORE"), date_B_to_H_before) - assert_equal(date_B.asfreq('H', "AFTER"), date_B_to_H_after) - assert_equal(date_B.asfreq('T', "BEFORE"), date_B_to_T_before) - assert_equal(date_B.asfreq('T', "AFTER"), date_B_to_T_after) - assert_equal(date_B.asfreq('S', "BEFORE"), date_B_to_S_before) - assert_equal(date_B.asfreq('S', "AFTER"), date_B_to_S_after) + assert_func(date_B.asfreq('A'), date_B_to_A) + assert_func(date_B_end_of_year.asfreq('A'), date_B_to_A) + assert_func(date_B.asfreq('Q'), date_B_to_Q) + assert_func(date_B_end_of_quarter.asfreq('Q'), date_B_to_Q) + assert_func(date_B.asfreq('M'), date_B_to_M) + assert_func(date_B_end_of_month.asfreq('M'), date_B_to_M) + assert_func(date_B.asfreq('W'), date_B_to_W) + assert_func(date_B_end_of_week.asfreq('W'), date_B_to_W) + assert_func(date_B.asfreq('D'), date_B_to_D) + + assert_func(date_B.asfreq('H', "BEFORE"), date_B_to_H_before) + assert_func(date_B.asfreq('H', "AFTER"), date_B_to_H_after) + assert_func(date_B.asfreq('T', "BEFORE"), date_B_to_T_before) + assert_func(date_B.asfreq('T', "AFTER"), date_B_to_T_after) + assert_func(date_B.asfreq('S', "BEFORE"), date_B_to_S_before) + assert_func(date_B.asfreq('S', "AFTER"), date_B_to_S_after) + def test_conv_daily(self): "frequency conversion tests: from Business Frequency" - date_D = Date(freq='D', year=2007, month=1, day=1) - date_D_end_of_year = Date(freq='D', year=2007, month=12, day=31) - date_D_end_of_quarter = Date(freq='D', year=2007, month=3, day=31) - date_D_end_of_month = Date(freq='D', year=2007, month=1, day=31) - date_D_end_of_week = Date(freq='D', year=2007, month=1, day=7) - - date_D_friday = Date(freq='D', year=2007, month=1, day=5) - date_D_saturday = Date(freq='D', year=2007, month=1, day=6) - date_D_sunday = Date(freq='D', year=2007, month=1, day=7) - date_D_monday = Date(freq='D', year=2007, month=1, day=8) - - date_B_friday = Date(freq='B', year=2007, month=1, day=5) - date_B_monday = Date(freq='B', year=2007, month=1, day=8) - - date_D_to_A = Date(freq='A', year=2007) - date_D_to_Q = Date(freq='Q', year=2007, quarter=1) - date_D_to_M = Date(freq='M', year=2007, month=1) - date_D_to_W = Date(freq='W', year=2007, month=1, day=7) + 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)) + date_D_end_of_quarter = dWrap(Date(freq='D', year=2007, month=3, day=31)) + date_D_end_of_month = dWrap(Date(freq='D', year=2007, month=1, day=31)) + date_D_end_of_week = dWrap(Date(freq='D', year=2007, month=1, day=7)) - date_D_to_H_before = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_D_to_H_after = Date(freq='H', year=2007, month=1, day=1, - hour=23) - date_D_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_D_to_T_after = Date(freq='T', year=2007, month=1, day=1, - hour=23, minute=59) - date_D_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_D_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hour=23, minute=59, second=59) - - assert_equal(date_D.asfreq('A'), date_D_to_A) - assert_equal(date_D_end_of_year.asfreq('A'), date_D_to_A) - assert_equal(date_D.asfreq('Q'), date_D_to_Q) - assert_equal(date_D_end_of_quarter.asfreq('Q'), date_D_to_Q) - assert_equal(date_D.asfreq('M'), date_D_to_M) - assert_equal(date_D_end_of_month.asfreq('M'), date_D_to_M) - assert_equal(date_D.asfreq('W'), date_D_to_W) - assert_equal(date_D_end_of_week.asfreq('W'), date_D_to_W) + date_D_friday = dWrap(Date(freq='D', year=2007, month=1, day=5)) + date_D_saturday = dWrap(Date(freq='D', year=2007, month=1, day=6)) + date_D_sunday = dWrap(Date(freq='D', year=2007, month=1, day=7)) + date_D_monday = dWrap(Date(freq='D', year=2007, month=1, day=8)) - assert_equal(date_D_friday.asfreq('B'), date_B_friday) - assert_equal(date_D_saturday.asfreq('B', "BEFORE"), date_B_friday) - assert_equal(date_D_saturday.asfreq('B', "AFTER"), date_B_monday) - assert_equal(date_D_sunday.asfreq('B', "BEFORE"), date_B_friday) - assert_equal(date_D_sunday.asfreq('B', "AFTER"), date_B_monday) + date_B_friday = dWrap(Date(freq='B', year=2007, month=1, day=5)) + date_B_monday = dWrap(Date(freq='B', year=2007, month=1, day=8)) - assert_equal(date_D.asfreq('H', "BEFORE"), date_D_to_H_before) - assert_equal(date_D.asfreq('H', "AFTER"), date_D_to_H_after) - assert_equal(date_D.asfreq('T', "BEFORE"), date_D_to_T_before) - assert_equal(date_D.asfreq('T', "AFTER"), date_D_to_T_after) - assert_equal(date_D.asfreq('S', "BEFORE"), date_D_to_S_before) - assert_equal(date_D.asfreq('S', "AFTER"), date_D_to_S_after) + date_D_to_A = dWrap(Date(freq='A', year=2007)) + date_D_to_Q = dWrap(Date(freq='Q', 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)) + 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, + hour=23)) + 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, + hour=23, minute=59)) + 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, + hour=23, minute=59, second=59)) + + assert_func(date_D.asfreq('A'), date_D_to_A) + 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.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) + assert_func(date_D_end_of_week.asfreq('W'), date_D_to_W) + + assert_func(date_D_friday.asfreq('B'), date_B_friday) + assert_func(date_D_saturday.asfreq('B', "BEFORE"), date_B_friday) + assert_func(date_D_saturday.asfreq('B', "AFTER"), date_B_monday) + assert_func(date_D_sunday.asfreq('B', "BEFORE"), date_B_friday) + assert_func(date_D_sunday.asfreq('B', "AFTER"), date_B_monday) + + assert_func(date_D.asfreq('H', "BEFORE"), date_D_to_H_before) + assert_func(date_D.asfreq('H', "AFTER"), date_D_to_H_after) + assert_func(date_D.asfreq('T', "BEFORE"), date_D_to_T_before) + assert_func(date_D.asfreq('T', "AFTER"), date_D_to_T_after) + assert_func(date_D.asfreq('S', "BEFORE"), date_D_to_S_before) + assert_func(date_D.asfreq('S', "AFTER"), date_D_to_S_after) + def test_conv_hourly(self): "frequency conversion tests: from Hourly Frequency" - date_H = Date(freq='H', year=2007, month=1, day=1, hour=0) - date_H_end_of_year = Date(freq='H', year=2007, month=12, day=31, - hour=23) - date_H_end_of_quarter = Date(freq='H', year=2007, month=3, day=31, - hour=23) - date_H_end_of_month = Date(freq='H', year=2007, month=1, day=31, - hour=23) - date_H_end_of_week = Date(freq='H', year=2007, month=1, day=7, - hour=23) - date_H_end_of_day = Date(freq='H', year=2007, month=1, day=1, - hour=23) - date_H_end_of_bus = Date(freq='H', year=2007, month=1, day=1, - hour=23) - - date_H_to_A = Date(freq='A', year=2007) - date_H_to_Q = Date(freq='Q', year=2007, quarter=1) - date_H_to_M = Date(freq='M', year=2007, month=1) - date_H_to_W = Date(freq='W', year=2007, month=1, day=7) - date_H_to_D = Date(freq='D', year=2007, month=1, day=1) - date_H_to_B = Date(freq='B', year=2007, month=1, day=1) - - date_H_to_T_before = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_H_to_T_after = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=59) - date_H_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_H_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=59, second=59) - - assert_equal(date_H.asfreq('A'), date_H_to_A) - assert_equal(date_H_end_of_year.asfreq('A'), date_H_to_A) - assert_equal(date_H.asfreq('Q'), date_H_to_Q) - assert_equal(date_H_end_of_quarter.asfreq('Q'), date_H_to_Q) - assert_equal(date_H.asfreq('M'), date_H_to_M) - assert_equal(date_H_end_of_month.asfreq('M'), date_H_to_M) - assert_equal(date_H.asfreq('W'), date_H_to_W) - assert_equal(date_H_end_of_week.asfreq('W'), date_H_to_W) - assert_equal(date_H.asfreq('D'), date_H_to_D) - assert_equal(date_H_end_of_day.asfreq('D'), date_H_to_D) - assert_equal(date_H.asfreq('B'), date_H_to_B) - assert_equal(date_H_end_of_bus.asfreq('B'), date_H_to_B) + 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, + hour=23)) + 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, + hour=23)) + 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, + hour=23)) + date_H_end_of_bus = dWrap(Date(freq='H', year=2007, month=1, day=1, + hour=23)) - assert_equal(date_H.asfreq('T', "BEFORE"), date_H_to_T_before) - assert_equal(date_H.asfreq('T', "AFTER"), date_H_to_T_after) - assert_equal(date_H.asfreq('S', "BEFORE"), date_H_to_S_before) - assert_equal(date_H.asfreq('S', "AFTER"), date_H_to_S_after) + date_H_to_A = dWrap(Date(freq='A', year=2007)) + date_H_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_H_to_M = dWrap(Date(freq='M', year=2007, month=1)) + date_H_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) + 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, + hour=0, minute=0)) + 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, + hour=0, minute=0, second=0)) + 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) + assert_func(date_H_end_of_year.asfreq('A'), date_H_to_A) + assert_func(date_H.asfreq('Q'), date_H_to_Q) + assert_func(date_H_end_of_quarter.asfreq('Q'), date_H_to_Q) + assert_func(date_H.asfreq('M'), date_H_to_M) + assert_func(date_H_end_of_month.asfreq('M'), date_H_to_M) + assert_func(date_H.asfreq('W'), date_H_to_W) + assert_func(date_H_end_of_week.asfreq('W'), date_H_to_W) + assert_func(date_H.asfreq('D'), date_H_to_D) + assert_func(date_H_end_of_day.asfreq('D'), date_H_to_D) + assert_func(date_H.asfreq('B'), date_H_to_B) + assert_func(date_H_end_of_bus.asfreq('B'), date_H_to_B) + + assert_func(date_H.asfreq('T', "BEFORE"), date_H_to_T_before) + assert_func(date_H.asfreq('T', "AFTER"), date_H_to_T_after) + assert_func(date_H.asfreq('S', "BEFORE"), date_H_to_S_before) + assert_func(date_H.asfreq('S', "AFTER"), date_H_to_S_after) + def test_conv_minutely(self): "frequency conversion tests: from Minutely Frequency" - date_T = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - date_T_end_of_year = Date(freq='T', year=2007, month=12, day=31, - hour=23, minute=59) - date_T_end_of_quarter = Date(freq='T', year=2007, month=3, day=31, - hour=23, minute=59) - date_T_end_of_month = Date(freq='T', year=2007, month=1, day=31, - hour=23, minute=59) - date_T_end_of_week = Date(freq='T', year=2007, month=1, day=7, - hour=23, minute=59) - date_T_end_of_day = Date(freq='T', year=2007, month=1, day=1, - hour=23, minute=59) - date_T_end_of_bus = Date(freq='T', year=2007, month=1, day=1, - hour=23, minute=59) - date_T_end_of_hour = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=59) - - date_T_to_A = Date(freq='A', year=2007) - date_T_to_Q = Date(freq='Q', year=2007, quarter=1) - date_T_to_M = Date(freq='M', year=2007, month=1) - date_T_to_W = Date(freq='W', year=2007, month=1, day=7) - date_T_to_D = Date(freq='D', year=2007, month=1, day=1) - date_T_to_B = Date(freq='B', year=2007, month=1, day=1) - date_T_to_H = Date(freq='H', year=2007, month=1, day=1, hour=0) - - date_T_to_S_before = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_T_to_S_after = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=59) - - assert_equal(date_T.asfreq('A'), date_T_to_A) - assert_equal(date_T_end_of_year.asfreq('A'), date_T_to_A) - assert_equal(date_T.asfreq('Q'), date_T_to_Q) - assert_equal(date_T_end_of_quarter.asfreq('Q'), date_T_to_Q) - assert_equal(date_T.asfreq('M'), date_T_to_M) - assert_equal(date_T_end_of_month.asfreq('M'), date_T_to_M) - assert_equal(date_T.asfreq('W'), date_T_to_W) - assert_equal(date_T_end_of_week.asfreq('W'), date_T_to_W) - assert_equal(date_T.asfreq('D'), date_T_to_D) - assert_equal(date_T_end_of_day.asfreq('D'), date_T_to_D) - assert_equal(date_T.asfreq('B'), date_T_to_B) - assert_equal(date_T_end_of_bus.asfreq('B'), date_T_to_B) - assert_equal(date_T.asfreq('H'), date_T_to_H) - assert_equal(date_T_end_of_hour.asfreq('H'), date_T_to_H) + for dWrap, assert_func in self.dateWrap: + 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, + hour=23, minute=59)) + 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, + hour=23, minute=59)) + 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, + hour=23, minute=59)) + 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, + hour=0, minute=59)) - assert_equal(date_T.asfreq('S', "BEFORE"), date_T_to_S_before) - assert_equal(date_T.asfreq('S', "AFTER"), date_T_to_S_after) + date_T_to_A = dWrap(Date(freq='A', year=2007)) + date_T_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_T_to_M = dWrap(Date(freq='M', year=2007, month=1)) + date_T_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) + date_T_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) + 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, + hour=0, minute=0, second=0)) + 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) + assert_func(date_T_end_of_year.asfreq('A'), date_T_to_A) + assert_func(date_T.asfreq('Q'), date_T_to_Q) + assert_func(date_T_end_of_quarter.asfreq('Q'), date_T_to_Q) + assert_func(date_T.asfreq('M'), date_T_to_M) + assert_func(date_T_end_of_month.asfreq('M'), date_T_to_M) + assert_func(date_T.asfreq('W'), date_T_to_W) + assert_func(date_T_end_of_week.asfreq('W'), date_T_to_W) + assert_func(date_T.asfreq('D'), date_T_to_D) + assert_func(date_T_end_of_day.asfreq('D'), date_T_to_D) + assert_func(date_T.asfreq('B'), date_T_to_B) + assert_func(date_T_end_of_bus.asfreq('B'), date_T_to_B) + assert_func(date_T.asfreq('H'), date_T_to_H) + assert_func(date_T_end_of_hour.asfreq('H'), date_T_to_H) + + assert_func(date_T.asfreq('S', "BEFORE"), date_T_to_S_before) + assert_func(date_T.asfreq('S', "AFTER"), date_T_to_S_after) + + def test_conv_secondly(self): "frequency conversion tests: from Secondly Frequency" - date_S = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=0) - date_S_end_of_year = Date(freq='S', year=2007, month=12, day=31, - hour=23, minute=59, second=59) - date_S_end_of_quarter = Date(freq='S', year=2007, month=3, day=31, - hour=23, minute=59, second=59) - date_S_end_of_month = Date(freq='S', year=2007, month=1, day=31, - hour=23, minute=59, second=59) - date_S_end_of_week = Date(freq='S', year=2007, month=1, day=7, - hour=23, minute=59, second=59) - date_S_end_of_day = Date(freq='S', year=2007, month=1, day=1, - hour=23, minute=59, second=59) - date_S_end_of_bus = Date(freq='S', year=2007, month=1, day=1, - hour=23, minute=59, second=59) - date_S_end_of_hour = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=59, second=59) - date_S_end_of_minute = Date(freq='S', year=2007, month=1, day=1, - hour=0, minute=0, second=59) + for dWrap, assert_func in self.dateWrap: + 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, + hour=23, minute=59, second=59)) + 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, + hour=23, minute=59, second=59)) + 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, + hour=23, minute=59, second=59)) + 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, + hour=0, minute=59, second=59)) + 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)) + date_S_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + date_S_to_M = dWrap(Date(freq='M', year=2007, month=1)) + 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, + hour=0)) + 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) + assert_func(date_S_end_of_year.asfreq('A'), date_S_to_A) + assert_func(date_S.asfreq('Q'), date_S_to_Q) + assert_func(date_S_end_of_quarter.asfreq('Q'), date_S_to_Q) + assert_func(date_S.asfreq('M'), date_S_to_M) + assert_func(date_S_end_of_month.asfreq('M'), date_S_to_M) + assert_func(date_S.asfreq('W'), date_S_to_W) + assert_func(date_S_end_of_week.asfreq('W'), date_S_to_W) + assert_func(date_S.asfreq('D'), date_S_to_D) + assert_func(date_S_end_of_day.asfreq('D'), date_S_to_D) + assert_func(date_S.asfreq('B'), date_S_to_B) + assert_func(date_S_end_of_bus.asfreq('B'), date_S_to_B) + assert_func(date_S.asfreq('H'), date_S_to_H) + 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) - date_S_to_A = Date(freq='A', year=2007) - date_S_to_Q = Date(freq='Q', year=2007, quarter=1) - date_S_to_M = Date(freq='M', year=2007, month=1) - date_S_to_W = Date(freq='W', year=2007, month=1, day=7) - date_S_to_D = Date(freq='D', year=2007, month=1, day=1) - date_S_to_B = Date(freq='B', year=2007, month=1, day=1) - date_S_to_H = Date(freq='H', year=2007, month=1, day=1, - hour=0) - date_S_to_T = Date(freq='T', year=2007, month=1, day=1, - hour=0, minute=0) - - assert_equal(date_S.asfreq('A'), date_S_to_A) - assert_equal(date_S_end_of_year.asfreq('A'), date_S_to_A) - assert_equal(date_S.asfreq('Q'), date_S_to_Q) - assert_equal(date_S_end_of_quarter.asfreq('Q'), date_S_to_Q) - assert_equal(date_S.asfreq('M'), date_S_to_M) - assert_equal(date_S_end_of_month.asfreq('M'), date_S_to_M) - assert_equal(date_S.asfreq('W'), date_S_to_W) - assert_equal(date_S_end_of_week.asfreq('W'), date_S_to_W) - assert_equal(date_S.asfreq('D'), date_S_to_D) - assert_equal(date_S_end_of_day.asfreq('D'), date_S_to_D) - assert_equal(date_S.asfreq('B'), date_S_to_B) - assert_equal(date_S_end_of_bus.asfreq('B'), date_S_to_B) - assert_equal(date_S.asfreq('H'), date_S_to_H) - assert_equal(date_S_end_of_hour.asfreq('H'), date_S_to_H) - assert_equal(date_S.asfreq('T'), date_S_to_T) - assert_equal(date_S_end_of_minute.asfreq('T'), date_S_to_T) - class test_methods(NumpyTestCase): "Base test class for MaskedArrays." From scipy-svn at scipy.org Tue Jan 30 14:08:49 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 13:08:49 -0600 (CST) Subject: [Scipy-svn] r2643 - trunk/Lib/sandbox/timeseries Message-ID: <20070130190849.60A0239C1DE@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 13:08:46 -0600 (Tue, 30 Jan 2007) New Revision: 2643 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: modified convert function to pass integer frequencies to c code Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 18:40:43 UTC (rev 2642) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 19:08:46 UTC (rev 2643) @@ -523,6 +523,14 @@ containing the indices of the non-zero elements in that dimension.""" return self._series.nonzero() +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 ... ##### -------------------------------------------------------------------------- @@ -1117,7 +1125,7 @@ if position.upper() not in ('END','START'): raise ValueError("invalid value for position argument: (%s)",str(position)) - toFreq = corelib.fmtFreq(freq) + toFreq = corelib.check_freq(freq) fromFreq = series.freq start_date = series._dates[0] @@ -1180,7 +1188,7 @@ freq = A) """ #Backup series attributes - options = dict(fill_value=series.fill_value, observed=series.observed) + options = _attrib_dict(series) newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if copy: From scipy-svn at scipy.org Tue Jan 30 14:30:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 13:30:01 -0600 (CST) Subject: [Scipy-svn] r2644 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070130193001.2658839C185@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 13:29:57 -0600 (Tue, 30 Jan 2007) New Revision: 2644 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added tests for convert function Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-30 19:08:46 UTC (rev 2643) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-30 19:29:57 UTC (rev 2644) @@ -292,6 +292,49 @@ 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. + """ + lowFreqSeries = time_series(N.arange(10), + 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, + (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER")) + + assert_equal(lowToHigh_start._mask[0], False) + 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')) + # def test_maskperiod(self): "Test mask_period" From scipy-svn at scipy.org Tue Jan 30 15:02:41 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:02:41 -0600 (CST) Subject: [Scipy-svn] r2645 - trunk/Lib/sandbox/timeseries Message-ID: <20070130200241.E384139C08B@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:02:40 -0600 (Tue, 30 Jan 2007) New Revision: 2645 Added: trunk/Lib/sandbox/timeseries/reportlib.py Log: Added a file remotely Added: trunk/Lib/sandbox/timeseries/reportlib.py =================================================================== --- trunk/Lib/sandbox/timeseries/reportlib.py 2007-01-30 19:29:57 UTC (rev 2644) +++ trunk/Lib/sandbox/timeseries/reportlib.py 2007-01-30 20:02:40 UTC (rev 2645) @@ -0,0 +1,257 @@ +""" +Reporting functions + +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknow_ca_at_hotmail_dot_com +:version: $Id: tdates.py 2641 2007-01-30 18:40:17Z mattknox_ca $ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: mattknox_ca $)" +__version__ = '1.0' +__revision__ = "$Revision: 2641 $" +__date__ = '$Date: 2007-01-30 13:40:17 -0500 (Tue, 30 Jan 2007) $' + +import cStringIO,operator, types +import tseries as ts +import tdates as td + +__all__ = [ + 'report', 'wrap_onspace', 'wrap_onspace_strict', + 'wrap_always'] + +class fmtfunc_wrapper: + """wraps a formatting function such that it handles masked values + +:IVariables: + - `fmtfunc` : formatting function. + - `mask_rep` : string to use for masked values + """ + def __init__ (self, fmtfunc, mask_rep): + self.f = fmtfunc + self.mr = mask_rep + + def __call__ (self, item): + "Execute the call behavior." + + if hasattr(item, "_mask") and item._mask: + return self.mr + else: + return self.f(item) + + + +def report(*tseries, **kwargs): + """generate a table report of *tseries with dates in the left column. + +:Parameters: + - `*tseries` : time series objects. Must all be at the same frequency, but + do not need to be aligned. + - `dates` (DateArray, *[None]*) : dates at which values of all the series + will be output. If not specified, data will be output from the minimum + start_date to the maximum end_date of all the time series objects + - `header_row` (list, *[None]*) : optional list of column headers. Length + must be equal to len(tseries) (no date column header specified) or + len(tseries)+1 (first header is assumed to be date column header) + - `header_char` : Character to be used for the row separator line + - `justify` (List of strings or single string, *[None]*) : Determines how are + data justified in their column. If not specified, the date column and string + columns are left justified, and everything else is right justified. If a + string is specified, it must be one of 'left', 'right', or 'center' and all + columns will be justified the same way. If a list is specified, each column + will be justified according to the specification for that column in the list + (specifying the justification for the date column is optional). + - `prefix` (string, *['']*) : A string prepended to each printed row. + - `postfix` (string, *['']*) : A string appended to each printed row. + - `mask_rep` (string, *['--']*): String used to represent masked values in + output + - `datefmt` (string, *[None]*) : Formatting string used for displaying the + dates in the date column. If None, str() is simply called on the dates + - `fmtfunc` (List of functions or single function, *[None]*) : A function or + list of functions for formatting each data column in the report. If not + specified, str() is simply called on each item. If a list of functions is + provided, there must be exactly one function for each column + - `wrapfunc` (function, *[lambda x:x]*): A function f(text) for wrapping text; + each element in the table is first wrapped by this function. Useful functions + for this are wrap_onspace, wrap_onspace_strict, and wrap_always (which are + part of this module). Eg wrapfunc=lambda x: wrap_onspace(x, 10) + +:Examples: + + import numpy as np + import timeseries as ts + from timeseries import report, wrap_onspace + + series1 = ts.time_series(np.random.uniform(-100,100,15), start_date=ts.thisday('b')-15) + series2 = ts.time_series(np.random.uniform(-100,100,13), start_date=ts.thisday('b')-10) + series3 = ts.time_series(['string1', 'another string', 'yet another string']*3, start_date=ts.thisday('b')-10) + + darray = ts.date_array(start_date=ts.thisday('b')-8, end_date=ts.thisday('b')-3) + + # print all values of series1 and series2 and show 2 decimal places. + # show masked values as "N/A" + print report(series1, series2, fmtfunc=lambda x:'%.2f' % x, mask_rep='N/A') + + # same thing, but format one column one with 2 decimal places, and column two with 4 + print report(series1, series2, fmtfunc=[(lambda x:'%.2f' % x), (lambda x:'%.4f' % x)], mask_rep='N/A') + + # print an html table of the data over a specified range + print "
" + \ + report(series1, series2, series3, dates=darray, + delim="") + \ + "
", prefix="
", postfix="
" + + # print a table with columns 10 characters wide when possible, but don't break up a word + print r.report(series1, series3, series2, wrapfunc=lambda x: wrap_onspace(x, 10))""" + + dates = kwargs.pop('dates', None) + header_row = kwargs.pop('header_row', None) + header_char = kwargs.pop('header_char', '-') + delim = kwargs.pop('delim', ' | ') + justify = kwargs.pop('justify', None) + prefix = kwargs.pop('prefix', '') + postfix = kwargs.pop('postfix', '') + mask_rep = kwargs.pop('mask_rep', '--') + datefmt = kwargs.pop('datefmt', None) + fmtfunc = kwargs.pop('fmtfunc', str) + + if type(fmtfunc) != types.ListType: + fmtfunc = [fmtfunc_wrapper(fmtfunc, mask_rep)]*len(tseries) + else: + fmtfunc = [fmtfunc_wrapper(f, mask_rep) for f in fmtfunc] + + wrapfunc = kwargs.pop('wrapfunc', lambda x:x) + + if len(kwargs) > 0: + raise KeyError("Unrecognized keyword(s): %s" % (", ".join(kwargs.keys()))) + + if header_row is not None: + hasHeader=True + if len(header_row) == len(tseries)+1: + # label for date column included + rows = [header_row] + elif len(header_row) == len(tseries): + # label for date column not included + rows = [['']+header_row] + else: + hasHeader=False + rows=[] + + if justify is not None: + if type(justify) == types.StringType: + # justify all columns the the same way + justify = [justify for x in range(len(tseries)+1)] + else: #assume it is a list or tuple, etc + if len(justify) == len(tseries): + # justification for date column not included, so set that + # to left by default + justify = ['left'] + justify + else: + # default column justification + justify = ['left'] + for ser in tseries: + if str(ser.dtype)[:2] == '|S': justify.append('left') + else: justify.append('right') + + + if datefmt is None: + def datefmt_func(date): return str(date) + else: + def datefmt_func(date): return date.strfmt(datefmt) + + tseries = ts.align_series(*tseries) + + if dates is None: + dates = td.date_array(start_date=tseries[0].start_date, + end_date=tseries[0].end_date) + + for d in dates: + rows.append([datefmt_func(d)]+[fmtfunc[i](ser[d]) for i, ser in enumerate(tseries)]) + + return indent(rows, hasHeader=hasHeader, headerChar=header_char, + delim=delim, justify=justify, separateRows=False, + prefix=prefix, postfix=postfix, wrapfunc=wrapfunc) + + + + +# written by George Sakkis +# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662 +def indent(rows, hasHeader=False, headerChar='-', delim=' | ', justify=None, + separateRows=False, prefix='', postfix='', wrapfunc=lambda x:x): + """Indents a table by column. + - rows: A sequence of sequences of items, one sequence per row. + - hasHeader: True if the first row consists of the columns' names. + - headerChar: Character to be used for the row separator line + (if hasHeader==True or separateRows==True). + - delim: The column delimiter. + - justify: Determines how are data justified in their column. + Valid values are 'left','right' and 'center'. + - separateRows: True if rows are to be separated by a line + of 'headerChar's. + - prefix: A string prepended to each printed row. + - postfix: A string appended to each printed row. + - wrapfunc: A function f(text) for wrapping text; each element in + the table is first wrapped by this function.""" + + + def rowWrapper(row): + newRows = [wrapfunc(item).split('\n') for item in row] + return [[substr or '' for substr in item] for item in map(None,*newRows)] + # break each logical row into one or more physical ones + logicalRows = [rowWrapper(row) for row in rows] + # columns of physical rows + columns = map(None,*reduce(operator.add,logicalRows)) + numCols = len(columns) + colNums = list(range(numCols)) + + if justify is None: + justify = ['left' for x in range(numCols)] + + # get the maximum of each column by the string length of its items + maxWidths = [max([len(str(item)) for item in column]) for column in columns] + rowSeparator = headerChar * (len(prefix) + len(postfix) + sum(maxWidths) + \ + len(delim)*(len(maxWidths)-1)) + # select the appropriate justify method + justify_funcs = {'center':str.center, 'right':str.rjust, 'left':str.ljust} + + + output=cStringIO.StringIO() + if separateRows: print >> output, rowSeparator + for physicalRows in logicalRows: + for row in physicalRows: + print >> output, \ + prefix \ + + delim.join([justify_funcs[justify[colNum].lower()](str(item),width) for (colNum,item,width) in zip(colNums,row,maxWidths)]) \ + + postfix + if separateRows or hasHeader: print >> output, rowSeparator; hasHeader=False + return output.getvalue() + +# written by Mike Brown +# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/148061 +def wrap_onspace(text, width): + """ + A word-wrap function that preserves existing line breaks + and most spaces in the text. Expects that existing line + breaks are posix newlines (\n). + """ + return reduce(lambda line, word, width=width: '%s%s%s' % + (line, + ' \n'[(len(line[line.rfind('\n')+1:]) + + len(word.split('\n',1)[0] + ) >= width)], + word), + text.split(' ') + ) + +import re +def wrap_onspace_strict(text, width): + """Similar to wrap_onspace, but enforces the width constraint: + words longer than width are split.""" + wordRegex = re.compile(r'\S{'+str(width)+r',}') + return wrap_onspace(wordRegex.sub(lambda m: wrap_always(m.group(),width),text),width) + +import math +def wrap_always(text, width): + """A simple word-wrap function that wraps text on exactly width characters. + It doesn't split the text in words.""" + return '\n'.join([ text[width*i:width*(i+1)] \ + for i in xrange(int(math.ceil(1.*len(text)/width))) ]) From scipy-svn at scipy.org Tue Jan 30 15:02:54 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:02:54 -0600 (CST) Subject: [Scipy-svn] r2646 - trunk/Lib/sandbox/timeseries Message-ID: <20070130200254.E83E439C08B@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:02:53 -0600 (Tue, 30 Jan 2007) New Revision: 2646 Removed: trunk/Lib/sandbox/timeseries/io/ Log: Removed file/folder From scipy-svn at scipy.org Tue Jan 30 15:03:39 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:03:39 -0600 (CST) Subject: [Scipy-svn] r2647 - trunk/Lib/sandbox/timeseries Message-ID: <20070130200339.393FA39C08B@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:03:36 -0600 (Tue, 30 Jan 2007) New Revision: 2647 Modified: trunk/Lib/sandbox/timeseries/__init__.py Log: added report functions Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-01-30 20:02:53 UTC (rev 2646) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-01-30 20:03:36 UTC (rev 2647) @@ -6,6 +6,8 @@ :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$" @@ -19,8 +21,11 @@ from tseries import * import tmulti from tmulti import * +import reportlib +from reportlib import * -__all__ = ['tdates', 'tseries','tmulti'] +__all__ = ['tdates', 'tseries','tmulti','reportlib'] __all__ += tdates.__all__ __all__ += tseries.__all__ -__all__ += tmulti.__all__ \ No newline at end of file +__all__ += tmulti.__all__ +__all__ += reportlib.__all__ From scipy-svn at scipy.org Tue Jan 30 15:22:52 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:22:52 -0600 (CST) Subject: [Scipy-svn] r2648 - trunk/Lib/sandbox/timeseries Message-ID: <20070130202252.5B6FA39C1E2@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:22:48 -0600 (Tue, 30 Jan 2007) New Revision: 2648 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: changed check_freq call to freq_revdict Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 20:03:36 UTC (rev 2647) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 20:22:48 UTC (rev 2648) @@ -458,7 +458,7 @@ if date.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") - fromfreq = corelib.check_freq('D') + fromfreq = corelib.freq_revdict['D'] else: fromfreq = date.freq From scipy-svn at scipy.org Tue Jan 30 15:27:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:27:38 -0600 (CST) Subject: [Scipy-svn] r2649 - trunk/Lib/sandbox/timeseries Message-ID: <20070130202738.6A37239C0C9@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:27:29 -0600 (Tue, 30 Jan 2007) New Revision: 2649 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: changed another check_freq call to use freq_revdict instead Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 20:22:48 UTC (rev 2648) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 20:27:29 UTC (rev 2649) @@ -650,7 +650,7 @@ return self if self.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") - fromfreq = corelib.check_freq('D') + fromfreq = corelib.freq_revdict['D'] else: fromfreq = self.freq _rel = relation.upper()[0] From scipy-svn at scipy.org Tue Jan 30 15:30:44 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:30:44 -0600 (CST) Subject: [Scipy-svn] r2650 - trunk/Lib/sandbox/timeseries Message-ID: <20070130203044.B1A1039C0C9@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:30:38 -0600 (Tue, 30 Jan 2007) New Revision: 2650 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: changed check_freq call to use freq_revdict. Fixed bug with fill_missing_dates Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 20:27:29 UTC (rev 2649) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 20:30:38 UTC (rev 2650) @@ -178,7 +178,7 @@ cls._defaultdates = newdates # Check frequency...... if freq is not None: - freq = corelib.check_freq(freq)[0] + freq = corelib.check_freq(freq) if freq != newdates.freq: _dates = newdates.tofreq(freq) else: @@ -1227,7 +1227,7 @@ `fill_value` : float *[None]* Default value for missing data. If None, the data are just masked. """ - (freq, freqstr) = corelib.check_freq(freq) + (freq, freqstr) = corelib.check_freq(freq), corelib.check_freqstr(freq) if freqstr == 'U': raise ValueError,\ "Unable to define a proper date resolution (found %s)." % freqstr From scipy-svn at scipy.org Tue Jan 30 15:39:49 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:39:49 -0600 (CST) Subject: [Scipy-svn] r2651 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070130203949.60D1A39C08B@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:39:45 -0600 (Tue, 30 Jan 2007) New Revision: 2651 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: added tests for fill_missing_dates Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-30 20:30:38 UTC (rev 2650) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-30 20:39:45 UTC (rev 2651) @@ -27,9 +27,9 @@ from timeseries import tseries #reload(tseries) -from timeseries.tseries import Date, date_array_fromlist +from timeseries.tseries import Date, date_array_fromlist, date_array from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, \ - mask_period, align_series + mask_period, align_series, fill_missing_dates class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -334,6 +334,22 @@ 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')) + + 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): From scipy-svn at scipy.org Tue Jan 30 15:52:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 14:52:15 -0600 (CST) Subject: [Scipy-svn] r2652 - in trunk/Lib/sandbox/timeseries: archived_version examples Message-ID: <20070130205215.DD0DA39C1DA@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 14:52:09 -0600 (Tue, 30 Jan 2007) New Revision: 2652 Added: trunk/Lib/sandbox/timeseries/archived_version/plotting.py Removed: trunk/Lib/sandbox/timeseries/examples/plotting.py Log: Moved remotely Copied: trunk/Lib/sandbox/timeseries/archived_version/plotting.py (from rev 2651, trunk/Lib/sandbox/timeseries/examples/plotting.py) Deleted: trunk/Lib/sandbox/timeseries/examples/plotting.py =================================================================== --- trunk/Lib/sandbox/timeseries/examples/plotting.py 2007-01-30 20:39:45 UTC (rev 2651) +++ trunk/Lib/sandbox/timeseries/examples/plotting.py 2007-01-30 20:52:09 UTC (rev 2652) @@ -1,28 +0,0 @@ -import pylab as pl -import timeseries as ts -import timeseries.plotlib as tpl -import numpy as np - -numPoints = 100 -freq = 'b' - -y_ts1 = ts.TimeSeries(100*np.cumprod(1 + np.random.normal(size=numPoints)/100), freq=freq, start_date=ts.thisday(freq)-numPoints) -y_ts2 = ts.TimeSeries(100*np.cumprod(1 + np.random.normal(size=numPoints)/100), freq=freq, start_date=ts.thisday(freq)-numPoints) - -y_ts1, y_ts2 = ts.aligned(y_ts1, y_ts2) - -sDate, eDate = y_ts1.start_date(), y_ts1.end_date() -dAxis = tpl.DateAxis(sDate, eDate) - -pl.clf() - -a = pl.subplot(1,1,1) -a.plot(dAxis.xaxis, y_ts1, '-', dAxis.xaxis, y_ts2, '-') -dAxis.set_labels(a) - -#a.set_xlim(dAxis.xaxis[0], dAxis.xaxis[-1]) - -pl.title('Time Series Plot') -pl.show() - - From scipy-svn at scipy.org Tue Jan 30 16:11:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 15:11:13 -0600 (CST) Subject: [Scipy-svn] r2653 - in trunk/Lib/sandbox/timeseries: . examples tests Message-ID: <20070130211113.815B539C1EA@new.scipy.org> Author: pierregm Date: 2007-01-30 15:11:09 -0600 (Tue, 30 Jan 2007) New Revision: 2653 Modified: trunk/Lib/sandbox/timeseries/examples/example.wiki trunk/Lib/sandbox/timeseries/tdates.py trunk/Lib/sandbox/timeseries/tests/test_dates.py trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py trunk/Lib/sandbox/timeseries/tmulti.py trunk/Lib/sandbox/timeseries/tseries.py Log: removed outdated comments Modified: trunk/Lib/sandbox/timeseries/examples/example.wiki =================================================================== --- trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-30 20:52:09 UTC (rev 2652) +++ trunk/Lib/sandbox/timeseries/examples/example.wiki 2007-01-30 21:11:09 UTC (rev 2653) @@ -1,287 +1,2 @@ - -== Requirements == - -In order to use the `TimeSeries` package, you need to have the foloowing packages installed: - * `numpy` - * `maskedarray` : the new implementation where masked arrays are subclasses of regular ndarrays. You can find this version in the sandbox on the scipy SVN server - * `mx.DateTime` : This external module is needed to process some of the dates in C. At term, we hope to be able to get rid of it. In the meanwhile, sorry for the inconvenience. - - -The `TimeSeries` package is organized as a group of modules. Two modules are especially useful: `tdates` for managing `Date` and `DateArray` objects, and `tseries`, for managing time series. -{{{#!python numbers=disable ->>> import numpy as N ->>> import maskedarray as MA ->>> import mx.DateTime ->>> import datetime ->>> import tseries as TS ->>> import tdates as TD -}}} -Note that you could also just import the generic `timeseries` package to achieve the same results. - - -== Dates == - -A `Date` object combines some date and/or time related information with a given frequency. You can picture the frequency as the unit into which the date is expressed. For example, the three objects: -{{{#!python numbers=disable ->>> D = TD.Date(freq='D', year=2007, month=1, day=1) ->>> M = TD.Date(freq='M', year=2007, month=1, day=1) ->>> Y = TD.Date(freq='A', year=2007, month=1, day=1) -}}} -use the same date information, but different frequencies. They correspond to to the day 'Jan. 01, 2007', the month 'Jan. 2007' and the year '2007', respectively. The importance of the frequency will become clearer later on. -~- A more technical note: `Date` objects are internally stored as integers. The conversion to integers and back is controlled by the frequency. In the example above, the internal representation of the three objects `D`, `M` and `Y` are 732677, 24073 and 2007, respectively. -~ - -==== Construction of a `Date` object ==== -Several options are available to construct a Date object explicitly. In each case, the `frequency` argument must be given. - - * Give appropriate values to any of the `year`, `month`, `day`, `quarter`, `hours`, `minutes`, `seconds` arguments. -{{{#!python numbers=disable ->>> 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 the documentation of this latter. -{{{#!python numbers=disable ->>> TD.Date('D', string='2007-01-01') - -}}} - - * Use the `mxDate` keyword with an existing `mx.DateTime.DateTime` object, or even a `datetime.datetime` object. -{{{#!python numbers=disable ->>> TD.Date('D', mxDate=mx.DateTime.now()) ->>> TD.Date('D', mxDate=datetime.datetime.now()) -}}} - - -==== Manipulating dates ==== - -You can add and subtract integers from a `Date` object to get a new `Date` object. The frequency of the new object is the same as the roginal one. For example: -{{{#!python numbers=disable ->>> mybirthday = D-1 - ->>> infivemonths = M + 5 - -}}} - -You can convert a `Date` object from one frequency to another with the `asfreq` method. When converting to a higher frequency (for example, from monthly to daily), the new object will fall on the earliest date possible by default. Thus, if you convert a daily `Date` to a monthly one and back to a daily one, you will lose your day information in the process: -{{{#!python numbers=disable ->>> mybirthday.asfreq('M') - ->>> mybirthday.asfreq('M').asfreq('D') - -}}} - -Some other methods worth mentioning are: - * `toordinal` : converts an object to the equivalent proleptic gregorian date - * `tostring` : converts an object to the corresponding string. - ----- - -== DateArray objects == - -DateArrays are simply ndarrays of `Date` objects. They accept the same methods as a `Date` object, with the addition of: - * `tovalue` : converts the array to an array of integers. Each integer is the internal representation of the corresponding date - * `has_missing_dates` : outputs a boolean on whether some dates are missing or not. - * `has_duplicated_dates` : outputs a boolean on whether some dates are duplicated or not. - -==== Construction ==== - -To construct a `DateArray` object, you can call the class directly -{{{#!python numbers=disable -DateArray(dates=None, freq='U', copy=False) -}}} -where `dates` can be ''(i)'' an existing `DateArray`; ''(ii)'' a sequence of `Date` objects; ''(iii)''' a sequence of objects that `Date` can recognize (such as strings, integers, `mx.DateTime` objects...). -Alternatively, you can use the `date_array` constructor: -{{{#!python numbers=disable -date_array(dlist=None, start_date=None, end_date=None, - include_last=True, length=None, freq=None) -}}} -If `dlist` is None, a new list of dates will be created from `start_date` and `end_date`. You should set `include_last` to True if you want `end_date` to be included. If `end_date` is None, then a series of length `length` will be created. - - ----- - -== TimeSeries == - -A `TimeSeries` object is the combination of three ndarrays: - * `dates`: DateArray object. - * `data` : ndarray. - * `mask` : Boolean ndarray, indicating missing or invalid data. -These three arrays can be accessed as attributes of a TimeSeries object. Another very useful attribute is `series`, that gives you the possibility to directly access `data` and `mask` as a masked array. - -==== Construction ==== - -To construct a TimeSeries, you can use the class constructor: - -{{{#!python numbers=disable -TimeSeries(data, dates=None, mask=nomask, - freq=None, observed=None, start_date=None, - dtype=None, copy=False, fill_value=None, - keep_mask=True, small_mask=True, hard_mask=False) -}}} -where `data` is a sequence, a ndarray or a MaskedArray. If `dates` is None, a DateArray of the same length as the data is constructed at a `freq` frequency, starting at `start_date`. - -Alternatively, you can use the `time_series` function: -{{{#!python numbers=disable -time_series(data, dates=None, freq=None, - start_date=None, end_date=None, length=None, include_last=True, - mask=nomask, dtype=None, copy=False, fill_value=None, - keep_mask=True, small_mask=True, hard_mask=False) -}}} - -Let us construct a series of 600 random elements, starting 600 business days ago, at a business daily frequency -{{{#!python numbers=disable ->>> data = N.random.uniform(-100,100,600) ->>> today = TD.thisday('B') ->>> series = TS.time_series(data, dtype=N.float_, freq='B', observed='SUMMED', ->>> start_date=today-600) -}}} -We can check that `series.dates` is a `DateArray` object and that `series.series` is a `MaskedArray` object. -{{{#!python numbers=disable ->>> isinstance(series.dates, TD.DateArray) -True ->>> isinstance(series.series, MA.MaskedArray) -True -}}} -So, if you are already familiar with `MaskedArray`, using `TimeSeries` should be straightforward. Just keep in mind that another attribute is always present, `dates`. - - -==== Indexing ==== - -Elements of a TimeSeries can be accessed just like with regular ndarrrays. Thus, -{{{#!python numbers=disable ->>> series[0] -}}} -outputs the first element, while -{{{#!python numbers=disable ->>> series[-30:] -}}} -outputs the last 30 elements. - -But you can also use a date: -{{{#!python numbers=disable ->>> thirtydaysago = today - 30 ->>> series[thirtydaysago:] -}}} -or even a string... -{{{#!python numbers=disable ->>> series[thirtydaysago.tostring():] -}}} -or a sequence/ndarray of integers... -{{{#!python numbers=disable ->>> series[[0,-1]] -}}} -~-This latter is quite useful: it gives you the first and last data of your series.-~ - -In a similar way, setting elements of a TimeSeries works seamlessly. -Let us set negative values to zero... -{{{#!python numbers=disable ->>> series[series<0] = 0 -}}} -... and the values falling on Fridays to 100 -{{{#!python numbers=disable ->>> series[series.day_of_week == 4] = 100 -}}} -Note that we could also create a temporary array of 'day_of weeks' for the -corresponding period, and use it as condition. -{{{#!python numbers=disable ->>> weekdays = TD.day_of_week(series) ->>> series[weekdays == 4] = 100 -}}} -You should keep in mind that TimeSeries are basically MaskedArrays. If some data are masked, you will not be able to use a condition as index, you will have to fill the data first. - -==== Operations on TimeSeries ==== - -If you work with only one TimeSeries, you can use regular commands to process the data. For example: -{{{#!python numbers=disable ->>> series_log = N.log(series) -}}} -Note that invalid values (negative, in that case), are automatically masked. Note also that you could use the corresponding function of the `maskedarray` module. This latter approach is actually recommended when you want to use the `reduce` and `accumulate` methods of some ufuncs (such as add or multiply). ~-The reason is that the methods of the numpy.ufuncs do not communicate well with subclasses: as they do not call the `__array_wrap__` method, there is no postprocessing.-~ - -When working with multiple series, only series of the same frequency, size and starting date can be used in basic operations. The function `align_series` ~-(or its alias `aligned`)-~ forces series to have matching starting and ending dates. By default, the starting date will be set to the smallest starting date of the series, and the ending date to the largest. - -Let's construct a list of months, starting on Jan 2005 and ending on Dec 2006, with a gap from Oct 2005 to Dec 2006. -{{{#!python numbers=disable ->>> mlist_1 = ['2005-%02i' % i for i in range(1,10)] ->>> mlist_1 += ['2006-%02i' % i for i in range(2,13)] ->>> mdata_1 = N.arange(len(mlist_1)) ->>> mser_1 = TS.time_series(mdata_1, mlist_1, observed='SUMMED') -}}} -Note that the frequency is 'U', for undefined. In fact, you have to specify what kind of data is actually missing by forcing a given frequency. -{{{#!python numbers=disable ->>> mser = mser_1.asfreq('M') -}}} -Let us check whether there are some duplicated dates (no): -{{{#!python numbers=disable ->>> mser_1.has_duplicated_dates() -False -}}} -...or missing dates (yes): -{{{#!python numbers=disable ->>> mser_1.has_missing_dates() -True -}}} - - -Let us construct a second monthly series, this time without missing dates -{{{#!python numbers=disable ->>> mlist_2 = ['2004-%02i' % i for i in range(1,13)] ->>> mlist_2 += ['2005-%02i' % i for i in range(1,13)] ->>> mser_2 = TS.time_series(N.arange(len(mlist_2)), mlist_2, observed='SUMMED') -}}} -Let's try to add the two series: -{{{#!python numbers=disable ->>> mser_3 = mser_1 + mser_2 -}}} -That doesn't work, as the series have different starting dates. We need to align them first. -{{{#!python numbers=disable ->>> (malg_1,malg_2) = aligned(mser_1, mser_2) -}}} -That still doesnt' work, as `malg_1` has missing dates. Let us fill it, then: data falling on a date that was missing will be masked. -{{{#!python numbers=disable ->>> mser_1_filled = fill_missing_dates(mser_1) ->>> (malg_1,malg_2) = align_series(mser_1_filled, mser_2) -}}} -Now we can add the two series. Only the data that fall on dates common to the original, non-aligned series will be actually added, the others will be masked. After all, we are adding masked arrays. -{{{#!python numbers=disable ->>> mser_3 = malg_1 + malg_2 -}}} -We could have filled the initial series first: -{{{#!python numbers=disable ->>> mser_3 = filled(malg_1,0) + filled(malg_2,0) -}}} -When aligning the series, we could have forced the series to start/end at some given dates: -{{{#!python numbers=disable ->>> (malg_1,malg_2) = aligned(mser_1_filled, mser2, ->>> start_date='2004-06', end_date='2006-06') -}}} - - -==== TimeSeries Conversion ==== - -To convert a TimeSeries to another frequency, use the `convert` method or function. The optional argument `func` must be a function that acts on a 1D masked array and returns a scalar. -{{{#!python numbers=disable ->>> mseries = series.convert('M',func=ma.average) -}}} -If `func` is not specified, the default value `'auto'` is used instead. In that case, -the conversion function is estimated from the `observed` attribute of the series. -For example, if `observed='SUMMED'`, then `func='auto'` is in fact `func=sum`. -{{{#!python numbers=disable ->>> mseries_default = series.convert('M') -}}} -If `func` is None, the convert method/function returns a 2D array, where each row corresponds to the new frequency, and the columns to the original data. In our example, `convert` will return a 2D array with 23 columns, as there are at most 23 business days per month. -{{{#!python numbers=disable ->>> mseries_2d = series.convert('M',func=None) -}}} -When converting from a lower frequency to a higher frequency, an extra argument `position` is required. The value of the argument is either 'START' or 'END', and determines where the data point will be placed in the period. In the future, interpolation methods will be supported to fill in the resulting masked values. - -Let us create a second series, this time with a monthly frequency, starting 110 months ago. -{{{#!python numbers=disable ->>> data = N.random.uniform(-100,100,100).astype(np.float_) ->>> today = TS.today.asfreq('M') - 110 ->>> nseries = TS.TimeSeries(data, freq='m', observed='END',start_date=today) ->>> sixtymonthsago = today-60 ->>> nseries[sixtymonthsago:sixtymonthsago+10] = 12 -}}} - +The page can be accessed at: +http://www.scipy.org/TimeSeriesPackage \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 20:52:09 UTC (rev 2652) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-01-30 21:11:09 UTC (rev 2653) @@ -470,7 +470,6 @@ return Date(freq=tofreq, value=value) else: return None - Date.asfreq = asfreq def isDate(data): @@ -697,14 +696,9 @@ if self.__hasdups is None: self.__hasdups = (steps.min() == 0) else: -# elif val.size == 1: self.__full = True self.__hasdups = False steps = numeric.array([], dtype=int_) -# else: -# self.__full = False -# self.__hasdups = False -# steps = None self.__steps = steps return self.__steps @@ -855,17 +849,9 @@ # Case #3: dates as objects ................. elif dlist.dtype.kind == 'O': template = dlist[0] -# if dlist.size > 1: -# template = dlist[0] -# else: -# template = dlist.item() #...as Date objects if isinstance(template, Date): dates = numpy.fromiter((d.value for d in dlist), int_) -# if dlist.size > 1: -# dates = numpy.fromiter((d.value for d in dlist), int_) -# else: -# dates = [template] #...as mx.DateTime objects elif hasattr(template,'absdays'): # no freq given: try to guess it from absdays @@ -904,7 +890,6 @@ # Case #2: we have a starting date .......... if start_date is None: raise InsufficientDateError -# if not isDateType(start_date): if not isinstance(start_date, Date): raise DateError, "Starting date should be a valid Date instance!" # Check if we have an end_date @@ -914,8 +899,6 @@ else: if not isinstance(end_date, Date): raise DateError, "Ending date should be a valid Date instance!" -# assert(isDateType(end_date), -# "Starting date should be a valid Date instance!") length = end_date - start_date if include_last: length += 1 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 20:52:09 UTC (rev 2652) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-30 21:11:09 UTC (rev 2653) @@ -26,9 +26,9 @@ from maskedarray.testutils import assert_equal, assert_array_equal from timeseries import tdates -reload(tdates) +#reload(tdates) from timeseries import tcore -reload(tcore) +#reload(tcore) from timeseries.tdates import date_array_fromlist, Date, DateArray, date_array, mxDFromString class test_creation(NumpyTestCase): Modified: trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-30 20:52:09 UTC (rev 2652) +++ trunk/Lib/sandbox/timeseries/tests/test_multitimeseries.py 2007-01-30 21:11:09 UTC (rev 2653) @@ -26,17 +26,12 @@ from maskedarray.core import getmaskarray, nomask, masked_array -##reload(MA) -#import maskedarray.mrecords -##reload(maskedarray.mrecords) -#from maskedarray.mrecords import mrecarray, fromarrays, fromtextfile, fromrecords from timeseries import tmulti reload(tmulti) from timeseries.tmulti import MultiTimeSeries, TimeSeries,\ fromarrays, fromtextfile, fromrecords, \ date_array, time_series -#from timeseries.tseries import time_series, TimeSeries #.............................................................................. class test_mrecords(NumpyTestCase): Modified: trunk/Lib/sandbox/timeseries/tmulti.py =================================================================== --- trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-30 20:52:09 UTC (rev 2652) +++ trunk/Lib/sandbox/timeseries/tmulti.py 2007-01-30 21:11:09 UTC (rev 2653) @@ -2,11 +2,11 @@ """ Support for multi-variable time series, through masked recarrays. -:author: Pierre Gerard-Marchant -:contact: pierregm_at_uga_dot_edu +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknow_ca_at_hotmail_dot_com :version: $Id$ """ -__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" __version__ = '1.0' __revision__ = "$Revision$" __date__ = '$Date$' @@ -51,7 +51,6 @@ reserved_fields = MR.reserved_fields + ['_dates'] import warnings -# format='%(name)-15s %(levelname)s %(message)s',) __all__ = [ 'MultiTimeSeries','fromarrays','fromrecords','fromtextfile', @@ -107,11 +106,6 @@ cls._defaulthardmask = data._series._hardmask | hard_mask cls._fill_value = data._series._fill_value return data._data.view(cls) -# elif isinstance(data, TimeSeries): -# cls._defaultfieldmask = data._series._fieldmask -# cls._defaulthardmask = data._series._hardmask | hard_mask -# cls._fill_value = data._series._fill_value - # ....................................... _data = MaskedRecords(data, mask=mask, dtype=dtype, **mroptions) if dates is None: @@ -122,36 +116,30 @@ newdates = date_array(dlist=dates, freq=freq) else: newdates = dates -# _data = data -# if hasattr(data, '_mask') : -# mask = mask_or(data._mask, mask) cls._defaultdates = newdates cls._defaultobserved = observed cls._defaultfieldmask = _data._fieldmask -# assert(_datadatescompat(data,newdates)) # return _data.view(cls) - - #.................................. - def __array_wrap__(self, obj, context=None): - """Special hook for ufuncs. -Wraps the numpy array and sets the mask according to context. - """ -# mclass = self.__class__ - #.......... - if context is None: -# return mclass(obj, mask=self._mask, copy=False) - return MaskedArray(obj, mask=self._mask, copy=False, - dtype=obj.dtype, - fill_value=self.fill_value, ) - #.......... - (func, args) = context[:2] - -# return mclass(obj, copy=False, mask=m) - return MultiTimeSeries(obj, copy=False, mask=m,) -# dtype=obj.dtype, fill_value=self._fill_value) - - +# +# #.................................. +# def __array_wrap__(self, obj, context=None): +# """Special hook for ufuncs. +#Wraps the numpy array and sets the mask according to context. +# """ +## mclass = self.__class__ +# #.......... +# if context is None: +## return mclass(obj, mask=self._mask, copy=False) +# return MaskedArray(obj, mask=self._mask, copy=False, +# dtype=obj.dtype, +# fill_value=self.fill_value, ) +# #.......... +# (func, args) = context[:2] +# +## return mclass(obj, copy=False, mask=m) +# return MultiTimeSeries(obj, copy=False, mask=m,) +## dtype=obj.dtype, fill_value=self._fill_value) def __array_finalize__(self,obj): if isinstance(obj, MultiTimeSeries): self.__dict__.update(_dates=obj._dates, @@ -234,13 +222,11 @@ for k in _names: m = mask_or(val, base_fmask.__getattr__(k)) base_fmask.__setattr__(k, m) - else: - return else: mval = getmaskarray(val) for k in _names: base_fmask.__setattr__(k, mval) - return + return #............................................ def __getitem__(self, indx): """Returns all the fields sharing the same fieldname base. Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 20:52:09 UTC (rev 2652) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-30 21:11:09 UTC (rev 2653) @@ -64,7 +64,6 @@ ] #............................................................................... -# format='%(name)-15s %(levelname)s %(message)s',) ufunc_domain = {} ufunc_fills = {} @@ -1195,7 +1194,6 @@ inidata = series._series.copy() else: inidata = series._series - if nper < 0: nper = max(-len(series), nper) newdata[-nper:] = inidata[:nper] From scipy-svn at scipy.org Tue Jan 30 18:04:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 17:04:00 -0600 (CST) Subject: [Scipy-svn] r2654 - trunk/Lib/sandbox/timeseries Message-ID: <20070130230400.DF77339C079@new.scipy.org> Author: mattknox_ca Date: 2007-01-30 17:03:57 -0600 (Tue, 30 Jan 2007) New Revision: 2654 Modified: trunk/Lib/sandbox/timeseries/reportlib.py Log: added footer capability, and bunch of other changes Modified: trunk/Lib/sandbox/timeseries/reportlib.py =================================================================== --- trunk/Lib/sandbox/timeseries/reportlib.py 2007-01-30 21:11:09 UTC (rev 2653) +++ trunk/Lib/sandbox/timeseries/reportlib.py 2007-01-30 23:03:57 UTC (rev 2654) @@ -38,7 +38,6 @@ return self.f(item) - def report(*tseries, **kwargs): """generate a table report of *tseries with dates in the left column. @@ -51,7 +50,20 @@ - `header_row` (list, *[None]*) : optional list of column headers. Length must be equal to len(tseries) (no date column header specified) or len(tseries)+1 (first header is assumed to be date column header) - - `header_char` : Character to be used for the row separator line + - `header_char` (string, *['-']*): Character to be used for the row separator + line between the header and first row of data. None for no separator. This + is ignored if `header_row` is None. + - `row_char` (string, *[None]*): Character to be used for the row separator + line between each row of data. None for no separator + - `footer_func` (List of functions or single function, *[None]*) : A function or + list of functions for summarizing each data column in the report. For example, + ma.sum to get the sum of the column. If a list of functions is provided + there must be exactly one function for each column. + - `footer_char` (string, *['-']*): Character to be used for the row separator + line between the last row of data and the footer. None for no separator. This + is ignored if `footer_func` is None. + - `footer_label` (string, *[None]*) : label for the footer row. This is + ignored if footer_func is None. - `justify` (List of strings or single string, *[None]*) : Determines how are data justified in their column. If not specified, the date column and string columns are left justified, and everything else is right justified. If a @@ -105,6 +117,10 @@ dates = kwargs.pop('dates', None) header_row = kwargs.pop('header_row', None) header_char = kwargs.pop('header_char', '-') + row_char = kwargs.pop('row_char', None) + footer_label = kwargs.pop('footer_label', None) + footer_char = kwargs.pop('footer_char', '-') + footer_func = kwargs.pop('footer_func', None) delim = kwargs.pop('delim', ' | ') justify = kwargs.pop('justify', None) prefix = kwargs.pop('prefix', '') @@ -113,6 +129,7 @@ datefmt = kwargs.pop('datefmt', None) fmtfunc = kwargs.pop('fmtfunc', str) + if type(fmtfunc) != types.ListType: fmtfunc = [fmtfunc_wrapper(fmtfunc, mask_rep)]*len(tseries) else: @@ -124,7 +141,7 @@ raise KeyError("Unrecognized keyword(s): %s" % (", ".join(kwargs.keys()))) if header_row is not None: - hasHeader=True + has_header=True if len(header_row) == len(tseries)+1: # label for date column included rows = [header_row] @@ -132,7 +149,7 @@ # label for date column not included rows = [['']+header_row] else: - hasHeader=False + has_header=False rows=[] if justify is not None: @@ -157,17 +174,32 @@ else: def datefmt_func(date): return date.strfmt(datefmt) - tseries = ts.align_series(*tseries) - if dates is None: + tseries = ts.align_series(*tseries) dates = td.date_array(start_date=tseries[0].start_date, end_date=tseries[0].end_date) + else: + tseries = ts.align_series(start_date=dates[0], end_date=dates[-1], *tseries) for d in dates: rows.append([datefmt_func(d)]+[fmtfunc[i](ser[d]) for i, ser in enumerate(tseries)]) + + if footer_func is not None: + has_footer=True + if type(footer_func) != types.ListType: + footer_func = [footer_func]*len(tseries) - return indent(rows, hasHeader=hasHeader, headerChar=header_char, - delim=delim, justify=justify, separateRows=False, + if footer_label is None: footer_label = [''] + else: footer_label = [footer_label] + rows.append(footer_label + [fmtfunc[i](footer_func[i](ser)) for i, ser in enumerate(tseries)]) + else: + has_footer=False + + return indent(rows, + has_header=has_header, header_char=header_char, + has_footer=has_footer, footer_char=footer_char, + separate_rows=separate_rows, row_char=row_char, + delim=delim, justify=justify, prefix=prefix, postfix=postfix, wrapfunc=wrapfunc) @@ -175,18 +207,22 @@ # written by George Sakkis # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662 -def indent(rows, hasHeader=False, headerChar='-', delim=' | ', justify=None, - separateRows=False, prefix='', postfix='', wrapfunc=lambda x:x): +def indent(rows, + has_header=False, header_char='-', + has_footer=False, footer_char='-', + separate_rows=False, row_char='_', + delim=' | ', justify=None, + prefix='', postfix='', wrapfunc=lambda x:x): """Indents a table by column. - rows: A sequence of sequences of items, one sequence per row. - - hasHeader: True if the first row consists of the columns' names. - - headerChar: Character to be used for the row separator line - (if hasHeader==True or separateRows==True). + - has_header: True if the first row consists of the columns' names. + - header_char: Character to be used for the row separator line + (if has_header==True or separate_rows==True). - delim: The column delimiter. - justify: Determines how are data justified in their column. Valid values are 'left','right' and 'center'. - - separateRows: True if rows are to be separated by a line - of 'headerChar's. + - separate_rows: True if rows are to be separated by a line + of 'header_char's. - prefix: A string prepended to each printed row. - postfix: A string appended to each printed row. - wrapfunc: A function f(text) for wrapping text; each element in @@ -198,6 +234,7 @@ return [[substr or '' for substr in item] for item in map(None,*newRows)] # break each logical row into one or more physical ones logicalRows = [rowWrapper(row) for row in rows] + numLogicalRows = len(logicalRows) # columns of physical rows columns = map(None,*reduce(operator.add,logicalRows)) numCols = len(columns) @@ -208,21 +245,37 @@ # get the maximum of each column by the string length of its items maxWidths = [max([len(str(item)) for item in column]) for column in columns] - rowSeparator = headerChar * (len(prefix) + len(postfix) + sum(maxWidths) + \ - len(delim)*(len(maxWidths)-1)) + + def getSeparator(char, separate): + if char is not None and separate: + return char * (len(prefix) + len(postfix) + sum(maxWidths) + \ + len(delim)*(len(maxWidths)-1)) + else: + return None + + header_separator = getSeparator(header_char, has_header) + footer_separator = getSeparator(footer_char, has_footer) + row_separator = getSeparator(row_char, separate_rows) + # select the appropriate justify method justify_funcs = {'center':str.center, 'right':str.rjust, 'left':str.ljust} - output=cStringIO.StringIO() - if separateRows: print >> output, rowSeparator - for physicalRows in logicalRows: + + for rowNum, physicalRows in enumerate(logicalRows): for row in physicalRows: print >> output, \ prefix \ + delim.join([justify_funcs[justify[colNum].lower()](str(item),width) for (colNum,item,width) in zip(colNums,row,maxWidths)]) \ + postfix - if separateRows or hasHeader: print >> output, rowSeparator; hasHeader=False + + if row_separator and (0 < rowNum < numLogicalRows-2): + print >> output, row_separator + elif header_separator and rowNum == 0: + print >> output, header_separator + elif footer_separator and rowNum == numLogicalRows-2: + print >> output, footer_separator + return output.getvalue() # written by Mike Brown From scipy-svn at scipy.org Tue Jan 30 21:24:29 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 20:24:29 -0600 (CST) Subject: [Scipy-svn] r2655 - trunk/Lib/sandbox/maskedarray Message-ID: <20070131022429.30A2F39C01F@new.scipy.org> Author: pierregm Date: 2007-01-30 20:24:25 -0600 (Tue, 30 Jan 2007) New Revision: 2655 Modified: trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/extras.py trunk/Lib/sandbox/maskedarray/mrecords.py Log: tcore: fixed a pb with m/m when m has some zeros textras: fixed syntax errors in mediff1d trecords: commented out __array_wrap__ for now Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-01-30 23:03:57 UTC (rev 2654) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-01-31 02:24:25 UTC (rev 2655) @@ -73,9 +73,6 @@ from numpy.lib.shape_base import expand_dims as n_expand_dims import warnings -import logging -logging.basicConfig(level=logging.DEBUG, - format='%(name)-15s %(levelname)s %(message)s',) MaskType = bool_ @@ -845,12 +842,12 @@ _defaulthardmask = False #TODO: There some reorganization to do round here 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): + keep_mask=True, small_mask=True, hard_mask=False, flag=None, + **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. """ -# logging.debug("__new__ received %s" % type(data)) if flag is not None: warnings.warn("The flag 'flag' is now called 'small_mask'!", DeprecationWarning) @@ -923,7 +920,7 @@ cls._fill_value = fill_value cls._defaulthardmask = hard_mask cls._defaultmask = mask -# logging.debug("__new__ returned %s as %s" % (type(_data), cls)) + cls._defaultoptions = options return numeric.asanyarray(_data).view(cls) #.................................. def __array_wrap__(self, obj, context=None): @@ -932,10 +929,8 @@ """ # mclass = self.__class__ #.......... -# logging.debug("__wrap__ received %s w/ context:%ss" % (type(obj),context)) if context is None: # return mclass(obj, mask=self._mask, copy=False) -# logging.debug("__wrap__ received nocontext") return MaskedArray(obj, mask=self._mask, copy=False, dtype=obj.dtype, fill_value=self.fill_value, ) @@ -956,7 +951,6 @@ if m.shape != dshape: m = reduce(mask_or, [getmaskarray(arg) for arg in args]) # return mclass(obj, copy=False, mask=m) -# logging.debug("__wrap__ context %s" % context) return MaskedArray(obj, copy=False, mask=m,) # dtype=obj.dtype, fill_value=self._fill_value) #........................ @@ -965,16 +959,13 @@ """Finalizes the masked array. """ # -# logging.debug("__finalize__ received %s" % type(obj)) if isinstance(obj, MaskedArray): # We came here from a MaskedArray -# logging.debug("__finalize__ recieved data %s" % obj) -# logging.debug("__finalize__ recieved data._data %s" % obj._data) -# logging.debug("__finalize__ recieved data.base %s" % obj.base) self._data = obj._data self._mask = obj._mask self._hardmask = obj._hardmask self._fill_value = obj._fill_value + self.options = obj.options else: # We came here from a .view() if hasattr(obj,'_data') and hasattr(obj, '_mask'): @@ -988,23 +979,22 @@ # Set the instance default self._hardmask = self._defaulthardmask self.fill_value = self._fill_value + self.options = self._defaultoptions # Reset the class default MaskedArray._defaultmask = nomask MaskedArray._defaulthardmask = False MaskedArray._fill_value = None -# logging.debug("__finalize__: obj has _mask %s" % hasattr(obj,'_data')) # # -# logging.debug("__finalize__ returned %s" % type(self)) return #............................................ - def __getitem__(self, index): + def __getitem__(self, indx): """x.__getitem__(y) <==> x[y] Returns the item described by i. Not a copy as in previous versions. """ - if getmask(index) is not nomask: + if getmask(indx) is not nomask: msg = "Masked arrays must be filled before they can be used as indices!" raise IndexError, msg - dout = self._data[index] + dout = self._data[indx] m = self._mask scalardout = (len(numeric.shape(dout))==0) # @@ -1013,15 +1003,17 @@ return dout else: return self.__class__(dout, mask=nomask, keep_mask=True, - fill_value=self._fill_value) + fill_value=self._fill_value, + **self.options) #.... - mi = m[index] + mi = m[indx] if mi.size == 1: if mi: return masked return dout else: - return self.__class__(dout, mask=mi, fill_value=self._fill_value) + return self.__class__(dout, mask=mi, fill_value=self._fill_value, + **self.options) #........................ def __setitem__(self, index, value): """x.__setitem__(i, y) <==> x[i]=y @@ -1088,9 +1080,11 @@ m = self._mask dout = self._data[i:j] if m is nomask: - return self.__class__(dout, fill_value=self._fill_value) + return self.__class__(dout, fill_value=self._fill_value, + **self.options) else: - return self.__class__(dout, mask=m[i:j], fill_value=self._fill_value) + return self.__class__(dout, mask=m[i:j], fill_value=self._fill_value, + **self.options) #........................ def __setslice__(self, i, j, value): """x.__setslice__(i, j, value) <==> x[i:j]=value @@ -1161,10 +1155,6 @@ """ if masked_print_option.enabled(): f = masked_print_option - # XXX: Without the following special case masked - # XXX: would print as "[--]", not "--". Can we avoid - # XXX: checks for masked by choosing a different value - # XXX: for the masked singleton? 2005-01-05 -- sasha if self is masked: return str(f) m = self._mask @@ -1222,7 +1212,7 @@ the absolute of the inital `_data`. """ return self.__class__(self._data.__abs__(), mask=self._mask, - fill_value = self._fill_value,) + fill_value = self._fill_value, **self.options) # def __neg__(self): """x.__abs__() <==> neg(x) @@ -1230,7 +1220,7 @@ the negative of the inital `_data`.""" try: return self.__class__(self._data.__neg__(), mask=self._mask, - fill_value = self._fill_value,) + fill_value = self._fill_value, **self.options) except MAError: return negative(self) # @@ -1323,11 +1313,12 @@ if tc == self._data.dtype: return self try: - return self.__class__(self, mask=self._mask, dtype=tc, copy=True) + return self.__class__(self, mask=self._mask, dtype=tc, copy=True, + **self.options) except: # d = self._data.astype(tc) return self.__class__(self._data.astype(tc), mask=self._mask, - dtype=tc) + dtype=tc, **self.options) # # #............................................ @@ -1344,10 +1335,12 @@ """ if self._mask is nomask: return masked_array(self._data.ravel(), mask=nomask, copy=False, - fill_value = self._fill_value) + fill_value = self._fill_value, + **self.options) else: return masked_array(self._data.ravel(), mask=self._mask.ravel(), - copy=False, fill_value = self._fill_value) + copy=False, fill_value = self._fill_value, + **self.options) # def _set_flat (self, value): "x.flat = value" @@ -1359,15 +1352,8 @@ #............................................ def _get_real(self): "Returns the real part of a complex array." - return masked_array(self._data.real, mask=self.mask, - fill_value = self._fill_value) -# if self.mask is nomask: -# return masked_array(self._data.real, mask=nomask, -# fill_value = self.fill_value) -# else: -# return masked_array(self._data.real, mask=self.mask, -# fill_value = self.fill_value) - + return self.__class__(self._data.real, mask=self.mask, + fill_value = self._fill_value, **self.options) def _set_real (self, value): "Sets the real part of a complex array to `value`." y = self.real @@ -1377,8 +1363,8 @@ def _get_imaginary(self): "Returns the imaginary part of a complex array." - return masked_array(self._data.imag, mask=nomask, - fill_value = self._fill_value) + return self.__class__(self._data.imag, mask=self.mask, + fill_value = self._fill_value, **self.options) def _set_imaginary (self, value): "Sets the imaginary part of a complex array to `value`." @@ -1524,10 +1510,10 @@ if self._mask is not nomask: return self.__class__(self._data.reshape(*s), mask=self._mask.reshape(*s), - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) else: return self.__class__(self._data.reshape(*s), - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) # def repeat(self, repeats, axis=None): """Repeat elements of `a` `repeats` times along `axis`. @@ -1547,7 +1533,8 @@ if m is not nomask: m = fromnumeric.repeat(m, repeats, axis) d = fromnumeric.repeat(f, repeats, axis) - return self.__class__(d, mask=m, fill_value=self.fill_value) + return self.__class__(d, mask=m, fill_value=self.fill_value, + **self.options) # def resize(self, newshape, refcheck=True, order=False): """Attempts to modify size and shape of self inplace. @@ -1608,7 +1595,7 @@ d = filled(self, True).all(axis) m = self._mask.all(axis) return self.__class__(d, mask=m, dtype=bool_, - fill_value=self._fill_value,) + fill_value=self._fill_value, **self.options) def any(self, axis=None): """a.any(axis) returns True if some or all entries along the axis are True. Returns False otherwise. If axis is None, uses the flatten array. @@ -1618,7 +1605,7 @@ d = filled(self, False).any(axis) m = self._mask.all(axis) return self.__class__(d, mask=m, dtype=bool_, - fill_value=self._fill_value) + fill_value=self._fill_value, **self.options) def nonzero(self): """a.nonzero() returns a tuple of arrays @@ -1632,7 +1619,7 @@ transpose(a.nonzero()) instead. The result of this is always a 2d array, with a row for each non-zero element.""" - return self.filled(0).nonzero() + return numeric.asarray(self.filled(0)).nonzero() #............................................ def trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None): """a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None) @@ -1658,13 +1645,14 @@ # if axis is None: # return self._data.sum(None, dtype=dtype) return self.__class__(self._data.sum(axis, dtype=dtype), - mask=nomask, fill_value=self.fill_value) + mask=nomask, fill_value=self.fill_value, + **self.options) else: # if axis is None: # return self.filled(0).sum(None, dtype=dtype) return self.__class__(self.filled(0).sum(axis, dtype=dtype), mask=self._mask.all(axis), - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) def cumsum(self, axis=None, dtype=None): """a.cumprod(axis=None, dtype=None) @@ -1676,12 +1664,13 @@ # if axis is None: # return self._data.cumsum(None, dtype=dtype) return self.__class__(self._data.cumsum(axis=axis, dtype=dtype), - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) else: # if axis is None: # return self.filled(0).cumsum(None, dtype=dtype) return self.__class__(self.filled(0).cumsum(axis=axis, dtype=dtype), - mask=self._mask, fill_value=self.fill_value) + mask=self._mask, fill_value=self.fill_value, + **self.options) def prod(self, axis=None, dtype=None): """a.prod(axis=None, dtype=None) @@ -1693,14 +1682,16 @@ # if axis is None: # return self._data.prod(None, dtype=dtype) return self.__class__(self._data.prod(axis, dtype=dtype), - mask=nomask, fill_value=self.fill_value) + mask=nomask, fill_value=self.fill_value, + **self.options) # return self.__class__(self._data.prod(axis=axis, dtype=dtype)) else: # if axis is None: # return self.filled(1).prod(None, dtype=dtype) return self.__class__(self.filled(1).prod(axis=axis, dtype=dtype), mask=self._mask.all(axis), - fill_value=self.fill_value) + fill_value=self.fill_value, + **self.options) product = prod def cumprod(self, axis=None, dtype=None): @@ -1713,13 +1704,14 @@ # if axis is None: # return self._data.cumprod(None, dtype=dtype) return self.__class__(self._data.cumprod(axis=axis, dtype=dtype), - mask=nomask, fill_value=self.fill_value,) + mask=nomask, fill_value=self.fill_value, + **self.options) else: # if axis is None: # return self.filled(1).cumprod(None, dtype=dtype) return self.__class__(self.filled(1).cumprod(axis=axis, dtype=dtype), mask=self._mask, - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) def mean(self, axis=None, dtype=None): """a.mean(axis=None, dtype=None) @@ -1738,7 +1730,8 @@ # if axis is None: # return self._data.mean(axis=None, dtype=dtype) return self.__class__(self._data.mean(axis=axis, dtype=dtype), - mask=nomask, fill_value=self.fill_value) + mask=nomask, fill_value=self.fill_value, + **self.options) else: dsum = fromnumeric.sum(self.filled(0), axis=axis, dtype=dtype) cnt = self.count(axis=axis) @@ -1746,7 +1739,7 @@ if axis is None and mask: return masked return self.__class__(dsum*1./cnt, mask=mask, - fill_value=self.fill_value,) + fill_value=self.fill_value, **self.options) def anom(self, axis=None, dtype=None): """a.anom(axis=None, dtype=None) @@ -1770,7 +1763,7 @@ # return self._data.var(axis=None, dtype=dtype) return self.__class__(self._data.var(axis=axis, dtype=dtype), mask=nomask, - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) else: cnt = self.count(axis=axis) danom = self.anom(axis=axis, dtype=dtype) @@ -1781,7 +1774,7 @@ return dvar return self.__class__(dvar, mask=mask_or(self._mask.all(axis), (cnt==1)), - fill_value=self.fill_value) + fill_value=self.fill_value, **self.options) def std(self, axis=None, dtype=None): """a.std(axis=None, dtype=None) @@ -1799,7 +1792,7 @@ return sqrt(dvar) return self.__class__(sqrt(dvar._data), mask=dvar._mask, dtype = self.dtype, - fill_value=self.fill_value,) + fill_value=self.fill_value, **self.options) #............................................ def argsort(self, axis=None, fill_value=None, kind='quicksort'): """Returns an array of indices that sort 'a' along the specified axis. @@ -2061,8 +2054,9 @@ # a pure ndarray. #Oh, and we better make a copy! if isinstance(other, ndarray): - if target is other: + if target is other or target is base: # We don't want to modify other: let's copy target, then + # Same if target us base, instead... target = target.copy() target[:] = numeric.where(fromnumeric.asarray(domain), self.fill_other, target) @@ -2073,7 +2067,8 @@ m = mask_or(m_self, m_other) method = getattr(base, self.methodname) return instance.__class__(method(target, *args), mask=m, - fill_value=instance.fill_value) + fill_value=instance.fill_value, + **instance.options) #...................................... class _compamethods(object): """Defines comparison methods (eq, ge, gt...). @@ -2112,8 +2107,7 @@ target = filled(other, self.fill_other) method = getattr(base, self.methodname) return instance.__class__(method(target, *args), mask=m, -# fill_value=instance.fill_value - ) + **instance.options) #.......................................................... MaskedArray.__add__ = _arithmethods('__add__') MaskedArray.__radd__ = _arithmethods('__add__') @@ -2256,8 +2250,9 @@ # def __call__(self, *args, **params): methodname = self._name - (d, m) = (self.obj._data, self.obj._mask) - (t, f) = (self.obj.dtype, self.obj._fill_value) + obj = self.obj + (d, m) = (obj._data, obj._mask) + (t, f) = (obj.dtype, obj._fill_value) C = self.obj.__class__ if m is nomask: return C(getattr(d,methodname).__call__(*args, **params), @@ -2265,10 +2260,10 @@ elif self._onmask: return C(getattr(d,methodname).__call__(*args, **params), mask=getattr(m,methodname)(*args, **params), - dtype=t, fill_value=f) + dtype=t, fill_value=f, **obj.options) else: return C(getattr(d,methodname).__call__(*args, **params), mask=m, - dtype=t, fill_value=f) + dtype=t, fill_value=f, **obj.options) #...................................... MaskedArray.conj = MaskedArray.conjugate = _arraymethod('conjugate') MaskedArray.copy = _arraymethod('copy') @@ -3017,3 +3012,15 @@ MaskedArray.__dumps__ = dumps ################################################################################ + +if __name__ == '__main__': + if 1: + a = masked_array([0,0]) + b = a/a + assert (b._mask == [1,1]).all() + assert (a._data == [0,0]).all() + if 1: + a = arange(4) + a[1:-1] = masked + b = a[:-5] + Modified: trunk/Lib/sandbox/maskedarray/extras.py =================================================================== --- trunk/Lib/sandbox/maskedarray/extras.py 2007-01-30 23:03:57 UTC (rev 2654) +++ trunk/Lib/sandbox/maskedarray/extras.py 2007-01-31 02:24:25 UTC (rev 2655) @@ -449,7 +449,7 @@ #............................................................................... def mediff1d(array, to_end=None, to_begin=None): """Array difference with prefixed and/or appended value.""" - a = MA.masked_array(array, copy=True) + a = masked_array(array, copy=True) if a.ndim > 1: a.reshape((a.size,)) (d, m, n) = (a._data, a._mask, a.size-1) @@ -460,30 +460,30 @@ dm = m[1:]-m[:-1] # if to_end is not None: - to_end = MA.asarray(to_end) + to_end = asarray(to_end) nend = to_end.size if to_begin is not None: - to_begin = MA.asarray(to_begin) + to_begin = asarray(to_begin) nbegin = to_begin.size - r_data = N.empty((n+nend+nbegin,), dtype=a.dtype) - r_mask = N.zeros((n+nend+nbegin,), dtype=bool_) + r_data = numeric.empty((n+nend+nbegin,), dtype=a.dtype) + r_mask = numeric.zeros((n+nend+nbegin,), dtype=bool_) r_data[:nbegin] = to_begin._data r_mask[:nbegin] = to_begin._mask r_data[nbegin:-nend] = dd r_mask[nbegin:-nend] = dm else: - r_data = N.empty((n+nend,), dtype=a.dtype) - r_mask = N.zeros((n+nend,), dtype=bool_) + r_data = numeric.empty((n+nend,), dtype=a.dtype) + r_mask = numeric.zeros((n+nend,), dtype=bool_) r_data[:-nend] = dd r_mask[:-nend] = dm r_data[-nend:] = to_end._data r_mask[-nend:] = to_end._mask # elif to_begin is not None: - to_begin = MA.asarray(to_begin) + to_begin = asarray(to_begin) nbegin = to_begin.size - r_data = N.empty((n+nbegin,), dtype=a.dtype) - r_mask = N.zeros((n+nbegin,), dtype=bool_) + r_data = numeric.empty((n+nbegin,), dtype=a.dtype) + r_mask = numeric.zeros((n+nbegin,), dtype=bool_) r_data[:nbegin] = to_begin._data r_mask[:nbegin] = to_begin._mask r_data[nbegin:] = dd Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-30 23:03:57 UTC (rev 2654) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-31 02:24:25 UTC (rev 2655) @@ -35,8 +35,6 @@ from maskedarray.core import default_fill_value, masked_print_option import warnings -import logging -logging.basicConfig(level=logging.DEBUG, format='%(name)-15s %(levelname)s %(message)s',) reserved_fields = ['_data','_mask','_fieldmask', 'dtype'] @@ -130,7 +128,6 @@ shape = numeric.asarray(data[0]).shape if isinstance(shape, int): shape = (shape,) -# logging.debug('__new__: shape: %s' % str(shape)) # Construct the _data recarray .......... if isinstance(data, record): _data = numeric.asarray(data).view(recarray) @@ -145,7 +142,6 @@ _data[n] = numeric.asarray(v).view(ndarray) _fieldmask[n] = getmaskarray(v) -# logging.debug('__new__: _fieldmask: %s' % _fieldmask) # Set filling value ..................... if fill_value is None: cls._fill_value = [default_fill_value(numeric.dtype(d[1])) @@ -159,7 +155,6 @@ return _data.view(cls) def __array_finalize__(self,obj): -# logging.debug("__array_finalize__ received %s" % type(obj)) if isinstance(obj, MaskedRecords): self.__dict__.update(_data=obj._data, _fieldmask=obj._fieldmask, @@ -182,11 +177,9 @@ ) MaskedRecords._defaultfieldmask = nomask MaskedRecords._defaulthardmask = False -# logging.debug("__array_finalize__ exit ") return #...................................................... def __getattribute__(self, attr): -# logging.debug('__getattribute__ %s' % attr) try: # Returns a generic attribute return object.__getattribute__(self,attr) @@ -194,7 +187,6 @@ # OK, so attr must be a field name pass # Get the list of fields ...... -# logging.debug('__getattribute__ %s listfield' % attr) _names = self.dtype.names _local = self.__dict__ _mask = _local['_fieldmask'] @@ -204,21 +196,18 @@ obj._mask = make_mask(_mask.__getattribute__(attr)) return obj elif attr == '_mask': -# logging.debug('__getattribute__ return mask') if self.size > 1: return _mask.view((bool_, len(self.dtype))).all(1) return _mask.view((bool_, len(self.dtype))) raise AttributeError,"No attribute '%s' !" % attr def __setattr__(self, attr, val): -# logging.debug('__setattribute__ %s' % attr) newattr = attr not in self.__dict__ try: # Is attr a generic attribute ? ret = object.__setattr__(self, attr, val) except: # Not a generic attribute: exit if it's not a valid field -# logging.debug('__setattribute__ %s' % attr) fielddict = self.dtype.names or {} if attr not in fielddict: exctype, value = sys.exc_info()[:2] @@ -259,7 +248,6 @@ def __getitem__(self, indx): """Returns all the fields sharing the same fieldname base. The fieldname base is either `_data` or `_mask`.""" -# logging.debug('__getitem__(%s)' % indx) _localdict = self.__dict__ # We want a field ........ if isinstance(indx, str): @@ -341,7 +329,6 @@ """Returns a view of the mrecarray.""" try: if issubclass(obj, ndarray): -# logging.debug('direct view as %s' % obj) return ndarray.view(self, obj) except TypeError: pass @@ -464,7 +451,6 @@ # Define formats from scratch ............... if formats is None and dtype is None: formats = _getformats(arraylist) -# logging.debug("fromarrays: formats",formats) # Define the dtype .......................... if dtype is not None: descr = numeric.dtype(dtype) @@ -627,7 +613,6 @@ line = f.readline() firstline = line[:line.find(commentchar)].strip() _varnames = firstline.split(delimitor) -# logging.debug("_VARNAMES:%s-%s"% (_varnames,len(_varnames))) if len(_varnames) > 1: break if varnames is None: @@ -648,7 +633,6 @@ vartypes = _guessvartypes(_variables[0]) # Construct the descriptor .................. mdescr = [(n,f) for (n,f) in zip(varnames, vartypes)] -# logging.debug("fromtextfile: descr: %s" % mdescr) # Get the data and the mask ................. # We just need a list of masked_arrays. It's easier to create it like that: _mask = (_variables.T == missingchar) From scipy-svn at scipy.org Tue Jan 30 21:25:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 30 Jan 2007 20:25:33 -0600 (CST) Subject: [Scipy-svn] r2656 - trunk/Lib/sandbox/maskedarray/tests Message-ID: <20070131022533.B739B39C01F@new.scipy.org> Author: pierregm Date: 2007-01-30 20:25:32 -0600 (Tue, 30 Jan 2007) New Revision: 2656 Modified: trunk/Lib/sandbox/maskedarray/tests/ Log: Property changes on: trunk/Lib/sandbox/maskedarray/tests ___________________________________________________________________ Name: svn:ignore + test_mrecarray.py From scipy-svn at scipy.org Wed Jan 31 08:02:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 07:02:16 -0600 (CST) Subject: [Scipy-svn] r2657 - trunk/Lib/io Message-ID: <20070131130216.0398939C018@new.scipy.org> Author: matthew.brett at gmail.com Date: 2007-01-31 07:02:13 -0600 (Wed, 31 Jan 2007) New Revision: 2657 Modified: trunk/Lib/io/__init__.py trunk/Lib/io/fopen.py Log: Removed fopen from default import, deprecate in favor of npfile Modified: trunk/Lib/io/__init__.py =================================================================== --- trunk/Lib/io/__init__.py 2007-01-31 02:25:32 UTC (rev 2656) +++ trunk/Lib/io/__init__.py 2007-01-31 13:02:13 UTC (rev 2657) @@ -8,7 +8,6 @@ from numpyio import packbits, unpackbits, bswap, fread, fwrite, \ convert_objectarray from mio import * -from fopen import * from npfile import npfile from recaster import sctype_attributes, Recaster from array_import import * Modified: trunk/Lib/io/fopen.py =================================================================== --- trunk/Lib/io/fopen.py 2007-01-31 02:25:32 UTC (rev 2656) +++ trunk/Lib/io/fopen.py 2007-01-31 13:02:13 UTC (rev 2657) @@ -8,6 +8,10 @@ from numpy import * import numpyio +import warnings +warnings.warn('fopen module is deprecated, please use npfile instead', + DeprecationWarning, stacklevel=2) + LittleEndian = (sys.byteorder == 'little') __all__ = ['fopen'] From scipy-svn at scipy.org Wed Jan 31 08:58:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 07:58:02 -0600 (CST) Subject: [Scipy-svn] r2658 - trunk/Lib/sandbox/models Message-ID: <20070131135802.687DB39C17E@new.scipy.org> Author: jonathan.taylor Date: 2007-01-31 07:58:00 -0600 (Wed, 31 Jan 2007) New Revision: 2658 Modified: trunk/Lib/sandbox/models/regression.py Log: changed hstack to vstack to check estimability of a contrast Modified: trunk/Lib/sandbox/models/regression.py =================================================================== --- trunk/Lib/sandbox/models/regression.py 2007-01-31 13:02:13 UTC (rev 2657) +++ trunk/Lib/sandbox/models/regression.py 2007-01-31 13:58:00 UTC (rev 2658) @@ -330,13 +330,13 @@ def isestimable(C, D): """ From an q x p contrast matrix C and an n x p design matrix D, checks - if the contrast C is estimable by looking at the rank of hstack([C,D]) and + if the contrast C is estimable by looking at the rank of vstack([C,D]) and verifying it is the same as the rank of D. """ if C.ndim == 1: C.shape = (C.shape[0], 1) - new = N.hstack([C, D]) + new = N.vstack([C, D]) if utils.rank(new) != utils.rank(D): return False return True From scipy-svn at scipy.org Wed Jan 31 11:46:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 10:46:28 -0600 (CST) Subject: [Scipy-svn] r2659 - trunk/Lib/io Message-ID: <20070131164628.D468A39C017@new.scipy.org> Author: stefan Date: 2007-01-31 10:46:06 -0600 (Wed, 31 Jan 2007) New Revision: 2659 Modified: trunk/Lib/io/npfile.py Log: Change file mode to 'w' instead of 'H'. Modified: trunk/Lib/io/npfile.py =================================================================== --- trunk/Lib/io/npfile.py 2007-01-31 13:58:00 UTC (rev 2658) +++ trunk/Lib/io/npfile.py 2007-01-31 16:46:06 UTC (rev 2659) @@ -16,7 +16,7 @@ Inputs: file_name -- The complete path name to the file to open or an open file-like object - permission -- Open the file with given permissions: ('r', 'H', 'a') + permission -- Open the file with given permissions: ('r', 'w', 'a') for reading, writing, or appending. This is the same as the mode argument in the builtin open command. format -- The byte-ordering of the file: From scipy-svn at scipy.org Wed Jan 31 11:52:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 10:52:57 -0600 (CST) Subject: [Scipy-svn] r2660 - trunk/Lib/io Message-ID: <20070131165257.4D26139C1B5@new.scipy.org> Author: stefan Date: 2007-01-31 10:51:37 -0600 (Wed, 31 Jan 2007) New Revision: 2660 Modified: trunk/Lib/io/npfile.py Log: Update npfile.read docstring. Modified: trunk/Lib/io/npfile.py =================================================================== --- trunk/Lib/io/npfile.py 2007-01-31 16:46:06 UTC (rev 2659) +++ trunk/Lib/io/npfile.py 2007-01-31 16:51:37 UTC (rev 2660) @@ -156,15 +156,16 @@ fwrite = write def read(self, shape, dt, endian=None, order=None): - ''' Read data from file and return it in a numpy array + '''Read data from file and return it in a numpy array. Inputs + ------ shape - shape of output array, or number of elements - dt - dtype of array to write + dt - dtype of array to be read endian - endianness of written data (can be None, 'dtype', '<', '>') (default from self.endian) - order - order of array to write (C, F) + order - order of array to be read ('C' or 'F') (default from self.order) ''' endian, order = self._endian_order(endian, order) From scipy-svn at scipy.org Wed Jan 31 13:44:31 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 12:44:31 -0600 (CST) Subject: [Scipy-svn] r2661 - trunk/Lib/sandbox/timeseries Message-ID: <20070131184431.992E839C224@new.scipy.org> Author: mattknox_ca Date: 2007-01-31 12:44:27 -0600 (Wed, 31 Jan 2007) New Revision: 2661 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: changed __getitem__ to return 1-D time series when indexed by an integer, rather than 0-D "time series". This also fixed a bug preventing series of higher than 1 dimension from being indexed by a single integer. Also added a "stack" function which behaves like column_stack but gives the obvious stacking result one would want for time series. Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-01-31 16:51:37 UTC (rev 2660) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-01-31 18:44:27 UTC (rev 2661) @@ -60,7 +60,7 @@ 'day_of_week','day_of_year','day','month','quarter','year','hour','minute','second', 'tofile','asrecords','flatten','adjust_endpoints','align_series','aligned', 'mask_period','mask_inside_period','mask_outside_period', -'convert','fill_missing_dates' +'convert','fill_missing_dates', 'stack' ] #............................................................................... @@ -115,7 +115,40 @@ 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()) + + if len(set(shapes)) > 1: + errItems = tuple(set(shapes)) + raise TimeSeriesCompatibilityError('size', "1: %s" % str(errItems[0].shape), + "2: %s" % str(errItems[1].shape)) + + return True + + 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.""" @@ -286,15 +319,17 @@ data = self._series[indx] date = self._dates[indx] m = self._mask - scalardata = (len(numeric.shape(data))==0) - # + + singlepoint = (len(numeric.shape(date))==0) + + if singlepoint: + data = data.reshape((list((1,)) + list(data.shape))) + date = date_array(start_date=date, length=1, freq=date.freq) + if m is nomask: - if scalardata: - return TimeSeries(data, dates=date) - else: - return TimeSeries(data, dates=date, mask=nomask, keep_mask=True, - copy=False) - #.... + return TimeSeries(data, dates=date, mask=nomask, keep_mask=True, + copy=False) + mi = m[indx] if mi.size == 1: if mi: @@ -302,6 +337,7 @@ return TimeSeries(data, dates=date, mask=nomask) else: return TimeSeries(data, dates=date, mask=mi) + #........................ def __setitem__(self, indx, value): """x.__setitem__(i, y) <==> x[i]=y @@ -1301,7 +1337,20 @@ nshp = tuple([-1,] + list(data.shape[1:])) return time_series(newdata.reshape(nshp), newdates) - +#.................................................................... +def stack(*series): + """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 +""" + _timeseriescompat_multiple(*series) + return time_series(MA.column_stack(series), series[0]._dates, + **_attrib_dict(series[0])) + + ################################################################################ if __name__ == '__main__': from maskedarray.testutils import assert_equal From scipy-svn at scipy.org Wed Jan 31 13:45:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 12:45:00 -0600 (CST) Subject: [Scipy-svn] r2662 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070131184500.0E9A339C232@new.scipy.org> Author: mattknox_ca Date: 2007-01-31 12:44:58 -0600 (Wed, 31 Jan 2007) New Revision: 2662 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: updated tests to reflect new behaviour of __getitem__ Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-31 18:44:27 UTC (rev 2661) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-01-31 18:44:58 UTC (rev 2662) @@ -198,11 +198,11 @@ def test_wdate(self): "Tests getitem with date as index" (series, data, dates) = self.d - last_date = series[-1]._dates + last_date = series._dates[-1] assert_equal(series[-1], series[last_date]) assert_equal(series._dates[-1], dates[-1]) - assert_equal(series[-1]._dates, dates[-1]) - assert_equal(series[last_date]._dates, dates[-1]) + assert_equal(series[-1]._dates[0], dates[-1]) + assert_equal(series[last_date]._dates[0], dates[-1]) assert_equal(series._series[-1], data._data[-1]) assert_equal(series[-1]._series, data._data[-1]) assert_equal(series._mask[-1], data._mask[-1]) @@ -386,6 +386,56 @@ 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: + tseries._timeseriescompat_multiple(seriesM_10, seriesD_10) + exception = False + except: + exception = True + assert(exception) + + try: + tseries._timeseriescompat_multiple(seriesD_5, seriesD_10) + exception = False + except: + exception = True + assert(exception) + + try: + tseries._timeseriescompat_multiple(seriesD_5, seriesD_5_apr) + exception = False + except: + exception = True + assert(exception) + + ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": From scipy-svn at scipy.org Wed Jan 31 14:01:52 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 13:01:52 -0600 (CST) Subject: [Scipy-svn] r2663 - trunk/Lib/sandbox/maskedarray Message-ID: <20070131190152.2C90539C0D8@new.scipy.org> Author: pierregm Date: 2007-01-31 13:01:50 -0600 (Wed, 31 Jan 2007) New Revision: 2663 Modified: trunk/Lib/sandbox/maskedarray/mrecords.py Log: fixed a syntax error, aka "don't trust conversion scripts" Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-31 18:44:58 UTC (rev 2662) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-01-31 19:01:50 UTC (rev 2663) @@ -35,7 +35,6 @@ from maskedarray.core import default_fill_value, masked_print_option import warnings - format='%(name)-15s %(levelname)s %(message)s',) reserved_fields = ['_data','_mask','_fieldmask', 'dtype'] From scipy-svn at scipy.org Wed Jan 31 22:48:44 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 21:48:44 -0600 (CST) Subject: [Scipy-svn] r2664 - in trunk/Lib/sandbox/timeseries: . tests Message-ID: <20070201034844.212BA39C048@new.scipy.org> Author: pierregm Date: 2007-01-31 21:48:41 -0600 (Wed, 31 Jan 2007) New Revision: 2664 Modified: trunk/Lib/sandbox/timeseries/tdates.py trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: tdates:added some shortcuts for the creation of Date and DateArray objects tdates:solved an issue in Date when parsing a string as value Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-01-31 19:01:50 UTC (rev 2663) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-02-01 03:48:41 UTC (rev 2664) @@ -33,7 +33,6 @@ - __all__ = [ 'Date', 'DateArray','isDate','isDateArray', 'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', @@ -135,9 +134,10 @@ self.freq = corelib.check_freq(freq) self.freqstr = corelib.freq_tostr(self.freq) + if value is not None: if isinstance(value, str): - self.mxDate = mxDFromString(string) + self.mxDate = mxDFromString(value) elif self.freqstr == 'A': self.mxDate = mxD.Date(value, -1, -1) elif self.freqstr == 'B': @@ -474,7 +474,8 @@ def isDate(data): "Returns whether `data` is an instance of Date." - return isinstance(data, Date) + return isinstance(data, Date) or \ + (hasattr(data,'freq') and hasattr(data,'value')) #####--------------------------------------------------------------------------- @@ -882,22 +883,34 @@ if dlist is not None: # Already a DateArray.................... if isinstance(dlist, DateArray): - if freq != dlist.freq: + if (freq is not None) and (dlist.freq != corelib.check_freq(freq)): return dlist.asfreq(freq) else: return dlist - return _listparser(dlist, freq) + # 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: raise InsufficientDateError - if not isinstance(start_date, Date): - raise DateError, "Starting date should be a valid Date instance!" + 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!" else: - if not isinstance(end_date, Date): + if not isDate(end_date): raise DateError, "Ending date should be a valid Date instance!" length = end_date - start_date if include_last: @@ -963,3 +976,8 @@ ################################################################################ + +if __name__ == '__main__': + assert (Date('D','2007-01')==Date('D',string='2007-01')) + assert (Date('D','2007-01')==Date('D', value=732677)) + assert (Date('D',732677)==Date('D', value=732677)) \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-01-31 19:01:50 UTC (rev 2663) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-02-01 03:48:41 UTC (rev 2664) @@ -29,7 +29,8 @@ #reload(tdates) from timeseries import tcore #reload(tcore) -from timeseries.tdates import date_array_fromlist, Date, DateArray, date_array, mxDFromString +from timeseries.tdates import date_array_fromlist, Date, DateArray, date_array,\ + mxDFromString, today class test_creation(NumpyTestCase): "Base test class for MaskedArrays." @@ -111,8 +112,19 @@ for f in freqs: today = tdates.thisday(f) assert(tdates.Date(freq=f, value=today.value) == today) + + def test_shortcuts(self): + "Tests some creation shortcuts. Because I'm lazy like that." + # Dates shortcuts + assert_equal(Date('D','2007-01'), Date('D',string='2007-01')) + assert_equal(Date('D','2007-01'), Date('D', value=732677)) + assert_equal(Date('D',732677), Date('D', value=732677)) + # DateArray shortcuts + n = today('M') + d = date_array(start_date=n, length=3) + assert_equal(date_array(n,length=3), d) + assert_equal(date_array(n, n+2), d) - class test_date_properties(NumpyTestCase): "Test properties such as year, month, day_of_week, etc...." From scipy-svn at scipy.org Wed Jan 31 23:10:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 22:10:05 -0600 (CST) Subject: [Scipy-svn] r2665 - trunk/Lib/linsolve/SuperLU/SRC Message-ID: <20070201041005.E176739C0AA@new.scipy.org> Author: wnbell Date: 2007-01-31 22:10:04 -0600 (Wed, 31 Jan 2007) New Revision: 2665 Modified: trunk/Lib/linsolve/SuperLU/SRC/get_perm_c.c Log: SuperLU workaround by mauger, fixes ticket #311 Modified: trunk/Lib/linsolve/SuperLU/SRC/get_perm_c.c =================================================================== --- trunk/Lib/linsolve/SuperLU/SRC/get_perm_c.c 2007-02-01 03:48:41 UTC (rev 2664) +++ trunk/Lib/linsolve/SuperLU/SRC/get_perm_c.c 2007-02-01 04:10:04 UTC (rev 2665) @@ -402,7 +402,7 @@ t = SuperLU_timer_(); /* Initialize and allocate storage for GENMMD. */ - delta = 1; /* DELTA is a parameter to allow the choice of nodes + delta = 0; /* DELTA is a parameter to allow the choice of nodes whose degree <= min-degree + DELTA. */ maxint = 2147483647; /* 2**31 - 1 */ invp = (int *) SUPERLU_MALLOC((n+delta)*sizeof(int)); @@ -420,7 +420,7 @@ for (i = 0; i <= n; ++i) ++b_colptr[i]; for (i = 0; i < bnz; ++i) ++b_rowind[i]; - genmmd_(&n, b_colptr, b_rowind, perm_c, invp, &delta, dhead, + genmmd_(&n, b_colptr, b_rowind, invp, perm_c, &delta, dhead, qsize, llist, marker, &maxint, &nofsub); /* Transform perm_c into 0-based indexing. */ From scipy-svn at scipy.org Wed Jan 31 23:26:06 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 31 Jan 2007 22:26:06 -0600 (CST) Subject: [Scipy-svn] r2666 - trunk Message-ID: <20070201042606.F177C39C0FF@new.scipy.org> Author: wnbell Date: 2007-01-31 22:26:05 -0600 (Wed, 31 Jan 2007) New Revision: 2666 Modified: trunk/THANKS.txt Log: added Nathan to contributors Modified: trunk/THANKS.txt =================================================================== --- trunk/THANKS.txt 2007-02-01 04:10:04 UTC (rev 2665) +++ trunk/THANKS.txt 2007-02-01 04:26:05 UTC (rev 2666) @@ -14,6 +14,7 @@ improvements to the feature set, build process, and robustness of SciPy. +Nathan Bell -- sparsetools reimplementation (CSR/CSC matrix operations) Robert Cimrman -- UMFpack wrapper for sparse matrix module David M. Cooke -- improvements to system_info, and LBFGSB wrapper Chuck Harris -- Zeros package in optimize (1d root-finding algorithms)