coordinates.mixins.core.CoordinateSystemAxesMixin.get_axes_permutation#

static CoordinateSystemAxesMixin.get_axes_permutation(src_axes: Sequence[str], dst_axes: Sequence[str]) List[int][source]#

Compute the permutation needed to reorder src_axes into dst_axes.

Parameters:
  • src_axes (list of str) – The current ordering of axes.

  • dst_axes (list of str) – The desired target ordering.

Returns:

Indices describing how to reorder src_axes to match dst_axes.

Return type:

list of int

Raises:

ValueError – If the two lists are not permutations of each other.

Examples

>>> from pymetric.coordinates import SphericalCoordinateSystem
>>> cs = SphericalCoordinateSystem()
>>> cs.get_axes_permutation(["theta", "r"], ["r", "theta"])
[1, 0]

If an element is not in one or the other sets, then an error occurs.

>>> cs.get_axes_permutation(["theta", "r", 'phi'], ["r", "theta"]) 
ValueError: `src_axes` and `dst_axes` must be permutations of each other.