summaryrefslogtreecommitdiff
path: root/numpy/lib/index_tricks.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r--numpy/lib/index_tricks.py11
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()