[Scipy-svn] r2966 - trunk/Lib/ndimage

scipy-svn at scipy.org scipy-svn at scipy.org
Sat May 5 08:25:36 EDT 2007


Author: stefan
Date: 2007-05-05 07:25:22 -0500 (Sat, 05 May 2007)
New Revision: 2966

Modified:
   trunk/Lib/ndimage/measurements.py
Log:
Force index to be of type int32 on 64-bit platform.


Modified: trunk/Lib/ndimage/measurements.py
===================================================================
--- trunk/Lib/ndimage/measurements.py	2007-05-05 09:26:12 UTC (rev 2965)
+++ trunk/Lib/ndimage/measurements.py	2007-05-05 12:25:22 UTC (rev 2966)
@@ -116,14 +116,11 @@
         if labels.shape != input.shape:
             raise RuntimeError, 'input and labels shape are not equal'
     if index is not None:
-        if numpy.isscalar(index):
-            index = numpy.asarray(index,dtype=numpy.uint32)
-        else:
-            index = numpy.asarray(index)
-
-        if numpy.issubsctype(index.dtype,numpy.int64) or \
-               numpy.issubsctype(index.dtype,numpy.uint64):
+        T = getattr(index,'dtype',numpy.int32)
+        if numpy.issubsctype(T,numpy.int64) or \
+               numpy.issubsctype(T,numpy.uint64):
             raise ValueError("Index values cannot be of type int64/uint64.")
+        index = numpy.asarray(index,dtype=T)
     return _nd_image.statistics(input, labels, index, 0)
 
 




More information about the Scipy-svn mailing list