8000 recarray scalars are not swapped on assignment (Trac #2185) · Issue #638 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

recarray scalars are not swapped on assignment (Trac #2185) #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
numpy-gitbot opened this issue Oct 19, 2012 · 4 comments
Closed

recarray scalars are not swapped on assignment (Trac #2185) #638

numpy-gitbot opened this issue Oct 19, 2012 · 4 comments

Comments

@numpy-gitbot
Copy link

Original ticket http://projects.scipy.org/numpy/ticket/2185 on 2012-07-14 by trac user mbyt, assigned to unknown.

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

@numpy-gitbot
Copy link
Author

Attachment added by @seberg on 2012-08-08: 0001-Fix-of-issue-with-scalars-in-np.choose-np.where.patch

@numpy-gitbot
Copy link
Author

@seberg wrote on 2012-08-08

I think this is comes down to the same problem as #369
I am not quite sure if this is the right way to fix the issue though, but it does seem to fix it and my guess is that it is at least the correct place to fix it...

@numpy-gitbot
Copy link
Author

trac user ocertik wrote on 2012-08-31

This is now fixed by: #395

@numpy-gitbot
Copy link
Author

trac user ocertik wrote on 2012-08-31

PR was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0