[Scipy-svn] r2800 - trunk/Lib/sandbox/timeseries

scipy-svn@scip... scipy-svn@scip...
Thu Mar 1 11:51:32 CST 2007


Author: pierregm
Date: 2007-03-01 11:51:29 -0600 (Thu, 01 Mar 2007)
New Revision: 2800

Modified:
   trunk/Lib/sandbox/timeseries/tseries.py
Log:
tseries : forced the _dates of tsmasked to a DateArray
        : forced the _dates of a series of 1 variable to the shape of the data

Modified: trunk/Lib/sandbox/timeseries/tseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tseries.py	2007-03-01 04:43:08 UTC (rev 2799)
+++ trunk/Lib/sandbox/timeseries/tseries.py	2007-03-01 17:51:29 UTC (rev 2800)
@@ -330,7 +330,8 @@
             return _data.view(cls)
         assert(_datadatescompat(_data,newdates))
         _data._dates = newdates
-        _data._defaultdates = _data._dates
+        if _data._dates.size == _data.size and _data.ndim > 1:
+            _data._dates.shape = _data.shape
         _data.observed = observed
         return _data
     #............................................
@@ -904,8 +905,11 @@
     if dates is None:
         dshape = data.shape
         if len(dshape) > 0:
+            if length is None:
+                length = dshape[0]
+        if len(dshape) > 0:
             dates = date_array(start_date=start_date, end_date=end_date,
-                               length=dshape[0], include_last=include_last, 
+                               length=length, include_last=include_last, 
                                freq=freq) 
         else:
             dates = date_array([], freq=freq)   
@@ -921,7 +925,7 @@
     "Returns whether the series is a valid TimeSeries object."
     return isinstance(series, TimeSeries)
 
-tsmasked = TimeSeries(masked,dates=Date('D',1))
+tsmasked = TimeSeries(masked,dates=DateArray(Date('D',1)))
 
 ##### --------------------------------------------------------------------------
 #---- ... Additional functions ...
@@ -1415,6 +1419,7 @@
         dates = date_array_fromlist(dlist)
         data = masked_array(numeric.arange(10), mask=[1,0,0,0,0]*2, dtype=float_)
         series = time_series(data, dlist)
+#        tostr = series._dates.tostring()
         #
         import cPickle
         series_pickled = cPickle.loads(series.dumps())
@@ -1422,13 +1427,5 @@
         assert_equal(series_pickled._data, series._data)
         assert_equal(series_pickled._mask, series._mask)        
         #
-        data = masked_array(N.matrix(range(10)).T, mask=[1,0,0,0,0]*2)
-        dates = date_array(start_date=thisday('D'), length=10)
-        series = time_series(data,dates=dates)
-        series_pickled = cPickle.loads(series.dumps())
-        assert_equal(series_pickled._dates, series._dates)
-        assert_equal(series_pickled._data, series._data)
-        assert_equal(series_pickled._mask, series._mask)
-        assert(isinstance(series_pickled._data, N.matrix))
-        
+
         
\ No newline at end of file



More information about the Scipy-svn mailing list