code: def _get_axis(array, axis, fname):
      """
      axis = _get_axis(array, axis, fname)
  
      Checks that ``axis`` is a valid axis of ``array`` and normalises it.
  
      Parameters
      ----------
      array : ndarray
      axis : int
      fname : str
          Function name. Used in error messages
  
      Returns
      -------
      axis : int
          The positive index of the axis to use
      """
      if axis < 0:
          axis += len(array.shape)
      if not (0 <= axis < len(array.shape)):
          raise ValueError(
              "mahotas.%s: `axis` is out of bounds (maximum was %s, got %s)"
              % (fname, array.ndim, axis)
          )
      return axis
  
file_path: mahotas/mahotas/internal.py
imports: import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: _get_axis(array, axis, fname) and returns: axis