numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturnsBackRef
normalize_axis_index(axis, ndim, msg_prefix=None)

Used internally by all axis-checking logic.

versionadded

Parameters

axis : int

The un-normalized index of the axis. Can be negative

ndim : int

The number of dimensions of the array that :None:None:`axis` should be normalized against

msg_prefix : str

A prefix to put before the message, typically the name of the argument

Raises

AxisError

If the axis index is invalid, when :None:None:`-ndim <= axis < ndim` is false.

Returns

normalized_axis : int

The normalized axis index, such that :None:None:`0 <= normalized_axis < ndim`

Normalizes an axis index, :None:None:`axis`, such that is a valid positive index into the shape of array with ndim dimensions. Raises an AxisError with an appropriate message if this is not possible.

Examples

This example is valid syntax, but we were not able to check execution
>>> normalize_axis_index(0, ndim=3)
0
This example is valid syntax, but we were not able to check execution
>>> normalize_axis_index(1, ndim=3)
1
This example is valid syntax, but we were not able to check execution
>>> normalize_axis_index(-1, ndim=3)
2
This example is valid syntax, but we were not able to check execution
>>> normalize_axis_index(3, ndim=3)
Traceback (most recent call last):
...
AxisError: axis 3 is out of bounds for array of dimension 3
This example is valid syntax, but we were not able to check execution
>>> normalize_axis_index(-4, ndim=3, msg_prefix='axes_arg')
Traceback (most recent call last):
...
AxisError: axes_arg: axis -4 is out of bounds for array of dimension 3
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.core.numeric.normalize_axis_tuple

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : None#None
type: <class 'builtin_function_or_method'>
Commit: