normalized_axes_tuple

odl.util.normalize.normalized_axes_tuple(axes, ndim)[source]

Return a tuple of axes converted to positive integers.

This function turns negative entries into equivalent positive ones according to standard Python indexing "from the right".

Parameters:
axesint or sequence of ints

Single integer or integer sequence of arbitrary length. Duplicate entries are not allowed. All entries must fulfill -ndim <= axis <= ndim - 1.

ndimpositive int

Number of available axes determining the valid axis range.

Returns:
axes_listtuple of ints

The converted tuple of axes.

Examples

Normalizing a sequence of axes:

>>> normalized_axes_tuple([0, -1, 2], ndim=3)
(0, 2, 2)

Single integer works, too:

>>> normalized_axes_tuple(-3, ndim=3)
(0,)