[Numpy-discussion] Recarray comparison and byte order
matthew.brett at gmail.com
Sun Nov 1 01:45:09 EDT 2009
>> c = a.byteswap().newbyteorder()
>> c == a
> In the last two lines, a variable "c" is assigned to a modified "a". The
> next line tests (==) to see if "c" is the same as (==) the unmodified "a".
> It isn't, because "c" is the modified "a". Hence, "False".
Sorry, I wasn't very clear - the stuff in brackets is what gets echoed
to the terminal, and '==' was deliberate.
The field values in 'a' and 'c' are all equal, so I was expecting what
I got for comparing - for example 'a' to a copy of itself. Non-record
arrays also behave as I expected after byteswapping:
In : a = np.arange(3, dtype='u2')
In : c = a.byteswap().newbyteorder()
In : a == c
Out: array([ True, True, True], dtype=bool)
More information about the NumPy-Discussion