In article <4630FDD9.9030307@ieee.org>, Travis Oliphant <oliphant.travis@ieee.org> wrote:
Russell E. Owen asked how best to translate some numarray code that determines if an array is in big-endian order...
What are you trying to test for (where a data-type is big-endian or not?).
I really want to know if the array is in big-endian order (I don't care whether it's native). This is for sending arrays to the ds9 image viewer via xpa (and communicating with ds9 is not easy). To do this reliably I need to indicate the byte order of the data. I suppose there are alternatives such as making a "native byte order" copy of the data and sending that without any flag. But I think it's easier to just send the flag.
To directly answer your question, however.
On page 42 of the sample pages (online for free) of my book, the recommended translation of numarray's arr.isbyteswapped() is (not arr.dtype.isnative)
I found that (I own your book).
The translation of numarray.isBigEndian is (not numpy.little_endian)
I missed that one (and I did look for it).
... isBigEndian = arr.dtype.isnative ^ numpy.little_endian
That should be much clearer than my translation. Thanks! -- Russell