[NumPy-Tickets] [NumPy] #1608: numpy.sort on x.flat modifies x
NumPy Trac
numpy-tickets@scipy....
Fri Sep 10 03:35:16 CDT 2010
#1608: numpy.sort on x.flat modifies x
---------------------------+------------------------------------------------
Reporter: carlscheffler | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.5.1
Component: numpy.core | Version: 1.3.0
Keywords: sort, flat |
---------------------------+------------------------------------------------
Comment(by pv):
It actually really modifies the underlying array data:
{{{
>>> from numpy import array
>>> x = array([[1,2],[3,4]]).T
>>> x
array([[1, 3],
[2, 4]])
>>> x.__array_interface__['data']
(145697400, False)
>>> x.strides
(4, 8)
>>> str(x.data)
'\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00'
>>> array(x.flat)
array([1, 3, 2, 4])
>>> x
array([[1, 2],
[3, 4]])
>>> x.__array_interface__['data']
(145697400, False)
>>> x.strides
(4, 8)
>>> str(x.data)
'\x01\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00'
}}}
Gdb's `watch` command should help here.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1608#comment:5>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list