Revision: 6836
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6836&view=rev
Author:   jswhit
Date:     2009-01-26 22:49:01 +0000 (Mon, 26 Jan 2009)

Log Message:
-----------
bugfixes for date2index

Modified Paths:
--------------
    trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py

Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py       
2009-01-26 20:27:50 UTC (rev 6835)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py       
2009-01-26 22:49:01 UTC (rev 6836)
@@ -7,7 +7,7 @@
 _units = ['days','hours','minutes','seconds','day','hour','minute','second']
 _calendars = 
['standard','gregorian','proleptic_gregorian','noleap','julian','all_leap','365_day','366_day','360_day']
 
-__version__ = '0.7'
+__version__ = '0.7.1'
 
 class datetime:
     """
@@ -975,22 +975,29 @@
         index[:] = (num-t0)/dt
 
         # convert numpy scalars or single element arrays to python ints.
-        if not len(index.shape) or index.shape == (1,):
-            index = index.item()
+        index = _toscalar(index)
 
         # Checking that the index really corresponds to the given date.
         _check_index(index, dates, nctime, calendar)
 
     except AssertionError:
+
+        index = numpy.empty(numpy.alen(dates), int)
+
         # If check fails, use brute force method.
         index[:] = numpy.digitize(num, nctime[:]) - 1
 
         # convert numpy scalars or single element arrays to python ints.
-        if not len(index.shape) or index.shape == (1,):
-            index = index.item()
+        index = _toscalar(index)
 
         # Perform check again.
         _check_index(index, dates, nctime, calendar)
 
     return index
 
+
+def _toscalar(a):
+    if a.shape in [(),(1,)]:
+        return a.item()
+    else:
+        return a


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to