[NumPy-Tickets] [NumPy] #2185: recarray scalars are not swapped on assignment
NumPy Trac
numpy-tickets@scipy....
Sat Jul 14 10:23:50 CDT 2012
#2185: recarray scalars are not swapped on assignment
------------------------+---------------------------------------------------
Reporter: mbyt | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.7.0
Component: numpy.core | Version: 1.6.1
Keywords: |
------------------------+---------------------------------------------------
Hello,
numpy seems to not swap the byte order when assigning scalars in record
arrays:
{{{
#!python
>>> import numpy as np
>>>
>>> dt = np.dtype([
... ('head', '>u4'),
... ('data', '>u4', 2),
... ])
>>> buf = np.recarray(1, dtype=dt)
>>> buf[0]['head'] = 1
>>> buf[0]['data'][:] = [1,1]
>>>
>>> h = buf[0]['head']
>>> d = buf[0]['data'][0]
>>> buf[0]['head'] = h
>>> buf[0]['data'][0] = d
>>> print buf, '\n', h.dtype.byteorder, d.dtype.byteorder
[(16777216L, array([1, 1], dtype=uint32))]
= =
}}}
The byte order of both, h and d is native. However, when
reassigning the scalar head in the recarray to h, the byte order is
not swapped and h gets wrapped around to 16777216L
(should be 1). Interestingly, the same is ok with an element of a vector
(d stays 1, thus is swapped).
This behavior is the same on windows 32bit, python 2.7.4, numpy 1.6.2.
and on linux 32bit, python 2.6.6, numpy 1.4.1.
Keep up the good work and cheers,[[BR]]
Moritz
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2185>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list