io.matlab.byteordercodes

Byteorder utilities for system - numpy byteorder encoding

Converts a variety of string codes for little endian, big endian, native byte order and swapped byte order to explicit numpy endian codes - one of ‘<’ (little endian) or ‘>’ (big endian)

Module Contents

Functions

to_numpy_code(code) Convert various order codings to numpy format.
to_numpy_code(code)

Convert various order codings to numpy format.

code : str
The code to convert. It is converted to lower case before parsing. Legal values are: ‘little’, ‘big’, ‘l’, ‘b’, ‘le’, ‘be’, ‘<’, ‘>’, ‘native’, ‘=’, ‘swapped’, ‘s’.
out_code : {‘<’, ‘>’}
Here ‘<’ is the numpy dtype code for little endian, and ‘>’ is the code for big endian.
>>> import sys
>>> sys_is_le == (sys.byteorder == 'little')
True
>>> to_numpy_code('big')
'>'
>>> to_numpy_code('little')
'<'
>>> nc = to_numpy_code('native')
>>> nc == '<' if sys_is_le else nc == '>'
True
>>> sc = to_numpy_code('swapped')
>>> sc == '>' if sys_is_le else sc == '<'
True