[Numpy-svn] r3329 - trunk/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Oct 13 14:26:45 CDT 2006


Author: oliphant
Date: 2006-10-13 14:26:43 -0500 (Fri, 13 Oct 2006)
New Revision: 3329

Modified:
   trunk/numpy/lib/index_tricks.py
Log:
Fix mgrid for count of 1

Modified: trunk/numpy/lib/index_tricks.py
===================================================================
--- trunk/numpy/lib/index_tricks.py	2006-10-13 19:09:04 UTC (rev 3328)
+++ trunk/numpy/lib/index_tricks.py	2006-10-13 19:26:43 UTC (rev 3329)
@@ -132,7 +132,7 @@
                 start = key[k].start
                 if start is None: start=0
                 if step is None: step=1
-                if type(step) is type(1j):
+                if isinstance(step, complex):
                     size.append(int(abs(step)))
                     typ = float
                 else:
@@ -151,9 +151,10 @@
                 start = key[k].start
                 if start is None: start=0
                 if step is None: step=1
-                if type(step) is type(1j):
+                if isinstance(step, complex):
                     step = int(abs(step))
-                    step = (key[k].stop - start)/float(step-1)
+                    if step != 1:
+                        step = (key[k].stop - start)/float(step-1)
                 nn[k] = (nn[k]*step+start)
             if self.sparse:
                 slobj = [_nx.newaxis]*len(size)
@@ -167,10 +168,11 @@
             stop = key.stop
             start = key.start
             if start is None: start = 0
-            if type(step) is type(1j):
+            if isinstance(step, complex):
                 step = abs(step)
                 length = int(step)
-                step = (key.stop-start)/float(step-1)
+                if step != 1:
+                    step = (key.stop-start)/float(step-1)
                 stop = key.stop+step
                 return _nx.arange(0, length,1, float)*step + start
             else:



More information about the Numpy-svn mailing list