You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Confusing ndarray repr: always shows dtype as if in native byteorder #19059
>>>fromnumpyimportarray, dtype# The repr of a dtype object distinguishes non-native byteorder.>>>dtype('<u2')
dtype('uint16')
>>>dtype('>u2')
dtype('>u2')
# But arrays always use the repr of the native endianness>>>array([0], dtype='<u2')
array([0], dtype=uint16)
>>>array([0], dtype='>u2')
array([0], dtype=uint16) # <-- this is confusing
This isn't strictly speaking a bug, but using the byteorder-sensitive repr of the dtype instead would make it easier to tell when you have an endianness issue in e.g. this StackOverflow question.
Activity
Zac-HD commentedon Aug 22, 2021
@mattip - any tips on where I should be looking to fix this?
Twenty minutes with
grepand examining various__repr__-related code snippets didn't get me anywhere, though I can see from https://github.com/numpy/numpy/blob/main/numpy/core/_dtype.py that it might be tricky if I can't simply have thearrayrepr defer to thedtyperepr...seberg commentedon Mar 14, 2023
Closed by gh-23295