class_docstr: Axis supplied was invalid.
  
  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 :exc:`ValueError` and :exc:`IndexError` for this
  situation, this exception subclasses both to ensure that
  ``except ValueError`` and ``except IndexError`` statements continue
  to catch ``AxisError``.
  
  .. versionadded:: 1.13
  
  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.
  
  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:: 1.22
  ndim : int, optional
      The number of array dimensions or ``None`` if a custom exception
      message was provided.
  
      .. versionadded:: 1.22
  
  
  Examples
  --------
  >>> 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
class_docstr_tok: ["Axis","supplied","was","invalid",".","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",":","exc",":","`","ValueError","`","and",":","exc",":","`","IndexError","`","for","this","situation",",","this","exception","subclasses","both","to","ensure","that","``","except","ValueError","``","and","``","except","IndexError","``","statements","continue","to","catch","``","AxisError","``",".","..","versionadded",":",":","1.13","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",".","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",":",":","1.22","ndim",":","int",",","optional","The","number","of","array","dimensions","or","``","None","``","if","a","custom","exception","message","was","provided",".","..","versionadded",":",":","1.22","Examples","--","--","--","--",">",">",">","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"]
code: def __str__(self):
      axis = self.axis
      ndim = self.ndim
  
      if axis is ndim is None:
          return self._msg
      else:
          msg = f"axis {axis} is out of bounds for array of dimension {ndim}"
          if self._msg is not None:
              msg = f"{self._msg}: {msg}"
          return msg
  
file_path: numpy/numpy/exceptions.py
label_desc: Use image node_id 2 for calling the AxisError obj's underlying member method code with example usage: obj.__str__() and returns: self, msg