moveaxis

moveaxis(x: array, source: int | Tuple[int, ...], destination: int | Tuple[int, ...], /) array

Moves array axes (dimensions) to new positions, while leaving other axes in their original positions.

Parameters:
  • x (array) – input array.

  • source (Union[int, Tuple[int, ...]]) – Axes to move. Provided axes must be unique. If x has rank (i.e, number of dimensions) N, a valid axis must reside on the half-open interval [-N, N).

  • destination (Union[int, Tuple[int, ...]]) – indices defining the desired positions for each respective source axis index. Provided indices must be unique. If x has rank (i.e, number of dimensions) N, a valid axis must reside on the half-open interval [-N, N).

Returns:

out (array) – an array containing reordered axes. The returned array must have the same data type as x.

Notes

New in version 2023.12.