[Numpy-discussion] Endian dtype specifier without using character codes?
Matthew Brett
matthew.brett at gmail.com
Fri Mar 9 06:04:53 EST 2018
Hi,
We (over at https://github.com/nipy/nibabel) often want to do stuff like this:
```
dtype_type = 'i'
size = 8
endianness = '<'
dtype = np.dtype('{}{}{}'.format(endianness, dtype_type, size))
```
I see that
"""
Use of the character codes, however, is discouraged.
"""
https://docs.scipy.org/doc/numpy-1.14.0/reference/arrays.scalars.html
What is the recommended way of specifying endianness in my dtype, if I
am not using the character codes? Do I have to use something like:
```
np.dtype('int64').newbyteorder(endianness)
```
?
Cheers,
Matthew
More information about the NumPy-Discussion
mailing list