bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / exceptions / AxisError
class
numpy.exceptions:AxisError
source: build-install/usr/lib/python3.14/site-packages/numpy/exceptions.py :108
Signature
class AxisError ( axis , ndim = None , msg_prefix = None ) Members
Summary
Axis supplied was invalid.
Extended Summary
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 ValueError and IndexError for this situation, this exception subclasses both to ensure that except ValueError and except IndexError statements continue to catch AxisError.
Parameters
axis: int or strThe out of bounds axis or a custom exception message. If an axis is provided, then
ndimshould be specified as well.ndim: int, optionalThe number of array dimensions.
msg_prefix: str, optionalA prefix for the exception message.
Attributes
axis: int, optionalThe out of bounds axis or
Noneif a custom exception message was provided. This should be the axis as passed by the user, before any normalization to resolve negative indices.ndim: int, optionalThe number of array dimensions or
Noneif a custom exception message was provided.
Examples
import numpy as np array_1d = np.arange(10) np.cumsum(array_1d, axis=1)✓
np.cumsum(array_1d, axis=-2)
✓print(np.exceptions.AxisError(2, 1, msg_prefix='error'))
✓print(np.exceptions.AxisError('Custom error message'))
✓Aliases
-
numpy.exceptions.AxisError