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

scipy-svn at scipy.org scipy-svn at scipy.org
Thu May 3 14:52:49 EDT 2007


Author: mattknox_ca
Date: 2007-05-03 13:52:46 -0500 (Thu, 03 May 2007)
New Revision: 2959

Modified:
   trunk/Lib/sandbox/timeseries/tseries.py
Log:
raise exception when undefined frequency used in convert method/function

Modified: trunk/Lib/sandbox/timeseries/tseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tseries.py	2007-05-03 18:51:58 UTC (rev 2958)
+++ trunk/Lib/sandbox/timeseries/tseries.py	2007-05-03 18:52:46 UTC (rev 2959)
@@ -690,10 +690,6 @@
         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 transpose(self, *axes):
         """ a.transpose(*axes)
@@ -1182,6 +1178,18 @@
     """
     if not isinstance(series,TimeSeries):
         raise TypeError, "The argument should be a valid TimeSeries!"
+
+    toFreq = check_freq(freq)
+    fromFreq = series.freq
+
+    if toFreq == _c.FR_UND:
+        raise TimeSeriesError, \
+            "Cannot convert a series to UNDEFINED frequency."
+
+    if fromFreq == _c.FR_UND:
+        raise TimeSeriesError, \
+            "Cannot convert a series with UNDEFINED frequency."
+
     if not series.isvalid():
         raise TimeSeriesError, \
             "Cannot adjust a series with missing or duplicated dates."
@@ -1189,9 +1197,6 @@
     if position.upper() not in ('END','START'):
         raise ValueError("invalid value for position argument: (%s)",str(position))
 
-    toFreq = freq
-    fromFreq = series.freq
-
     start_date = series._dates[0]
 
     if series.size == 0:




More information about the Scipy-svn mailing list