[Numpy-discussion] Recarray comparison and byte order

Matthew Brett matthew.brett@gmail....
Sun Nov 1 00:45:09 CDT 2009


Hi,

>> 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 [2]: a = np.arange(3, dtype='u2')

In [3]: c = a.byteswap().newbyteorder()

In [4]: a == c
Out[4]: array([ True,  True,  True], dtype=bool)

Best,

Matthew


More information about the NumPy-Discussion mailing list