Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-31 Thread Matthew Brett
Hi, I can see your point I think, that situation 1 seems to be the more common and obvious, and coming at it from outside, you would have thought that a.byteswap would change both. I think the reason that byteswap behaves the way it does is that for situation 1 you often don't actually

Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-30 Thread Francesc Altet
El dt 29 de 05 del 2007 a les 14:17 -0400, en/na Erin Sheldon va escriure: Hi all - I have read some big-endian data and I want to byte swap it to little endian. If I use a.byteswap(True) the bytes clearly get swapped, but the dtype is not updated to reflect the new data type. e.g

Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-30 Thread Erin Sheldon
On 5/30/07, Francesc Altet [EMAIL PROTECTED] wrote: El dt 29 de 05 del 2007 a les 14:17 -0400, en/na Erin Sheldon va escriure: Hi all - I have read some big-endian data and I want to byte swap it to little endian. If I use a.byteswap(True) the bytes clearly get swapped, but the

Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-30 Thread Matthew Brett
Hi, This doesn't make any sense. The numbers have changed but the dtype is now incorrect. If you byteswap and correct the dtype the numbers have still changed, but you now can actually use the object. By numbers have still changed I mean the underlying byte order is still different,

Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-30 Thread Erin Sheldon
Matthew, this is a very clear description of all the issues, and I now see why it can be useful to keep the two methods separate. I think an update to the doc string for byteswap() with this description would be useful. Or perhaps a keyword to byteswap() in which one could specify the behavior

Re: [Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-30 Thread Anne Archibald
On 30/05/07, Matthew Brett [EMAIL PROTECTED] wrote: I think the point is that you can have several different situations with byte ordering: 1) Your data and dtype endianess match, but you want the data swapped and the dtype to reflect this 2) Your data and dtype endianess don't match, and

[Numpy-discussion] byteswap() leaves dtype unchanged

2007-05-29 Thread Erin Sheldon
Hi all - I have read some big-endian data and I want to byte swap it to little endian. If I use a.byteswap(True) the bytes clearly get swapped, but the dtype is not updated to reflect the new data type. e.g [~]|1 a=N.array([2.5, 3.2]) [~]|2 a.dtype.descr 2 [('', 'f8')] [~]|3