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 regarding the data type.
Erin On 5/30/07, Matthew Brett <[EMAIL PROTECTED]> wrote: > 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, but you can now use the object for mathematical > > operations. My point is that the metadata for the object should be > > correct after using it's built-in methods. > > 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 you want to swap the > data so that they match the dtype > > 3) Your data and dtype endianess don't match, and you want to change > the dtype so that it matches the data. > > I guess situation 1 is the one you have, and the way to deal with this > is, as you say: > > other_order_arr = one_order_arr.byteswap() > other_order_arr.dtype.newbyteorder() > > The byteswap method is obviously aimed at situation 2 (the data and > dtype don't match in endianness, and you want to swap the data). > > 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. > > Best, > > Matthew > _______________________________________________ > Numpy-discussion mailing list > [email protected] > http://projects.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
