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

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Jan 23 16:16:01 EST 2007


Author: mattknox_ca
Date: 2007-01-23 15:15:58 -0600 (Tue, 23 Jan 2007)
New Revision: 2602

Modified:
   trunk/Lib/sandbox/timeseries/tseries.py
Log:
added missing date info properties for TimeSeries class. Set start_date and end_date methods as properties.

Modified: trunk/Lib/sandbox/timeseries/tseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tseries.py	2007-01-23 21:05:27 UTC (rev 2601)
+++ trunk/Lib/sandbox/timeseries/tseries.py	2007-01-23 21:15:58 UTC (rev 2602)
@@ -109,9 +109,9 @@
         return True
     if a.freq != b.freq:
         raise TimeSeriesCompatibilityError('freq', a.freq, b.freq)
-    elif a.start_date() != b.start_date():
+    elif a.start_date != b.start_date:
         raise TimeSeriesCompatibilityError('start_date', 
-                                           a.start_date(), b.start_date())
+                                           a.start_date, b.start_date)
     elif (a._dates.get_steps() != b._dates.get_steps()).any():
         raise TimeSeriesCompatibilityError('time_steps', 
                                            a._dates.get_steps(), b._dates.get_steps())
@@ -416,32 +416,70 @@
     def freq(self):
         """Returns the corresponding frequency."""
         return self._dates.freq
-#    @property
-    def years(self):
-        """Returns the corresponding years."""
-        return self._dates.years
-#    @property
-    def months(self):
-        """Returns the corresponding months."""
-        return self._dates.months
-#    @property
-    def yeardays(self):
-        """Returns the corresponding days of year."""
-        return self._dates.yeardays
-    day_of_year = yeardays
-#    @property
-    def weekdays(self):
-        """Returns the corresponding days of weeks."""
+        
+    @property
+    def day(self):          
+        "Returns the day of month for each date in self._dates."
+        return self._dates.day
+    @property
+    def day_of_week(self):  
+        "Returns the day of week for each date in self._dates."
         return self._dates.day_of_week
-    day_of_week = weekdays
+    @property
+    def day_of_year(self):  
+        "Returns the day of year for each date in self._dates."
+        return self._dates.day_of_year
+    @property
+    def month(self):        
+        "Returns the month for each date in self._dates."
+        return self._dates.month
+    @property
+    def quarter(self):   
+        "Returns the quarter for each date in self._dates."   
+        return self._dates.quarter
+    @property
+    def year(self):         
+        "Returns the year for each date in self._dates."
+        return self._dates.year
+    @property
+    def second(self):    
+        "Returns the seconds for each date in self._dates."  
+        return self._dates.second
+    @property
+    def minute(self):     
+        "Returns the minutes for each date in self._dates."  
+        return self._dates.minute
+    @property
+    def hour(self):         
+        "Returns the hour for each date in self._dates."
+        return self._dates.hour
+    @property
+    def week(self):
+        "Returns the week for each date in self._dates."
+        return self._dates.week
+
+    days = day
+    weekdays = day_of_week
+    yeardays = day_of_year
+    months = month
+    quarters = quarter
+    years = year
+    seconds = second
+    minutes = minute
+    hours = hour
+    weeks = week
+
     
+    @property
     def start_date(self):
         """Returns the first date of the series."""
         return self._dates[0]
-#
+
+    @property
     def end_date(self):
         """Returns the last date of the series."""
         return self._dates[-1]
+
     
     def isvalid(self):
         """Returns whether the series has no duplicate/missing dates."""
@@ -1003,10 +1041,10 @@
         raise TimeSeriesError, \
             "Cannot adjust a series with missing or duplicated dates."
     
-    start_date = kwargs.pop('start_date', min([x.start_date() for x in series]))
+    start_date = kwargs.pop('start_date', min([x.start_date for x in series]))
     if isinstance(start_date,str):
         start_date = Date(common_freq, string=start_date)
-    end_date = kwargs.pop('end_date', max([x.end_date() for x in series]))
+    end_date = kwargs.pop('end_date', max([x.end_date for x in series]))
     if isinstance(end_date,str):
         end_date = Date(common_freq, string=end_date)
     




More information about the Scipy-svn mailing list