>> import numpy as np >>> array_1d = np.arange(10) >>> np.cumsum(array_1d, axis=1) Traceback (most recent call last): ... numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1 Negative axes are preserved: >>> np.cumsum(array_1d, axis=-2) Traceback (most recent call last): ... numpy.exceptions.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.exceptions.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.exceptions.AxisError('Custom error message')) Custom error message _msgaxisndimNchX#s=LacO OXlSUlSUlgX0lXlX lg)Nr!)selfr#r$ msg_prefixs r__init__AxisError.__init__s-  % %IDIDI"IIIrcURnURnXs=LacUR$ SUSU3nURbURSU3nU$)Nzaxis z) is out of bounds for array of dimension z: )r#r$r")r&r#r$msgs r__str__AxisError.__str__sayyyy  99  $HOCyy$ 2cU+Jr)NN) r rrrr __slots__r(r,rr rrrrls>@)I  rrc\rSrSrSrSrg)ra5Multiple DTypes could not be converted to a common one. This exception derives from ``TypeError`` and is raised whenever dtypes cannot be converted to a single common one. This can be because they are of a different category/class or incompatible instances of the same one (see Examples). Notes ----- Many functions will use promotion to find the correct result and implementation. For these functions the error will typically be chained with a more specific error indicating that no implementation was found for the input dtypes. Typically promotion should be considered "invalid" between the dtypes of two arrays when `arr1 == arr2` can safely return all ``False`` because the dtypes are fundamentally different. Examples -------- Datetimes and complex numbers are incompatible classes and cannot be promoted: >>> import numpy as np >>> np.result_type(np.dtype("M8[s]"), np.complex128) # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... DTypePromotionError: The DType could not be promoted by . This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is `object`. The full list of DTypes is: (, ) For example for structured dtypes, the structure can mismatch and the same ``DTypePromotionError`` is given when two structured dtypes with a mismatch in their number of fields is given: >>> dtype1 = np.dtype([("field1", np.float64), ("field2", np.int64)]) >>> dtype2 = np.dtype([("field1", np.float64)]) >>> np.promote_types(dtype1, dtype2) # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... DTypePromotionError: field names `('field1', 'field2')` and `('field1',)` mismatch. r Nr r rrrrs -\ rrN)r__all__globals RuntimeErrorrRuntimeWarningrDeprecationWarningr UserWarningrrr ValueError IndexErrorr TypeErrorrr rrr:sD 879 @ AA   ^  1 "   .   <  X JXv/ )/ r