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

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Feb 27 16:45:42 EST 2007


Author: pierregm
Date: 2007-02-27 15:45:40 -0600 (Tue, 27 Feb 2007)
New Revision: 2774

Modified:
   trunk/Lib/sandbox/timeseries/tests/test_timeseries.py
   trunk/Lib/sandbox/timeseries/tseries.py
Log:
tseries : fixed a but in _tsmathmethods.__call__
tests/time_series : updated

Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py	2007-02-27 21:41:19 UTC (rev 2773)
+++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py	2007-02-27 21:45:40 UTC (rev 2774)
@@ -275,7 +275,7 @@
         series = time_series(N.arange(10).reshape(5,2), start_date=hodie)
         assert_equal(len(series), 5)
         assert_equal(series[0], [[0,1]])
-        assert_equal(series[0]._dates, (hodie))
+        assert_equal(series[0]._dates[0], (hodie))
         assert_equal(series[:,0], [0,2,4,6,8])
         assert_equal(series[:,0]._dates, series._dates)
         # Case 2D + mask
@@ -284,7 +284,7 @@
         assert_equal(len(series), 5)
         assert_equal(series[0], [[0,1]])
         assert_equal(series[0]._mask, [[1,1]])
-        assert_equal(series[0]._dates, (hodie))
+        assert_equal(series[0]._dates[0], (hodie))
         assert_equal(series[:,0]._data, [0,2,4,6,8])
         assert_equal(series[:,0]._mask, [1,0,0,0,0])
         assert_equal(series[:,0]._dates, series._dates)       
@@ -293,7 +293,7 @@
         x = series[0]
         assert_equal(len(series), 5)
         assert_equal(series[0], [[[0,1],[2,3],[4,5]]])
-        assert_equal(series[0]._dates, (hodie))
+        assert_equal(series[0]._dates[0], (hodie))
         assert_equal(series[:,0], series._data[:,0])
         assert_equal(series[:,0]._dates, series._dates)
         x = series[:,:,0]

Modified: trunk/Lib/sandbox/timeseries/tseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tseries.py	2007-02-27 21:41:19 UTC (rev 2773)
+++ trunk/Lib/sandbox/timeseries/tseries.py	2007-02-27 21:45:40 UTC (rev 2774)
@@ -55,10 +55,12 @@
 __all__ = [
 'TimeSeriesError','TimeSeriesCompatibilityError','TimeSeries','isTimeSeries',
 'time_series', 'tsmasked',
-'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', 'stack'
+'mask_period','mask_inside_period','mask_outside_period','compressed',
+'adjust_endpoints','align_series','aligned','convert','group_byperiod',
+'tshift','fill_missing_dates', 'stack', 'concatenate_series','empty_like',
+'day_of_week','day_of_year','day','month','quarter','year',
+'hour','minute','second',  
+'tofile','asrecords','flatten',
            ]
 
 #...............................................................................
@@ -209,7 +211,7 @@
         if isinstance(other, TimeSeries):
             assert(_timeseriescompat(instance, other))
         func = getattr(super(TimeSeries, instance), self._name)
-        result = func(other, *args) #.view(type(instance))
+        result = func(other, *args).view(type(instance))
         result._dates = instance._dates
         return result
 
@@ -288,6 +290,7 @@
     """
     options = None
     _defaultobserved = None
+    _genattributes = ['fill_value', 'observed']
     def __new__(cls, data, dates=None, mask=nomask, 
                 freq=None, observed=None, start_date=None, 
                 dtype=None, copy=False, fill_value=None,
@@ -678,7 +681,7 @@
     #......................................................
     def copy_attributes(self, oldseries, exclude=[]):
         "Copies the attributes from oldseries if they are not in the exclude list."
-        attrlist = ['fill_value', 'observed']
+        attrlist = type(self)._genattributes
         if not isinstance(oldseries, TimeSeries):
             msg = "Series should be a valid TimeSeries object! (got <%s> instead)"
             raise TimeSeriesError, msg % type(oldseries)
@@ -1410,4 +1413,18 @@
             pass
         assert_equal(ser3d.transpose(0,2,1).shape, (5,2,3))
         
+    if 1:        
+        data = dates
     
+        series = time_series(data, dates)
+        assert(isinstance(series, TimeSeries))
+        assert_equal(series._dates, dates)
+        assert_equal(series._data, data)
+        assert_equal(series.freqstr, 'D')
+        
+        series[5] = MA.masked
+        
+        # ensure that series can be represented by a string after masking a value
+        # (there was a bug before that prevented this from working when using a 
+        # DateArray for the data)
+        strrep = str(series)




More information about the Scipy-svn mailing list