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

scipy-svn at scipy.org scipy-svn at scipy.org
Wed Dec 20 12:10:22 EST 2006


Author: mattknox_ca
Date: 2006-12-20 11:10:19 -0600 (Wed, 20 Dec 2006)
New Revision: 2441

Modified:
   trunk/Lib/sandbox/timeseries/tsdate.py
Log:
code cleanup

Modified: trunk/Lib/sandbox/timeseries/tsdate.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tsdate.py	2006-12-20 17:09:08 UTC (rev 2440)
+++ trunk/Lib/sandbox/timeseries/tsdate.py	2006-12-20 17:10:19 UTC (rev 2441)
@@ -14,7 +14,6 @@
             if self.freq == 'D':
                 self.mxDate = mx.DateTime.DateTimeFromAbsDays(value-1)
             elif self.freq == 'B':
-                #originDate + val + (val//5)*7 - (val//5)*5
                 value -= 1
                 self.mxDate = mx.DateTime.DateTimeFromAbsDays(value + (value//5)*7 - (value//5)*5)
             elif self.freq == 'S':
@@ -100,15 +99,15 @@
     def __radd__(self, other): return self+other
     
     def __sub__(self, other):
-        try: return self + (-1) * other
-        except: pass
-        try:
+        if isinstance(other, Date):
             if self.freq != other.freq:
                 raise ValueError("Cannont subtract dates of different frequency (" + str(self.freq) + " != " + str(other.freq) + ")")
-            return int(self) - int(other)
-        except TypeError: 
-            raise TypeError("Could not subtract types " + str(type(self)) + " and " + str(type(other)))
+            else:
+                return int(self) - int(other) 
+        else:
+            return self + (-1) * int(other)
 
+
     def __repr__(self): return "<" + str(self.freq) + ":" + str(self) + ">"
     
     def __eq__(self, other):




More information about the Scipy-svn mailing list