From 1d3bcb446771ff16e9cf06e3a5d9cac20e68c4ac Mon Sep 17 00:00:00 2001 From: jaimefrio Date: Tue, 20 Jan 2015 19:15:00 -0800 Subject: ENH: Make swapaxes always return a view swapaxes now returns a view of the input array when the axes to swap are both the same, not the input array as it used to do. Fixes #5260 --- numpy/core/fromnumeric.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 2a527a4a4..aef09411a 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -464,8 +464,10 @@ def swapaxes(a, axis1, axis2): Returns ------- a_swapped : ndarray - If `a` is an ndarray, then a view of `a` is returned; otherwise - a new array is created. + For Numpy >= 1.10, if `a` is an ndarray, then a view of `a` is + returned; otherwise a new array is created. For earlier Numpy + versions a view of `a` is returned only if the order of the + axes is changed, otherwise the input array is returned. Examples -------- -- cgit v1.2.1