summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@climate.com>2015-11-04 20:08:57 -0800
committerStephan Hoyer <shoyer@climate.com>2016-01-09 15:56:13 -0800
commit8ffde7f488eb583ed2a200702e85a6518c4f94ec (patch)
treefc7a3eed899e6677fbbf6f40f54b03a0257bed3f /numpy/core/fromnumeric.py
parent8a76291c76aa9b33b18ceb06f6e8f37f990c9e27 (diff)
downloadnumpy-8ffde7f488eb583ed2a200702e85a6518c4f94ec.tar.gz
ENH: moveaxis function
Fixes GH2039 This function provides a much more intuitive interface than `np.rollaxis`, which has a confusing behavior with the position of the `start` argument: http://stackoverflow.com/questions/29891583/reason-why-numpy-rollaxis-is-so-confusing It was independently suggested several times over the years after discussions on the mailing list and GitHub (GH2039), but never made it into a pull request: https://mail.scipy.org/pipermail/numpy-discussion/2010-September/052882.html My version adds support for a sequence of axis arguments. I find this behavior to be very useful. It is often more intuitive than supplying a list of arguments to `transpose` and also nicely generalizes NumPy's existing axis manipulation routines, e.g., def transpose(a, order=None): if order is None: order = reversed(range(a.ndim)) return moveaxes(a, order, range(a.ndim)) def swapaxes(a, axis1, axis2): return moveaxes(a, [axis1, axis2], [axis2, axis1]) def rollaxis(a, axis, start=0): if axis < start: start -= 1 return moveaxes(a, axis, start)
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index a2937c5c5..67d2c5b48 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -518,7 +518,7 @@ def transpose(a, axes=None):
See Also
--------
- rollaxis
+ moveaxis
argsort
Notes