-
matrix.byteswap(inplace)
-
Swap the bytes of the array elements
Toggle between low-endian and big-endian data representation by returning a byteswapped array, optionally swapped in-place.
Parameters: inplace : bool, optional
If
True
, swap bytes in-place, default isFalse
.Returns: out : ndarray
The byteswapped array. If
inplace
isTrue
, this is a view to self.Examples
1234567>>> A
=
np.array([
1
,
256
,
8755
], dtype
=
np.int16)
>>>
map
(
hex
, A)
[
'0x1'
,
'0x100'
,
'0x2233'
]
>>> A.byteswap(
True
)
array([
256
,
1
,
13090
], dtype
=
int16)
>>>
map
(
hex
, A)
[
'0x100'
,
'0x1'
,
'0x3322'
]
Arrays of strings are not swapped
1234>>> A
=
np.array([
'ceg'
,
'fac'
])
>>> A.byteswap()
array([
'ceg'
,
'fac'
],
dtype
=
'|S3'
)
matrix.byteswap()

2025-01-10 15:47:30
Please login to continue.