moveaxis#
- class saiunit.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 (
Union[Array, saiunit.Quantity]) – The array whose axes should be reordered.source (
Union[int,Tuple[int,...]]) – Original positions of the axes to move. These must be unique.destination (
Union[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:
Union[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)