moveaxis

Contents

moveaxis#

class brainunit.math.moveaxis(a, source, destination, **kwargs)#

Moves axes of a quantity or an array to new positions. Other axes remain in their original order.

Parameters:
  • a (Array | saiunit.Quantity) – The array whose axes should be reordered.

  • source (int | Tuple[int, ...]) – Original positions of the axes to move. These must be unique.

  • destination (int | Tuple[int, ...]) – Destination positions for each of the original axes. These must also be unique.

Returns:

result – Array with moved axes. This array is a view of the input array.

Return type:

Array | saiunit.Quantity

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> a = jnp.zeros((3, 4, 5)) * u.meter
>>> u.math.moveaxis(a, 0, -1).shape
(4, 5, 3)