diff options
| author | Eric Wieser <wieser.eric@gmail.com> | 2018-02-22 01:46:28 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-22 01:46:28 -0800 |
| commit | 8db6698657e1294c6c79db39b19c94b19cfe8c08 (patch) | |
| tree | bb331800dbe2799ea404d8303b4610fdb140b5b0 | |
| parent | 173a9e3eb37826e2524f5dd66aab24fcf203068b (diff) | |
| parent | 579034a0c925ee9db5157141d73209beca037aeb (diff) | |
| download | numpy-8db6698657e1294c6c79db39b19c94b19cfe8c08.tar.gz | |
Merge pull request #10599 from girving/flatnonzero
ENH: Make flatnonzero call asanyarray before ravel()
| -rw-r--r-- | doc/release/1.15.0-notes.rst | 5 | ||||
| -rw-r--r-- | numpy/core/numeric.py | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/doc/release/1.15.0-notes.rst b/doc/release/1.15.0-notes.rst index 0b1408d1f..2aa102316 100644 --- a/doc/release/1.15.0-notes.rst +++ b/doc/release/1.15.0-notes.rst @@ -114,5 +114,10 @@ Previously an array was returned for integer scalar inputs, which is inconsistent with the behavior for float inputs, and that of ufuncs in general. For all types of scalar or 0d input, the result is now a scalar. +``np.flatnonzero`` works on numpy-convertible types +--------------------------------------------------- +``np.flatnonzero`` now uses ``np.ravel(a)`` instead of ``a.ravel()``, so it +works for lists, tuples, etc. + Changes ======= diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 123bff2ec..5c8951474 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -829,12 +829,12 @@ def flatnonzero(a): """ Return indices that are non-zero in the flattened version of a. - This is equivalent to a.ravel().nonzero()[0]. + This is equivalent to np.nonzero(np.ravel(a))[0]. Parameters ---------- - a : ndarray - Input array. + a : array_like + Input data. Returns ------- @@ -862,7 +862,7 @@ def flatnonzero(a): array([-2, -1, 1, 2]) """ - return a.ravel().nonzero()[0] + return np.nonzero(np.ravel(a))[0] _mode_from_name_dict = {'v': 0, |
