summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/numeric.py9
-rw-r--r--numpy/lib/function_base.py8
-rw-r--r--numpy/linalg/linalg.py4
3 files changed, 10 insertions, 11 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 252ba70cd..aaf8989c3 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -16,7 +16,7 @@ __all__ = ['newaxis', 'ndarray', 'flatiter', 'ufunc',
'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 @@ def argwhere(a):
"""
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}
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 548af953d..a56233d34 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -8,7 +8,6 @@ __all__ = ['logspace', 'linspace',
'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 @@ def meshgrid(x,y):
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]
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index d80d36685..b2ab357b7 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -18,7 +18,7 @@ __all__ = ['solve',
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 @@ eigenvalue u[i]. Satisfies the equation dot(a, v[:,i]) = u[i]*v[:,i]
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]]