[Numpy-svn] r2965 - in trunk/numpy: core lib linalg

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Aug 5 02:50:54 CDT 2006


Author: oliphant
Date: 2006-08-05 02:50:50 -0500 (Sat, 05 Aug 2006)
New Revision: 2965

Modified:
   trunk/numpy/core/numeric.py
   trunk/numpy/lib/function_base.py
   trunk/numpy/linalg/linalg.py
Log:
Move location of flatnonzero

Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2006-08-05 07:48:48 UTC (rev 2964)
+++ trunk/numpy/core/numeric.py	2006-08-05 07:50:50 UTC (rev 2965)
@@ -16,7 +16,7 @@
            'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',
            'ones', 'identity', 'allclose',
            'seterr', 'geterr', 'setbufsize', 'getbufsize',
-           'seterrcall', 'geterrcall',
+           'seterrcall', 'geterrcall', 'flatnonzero',
            'Inf', 'inf', 'infty', 'Infinity',
            'nan', 'NaN', 'False_', 'True_']
 
@@ -178,6 +178,13 @@
     """
     return transpose(a.nonzero())
 
+def flatnonzero(a):
+    """Return indicies that are not-zero in flattened version of a
+
+    Equivalent to a.ravel().nonzero()[0]
+    """
+    return a.ravel().nonzero()[0]
+
 _mode_from_name_dict = {'v': 0,
                         's' : 1,
                         'f' : 2}

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2006-08-05 07:48:48 UTC (rev 2964)
+++ trunk/numpy/lib/function_base.py	2006-08-05 07:50:50 UTC (rev 2965)
@@ -8,7 +8,6 @@
            'histogram', 'bincount', 'digitize', 'cov', 'corrcoef', 'msort',
            'median', 'sinc', 'hamming', 'hanning', 'bartlett', 'blackman',
            'kaiser', 'trapz', 'i0', 'add_newdoc', 'add_docstring', 'meshgrid',
-           'flatnonzero'
            ]
 
 import types
@@ -998,11 +997,4 @@
     y = y.reshape(numRows,1)
     Y = y.repeat(numCols, axis=1)
     return X, Y
-
-def flatnonzero(a):
-    """Return indicies that are not-zero in flattened version of a
-
-    Equivalent to a.ravel().nonzero()[0]
-    """
-    return a.ravel().nonzero()[0]
     

Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2006-08-05 07:48:48 UTC (rev 2964)
+++ trunk/numpy/linalg/linalg.py	2006-08-05 07:50:50 UTC (rev 2965)
@@ -18,7 +18,7 @@
 from numpy.core import array, asarray, zeros, empty, transpose, \
         intc, single, double, csingle, cdouble, inexact, complexfloating, \
         newaxis, ravel, all, Inf, dot, add, multiply, identity, sqrt, \
-        maximum, nonzero, diagonal, arange, fastCopyAndTranspose, sum, \
+        maximum, flatnonzero, diagonal, arange, fastCopyAndTranspose, sum, \
         argsort
 from numpy.lib import triu
 from numpy.linalg import lapack_lite
@@ -313,7 +313,7 @@
         else:
             w = wr+1j*wi
             v = array(vr, w.dtype)
-            ind = nonzero(wi != 0.0)[0]      # indices of complex e-vals
+            ind = flatnonzero(wi != 0.0)      # indices of complex e-vals
             for i in range(len(ind)/2):
                 v[ind[2*i]] = vr[ind[2*i]] + 1j*vr[ind[2*i+1]]
                 v[ind[2*i+1]] = vr[ind[2*i]] - 1j*vr[ind[2*i+1]]



More information about the Numpy-svn mailing list