Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.dtype.newbyteorder

dtype.newbyteorder(new_order='S')

Return a new dtype with a different byte order.

Changes are also made in all fields and sub-arrays of the data type.

Parameters:
new_order:string, optional

Byte order to force; a value from the byte order specificationsbelow. The default value (‘S’) results in swapping the currentbyte order.new_order codes can be any of:

  • ‘S’ - swap dtype from current to opposite endian
  • {‘<’, ‘L’} - little endian
  • {‘>’, ‘B’} - big endian
  • {‘=’, ‘N’} - native order
  • {‘|’, ‘I’} - ignore (no change to byte order)

The code does a case-insensitive check on the first letter ofnew_order for these alternatives. For example, any of ‘>’or ‘B’ or ‘b’ or ‘brian’ are valid to specify big-endian.

Returns:
new_dtype:dtype

New dtype object with the given change to the byte order.

Notes

Changes are also made in all fields and sub-arrays of the data type.

Examples

>>>importsys>>>sys_is_le=sys.byteorder=='little'>>>native_code=sys_is_leand'<'or'>'>>>swapped_code=sys_is_leand'>'or'<'>>>native_dt=np.dtype(native_code+'i2')>>>swapped_dt=np.dtype(swapped_code+'i2')>>>native_dt.newbyteorder('S')==swapped_dtTrue>>>native_dt.newbyteorder()==swapped_dtTrue>>>native_dt==swapped_dt.newbyteorder('S')True>>>native_dt==swapped_dt.newbyteorder('=')True>>>native_dt==swapped_dt.newbyteorder('N')True>>>native_dt==native_dt.newbyteorder('|')True>>>np.dtype('<i2')==native_dt.newbyteorder('<')True>>>np.dtype('<i2')==native_dt.newbyteorder('L')True>>>np.dtype('>i2')==native_dt.newbyteorder('>')True>>>np.dtype('>i2')==native_dt.newbyteorder('B')True

Previous topic

numpy.dtype

Next topic

numpy.dtype.type

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp