[Scipy-svn] r2571 - in trunk/Lib/sandbox/timeseries: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Jan 15 23:28:38 CST 2007


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



More information about the Scipy-svn mailing list