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

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Jan 22 15:16:00 CST 2007


Author: mattknox_ca
Date: 2007-01-22 15:15:50 -0600 (Mon, 22 Jan 2007)
New Revision: 2587

Modified:
   trunk/Lib/sandbox/timeseries/tdates.py
Log:
fixed problem with DateArray __getitem__ method which wouldn't let a DateArray instance be used as the data in a masked array

Modified: trunk/Lib/sandbox/timeseries/tdates.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tdates.py	2007-01-22 15:30:37 UTC (rev 2586)
+++ trunk/Lib/sandbox/timeseries/tdates.py	2007-01-22 21:15:50 UTC (rev 2587)
@@ -13,6 +13,7 @@
 import datetime
 import itertools
 import warnings
+import types
 
 
 import numpy
@@ -541,7 +542,11 @@
             except AttributeError:
                 pass     
         r = ndarray.__getitem__(self, index)
-        if r.size == 1:
+
+        if not hasattr(r, "size"):
+            if type(r) == types.IntType: return Date(self.freq, value=r)
+            else: return r
+        elif r.size == 1:
             # Only one element, and it's not a scalar: we have a DateArray of size 1
             if len(r.shape) > 0:
                 r = r.item()



More information about the Scipy-svn mailing list