[Numpy-discussion] LittleEndian (original) (raw)
Albert Strasheim fullung at gmail.com
Wed Jun 21 09:58:28 EDT 2006
- Previous message (by thread): [Numpy-discussion] LittleEndian
- Next message (by thread): [Numpy-discussion] SciPy 2006 Tutorials
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hey Sheldon
With NumPy you can use dtype's newbyteorder method to convert any dtype's byte order to an order you specify:
In [1]: import numpy as N In [2]: x = N.array([1],dtype='<i4') In [3]: y = N.array([1],dtype='>i4') In [4]: xle = N.asarray(x, dtype=x.dtype.newbyteorder('<')) In [5]: yle = N.asarray(y, dtype=y.dtype.newbyteorder('<'))
In [6]: x.dtype Out[6]: dtype('<i4')
In [7]: y.dtype Out[7]: dtype('>i4')
In [8]: xle.dtype Out[8]: dtype('<i4')
In [9]: yle.dtype Out[9]: dtype('<i4')
Regards,
Albert
-----Original Message----- From: numpy-discussion-bounces at lists.sourceforge.net [mailto:numpy-_ _discussion-bounces at lists.sourceforge.net] On Behalf Of Johnston Sheldon Sent: 21 June 2006 15:31 To: Numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] LittleEndian
Hi, Can someone give a brief example of the Numeric function LittleEndian? I have written two separate functions to read binary data that can be either LittleEndian or BigEndian (using byteswapped() ) but it would be great with just one function.
- Previous message (by thread): [Numpy-discussion] LittleEndian
- Next message (by thread): [Numpy-discussion] SciPy 2006 Tutorials
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]