bundles / numpy latest / numpy / lib / array_utils / normalize_axis_tuple
function
numpy.lib.array_utils:normalize_axis_tuple
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/numeric.py :1418
Signature
def normalize_axis_tuple ( axis , ndim , argname = None , allow_duplicate = False ) Summary
Normalizes an axis argument into a tuple of non-negative integer axes.
Extended Summary
This handles shorthands such as 1 and converts them to (1,), as well as performing the handling of negative indices covered by normalize_axis_index.
By default, this forbids axes from being specified multiple times.
Used internally by multi-axis-checking logic.
Parameters
axis: int, iterable of intThe un-normalized index or indices of the axis.
ndim: intThe number of dimensions of the array that
axisshould be normalized against.argname: str, optionalA prefix to put before the error message, typically the name of the argument.
allow_duplicate: bool, optionalIf False, the default, disallow an axis from being specified twice.
Returns
normalized_axes: tuple of intThe normalized axis index, such that
0 <= normalized_axis < ndim
Raises
: AxisErrorIf any axis provided is out of range
: ValueErrorIf an axis is repeated
See also
- normalize_axis_index
normalizing a single scalar axis
Aliases
-
numpy.lib._array_utils_impl.normalize_axis_tuple