[NumPy-Tickets] [NumPy] #1608: numpy.sort on a flattened array has unwanted side-effect
NumPy Trac
numpy-tickets@scipy....
Thu Sep 9 17:45:54 CDT 2010
#1608: numpy.sort on a flattened array has unwanted side-effect
---------------------------+------------------------------------------------
Reporter: carlscheffler | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.5.1
Component: numpy.core | Version: 1.3.0
Keywords: sort, flat |
---------------------------+------------------------------------------------
(The code example below should be self-explanatory.)
The sort function has the side-effect of changing/removing the view
information of its argument when called with argument.flat. This side-
effect does not appear when using sort(ravel(argument)) rather than
sort(argument.flat).
Tested on
* Python version 2.6.5, NumPy version 1.3.0; and
* Python version 2.6.2, NumPy version 1.2.1.
{{{
import numpy
x = numpy.array([[1,2],[3,4]])
x = x.transpose() # Create a transposed view of the original array
print x # [[1, 3], [2, 4]] -- OK
y = numpy.sort(numpy.ravel(x))
print x # [[1, 3], [2, 4]] -- OK
y = numpy.sort(x.flat)
print x # [[1, 2], [3, 4]] -- ERROR
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1608>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list