coordinates.mixins.core.CoordinateSystemAxesMixin.get_axes_from_mask#

CoordinateSystemAxesMixin.get_axes_from_mask(mask: ndarray) List[str][source]#

Convert a boolean axis mask into a list of axis names.

This method reverses the effect of build_axes_mask() by returning the axis names corresponding to True values in the provided mask.

Parameters:

mask (np.ndarray) – A boolean array of length ndim where each True value indicates that the corresponding axis is selected. Must match the length of self.__AXES__.

Returns:

The names of the axes that are selected in the mask.

Return type:

list of str

Raises:

ValueError – If the mask does not have the same length as the number of coordinate axes.

Notes

This is the inverse of build_axes_mask():

>>> mask = cs.build_axes_mask(["r", "phi"])
>>> cs.get_axes_from_mask(mask)
['r', 'phi']

Examples

>>> from pymetric.coordinates import SphericalCoordinateSystem
>>> cs = SphericalCoordinateSystem()
>>> mask = np.array([True, False, True])
>>> cs.get_axes_from_mask(mask)
['r', 'phi']