[Scipy-svn] r3472 - in trunk/scipy/sandbox/timeseries: . tests

scipy-svn@scip... scipy-svn@scip...
Sun Oct 28 22:04:29 CDT 2007


Author: mattknox_ca
Date: 2007-10-28 22:03:54 -0500 (Sun, 28 Oct 2007)
New Revision: 3472

Modified:
   trunk/scipy/sandbox/timeseries/tests/test_timeseries.py
   trunk/scipy/sandbox/timeseries/tseries.py
Log:
removed some obsolete parameters from time_series function and cleaned up the corresponding __doc__ string

Modified: trunk/scipy/sandbox/timeseries/tests/test_timeseries.py
===================================================================
--- trunk/scipy/sandbox/timeseries/tests/test_timeseries.py	2007-10-28 08:07:38 UTC (rev 3471)
+++ trunk/scipy/sandbox/timeseries/tests/test_timeseries.py	2007-10-29 03:03:54 UTC (rev 3472)
@@ -53,7 +53,7 @@
     def test_fromrange (self):
         "Base data definition."
         (dlist, dates, data) = self.d
-        series = time_series(data, start_date=dates[0], length=15)
+        series = time_series(data, start_date=dates[0])
         assert(isinstance(series, TimeSeries))
         assert_equal(series._mask, [1,0,0,0,0]*3)
         assert_equal(series._series, data)
@@ -530,28 +530,32 @@
 
     def test__timeseriescompat_multiple(self):
         "Tests the compatibility of multiple time series."
-        seriesM_10 = time_series(numpy.arange(10),
-                                    date_array(
-                                      start_date=Date(freq='m', year=2005, month=1),
-                                      length=10)
+        seriesM_10 = time_series(
+                        numpy.arange(10),
+                        date_array(
+                            start_date=Date(freq='m', year=2005, month=1),
+                            length=10)
                                 )
 
-        seriesD_10 = time_series(numpy.arange(10),
-                                    date_array(
-                                      start_date=Date(freq='d', year=2005, month=1, day=1),
-                                      length=10)
+        seriesD_10 = time_series(
+                        numpy.arange(10),
+                        date_array(
+                            start_date=Date(freq='d', year=2005, month=1, day=1),
+                            length=10)
                                 )
 
-        seriesD_5 = time_series(numpy.arange(5),
-                                    date_array(
-                                      start_date=Date(freq='d', year=2005, month=1, day=1),
-                                      length=5)
+        seriesD_5 = time_series(
+                        numpy.arange(5),
+                        date_array(
+                            start_date=Date(freq='d', year=2005, month=1, day=1),
+                            length=5)
                                 )
 
-        seriesD_5_apr = time_series(numpy.arange(5),
-                                    date_array(
-                                      start_date=Date(freq='d', year=2005, month=4, day=1),
-                                      length=5)
+        seriesD_5_apr = time_series(
+                            numpy.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))

Modified: trunk/scipy/sandbox/timeseries/tseries.py
===================================================================
--- trunk/scipy/sandbox/timeseries/tseries.py	2007-10-28 08:07:38 UTC (rev 3471)
+++ trunk/scipy/sandbox/timeseries/tseries.py	2007-10-29 03:03:54 UTC (rev 3472)
@@ -360,12 +360,11 @@
     construction as it allows greater flexibility and convenience.
 """
     def __new__(cls, data, dates, mask=nomask, dtype=None, copy=False,
-                fill_value=None, subok=True, keep_mask=True, small_mask=True,
-                hard_mask=False, **options):
+                fill_value=None, subok=True, keep_mask=True, hard_mask=False,
+                **options):
 
         maparms = dict(copy=copy, dtype=dtype, fill_value=fill_value, subok=subok,
-                       keep_mask=keep_mask, small_mask=small_mask,
-                       hard_mask=hard_mask)
+                       keep_mask=keep_mask, hard_mask=hard_mask)
         _data = MaskedArray(data, mask=mask, **maparms)
 
         # Get the dates ......................................................
@@ -945,21 +944,37 @@
 ##### -------------------------------------------------------------------------
 #---- --- TimeSeries creator ---
 ##### -------------------------------------------------------------------------
-def time_series(data, dates=None, freq=None, start_date=None, end_date=None,
-                length=None, mask=nomask, dtype=None, copy=False,
-                fill_value=None, keep_mask=True, small_mask=True,
+def time_series(data, dates=None, start_date=None, freq=None, mask=nomask,
+                dtype=None, copy=False, fill_value=None, keep_mask=True,
                 hard_mask=False):
     """Creates a TimeSeries object
 
-:Parameters:
-    `dates` : ndarray
-        Array of dates.
-    `data` :
-        Array of data.
-    """
+*Parameters*:
+    data : {array_like}
+        data portion of the array. Any data that is valid for constructing a
+        MaskedArray can be used here. May also be a TimeSeries object
+    dates : {DateArray}, optional
+        Date part.
+    freq : {freq_spec}, optional
+        a valid frequency specification
+    start_date : {Date}, optional
+        date corresponding to index 0 in the data
+
+*Other Parameters*:
+    All other parameters that are accepted by the *array* function in the
+    maskedarray module are also accepted by this function.
+
+*Notes*:
+    the date portion of the time series must be specified in one of the
+    following ways:
+        - specify a TimeSeries object for the *data* parameter
+        - pass a DateArray for the *dates* parameter
+        - specify a start_date (a continuous DateArray will be automatically
+          constructed for the dates portion)
+        - specify just a frequency (for TimeSeries of size zero)
+"""
     maparms = dict(copy=copy, dtype=dtype, fill_value=fill_value, subok=True,
-                   keep_mask=keep_mask, small_mask=small_mask,
-                   hard_mask=hard_mask,)
+                   keep_mask=keep_mask, hard_mask=hard_mask,)
     data = masked_array(data, mask=mask, **maparms)
 
     freq = check_freq(freq)
@@ -980,11 +995,8 @@
     else:
         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=length, freq=freq)
+            length = dshape[0]
+            _dates = date_array(start_date=start_date, freq=freq, length=length)
         else:
             _dates = date_array([], freq=freq)
 
@@ -995,7 +1007,7 @@
     return TimeSeries(data=data, dates=_dates, mask=data._mask,
                       copy=copy, dtype=dtype, 
                       fill_value=fill_value, keep_mask=keep_mask, 
-                      small_mask=small_mask, hard_mask=hard_mask,)
+                      hard_mask=hard_mask,)
 
 
 def isTimeSeries(series):



More information about the Scipy-svn mailing list