diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-05-17 22:49:41 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-05-17 22:49:41 +0000 |
commit | 1b425c5c98cfd68dff1741e35cb4e846b78fbd99 (patch) | |
tree | 59f09b8112e5da0359e728dcb57841dceac75366 /numpy/lib/index_tricks.py | |
parent | a27f468bd852b6ff7cce4740c2980b5e66081e41 (diff) | |
download | numpy-1b425c5c98cfd68dff1741e35cb4e846b78fbd99.tar.gz |
Rename fromflat to unravel_index. Add argwhere function. Change where docstring to reflect truth.
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r-- | numpy/lib/index_tricks.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 444c67e03..6f9d14e3e 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -1,6 +1,6 @@ ## Automatically adapted for numpy Sep 19, 2005 by convertcode.py -__all__ = ['fromflat', +__all__ = ['unravel_index', 'mgrid', 'ogrid', 'r_', 'c_', 's_', @@ -16,16 +16,15 @@ import function_base import numpy.core.defmatrix as matrix makemat = matrix.matrix - -# fromflat contributed by Stefan van der Walt -def fromflat(x,dims): +# contributed by Stefan van der Walt +def unravel_index(x,dims): """Convert a flat index into an index tuple for a matrix of given shape. - e.g. for a 2x2 matrix, fromflat(2,(2,2)) translates to (1,0). + e.g. for a 2x2 matrix, unravel_index(2,(2,2)) returns (1,0). Example usage: p = x.argmax() - idx = fromflat(p) + idx = unravel_index(p) x[idx] == x.max() Note: x.flat[p] == x.max() |