numpy 1.22.4 Pypi GitHub Homepage
Other Docs
AttributesParametersBackRef

Attributes

axis : int, optional

The out of bounds axis or None if a custom exception message was provided. This should be the axis as passed by the user, before any normalization to resolve negative indices.

versionadded
ndim : int, optional

The number of array dimensions or None if a custom exception message was provided.

versionadded

This is raised whenever an axis parameter is specified that is larger than the number of array dimensions. For compatibility with code written against older numpy versions, which raised a mixture of :None:None:`ValueError` and :None:None:`IndexError` for this situation, this exception subclasses both to ensure that except ValueError and except IndexError statements continue to catch AxisError .

versionadded

Parameters

axis : int or str

The out of bounds axis or a custom exception message. If an axis is provided, then ndim should be specified as well.

ndim : int, optional

The number of array dimensions.

msg_prefix : str, optional

A prefix for the exception message.

Axis supplied was invalid.

Examples

This example is valid syntax, but raise an exception at execution
>>> array_1d = np.arange(10)
... np.cumsum(array_1d, axis=1) Traceback (most recent call last): ... numpy.AxisError: axis 1 is out of bounds for array of dimension 1

Negative axes are preserved:

This example is valid syntax, but raise an exception at execution
>>> np.cumsum(array_1d, axis=-2)
Traceback (most recent call last):
  ...
numpy.AxisError: axis -2 is out of bounds for array of dimension 1

The class constructor generally takes the axis and arrays' dimensionality as arguments:

>>> print(np.AxisError(2, 1, msg_prefix='error'))
error: axis 2 is out of bounds for array of dimension 1

Alternatively, a custom exception message can be passed:

>>> print(np.AxisError('Custom error message'))
Custom error message
See :

Back References

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

numpy.AxisError

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 : /numpy/__init__.py#None
type: <class 'type'>
Commit: