docs: def _pad(self, a, axis, extrap, out):
          """Add padding to an array.
  
          Parameters
          ----------
          a : (..., Nin, ...) ndarray
              array to be padded to size `N`
          axis : int
              axis along which to pad
          extrap : {bool, 'const'} or 2-tuple
              Method to extrapolate `a`.
              For a 2-tuple, the two elements are for the left and right pads,
              whereas a single value applies to both ends.
              Options are:
              * True: power-law extrapolation using the end segment
              * False: zero padding
              * 'const': constant padding with the end point value
          out : bool
              pad the output if True, otherwise the input; the two cases have
              their left and right pad sizes reversed
          """
  
          assert a.shape[axis] == self.Nin
  
          axis %= a.ndim  # to fix the indexing below with axis+1
  
          to_axis = [1] * a.ndim
          to_axis[axis] = -1
  
          Npad = self.N - self.Nin
          if out:
              _Npad, Npad_ = Npad - Npad//2, Npad//2
          else:
              _Npad, Npad_ = Npad//2, Npad - Npad//2
  
          try:
              _extrap, extrap_ = extrap
          except (TypeError, ValueError):
              _extrap = extrap_ = extrap
  
          if isinstance(_extrap, bool):
              if _extrap:
                  end = np.take(a, [0], axis=axis)
                  ratio = np.take(a, [1], axis=axis) / end
                  exp = np.arange(-_Npad, 0).reshape(to_axis)
                  _a = end * ratio ** exp
              else:
                  _a = np.zeros(a.shape[:axis] + (_Npad,) + a.shape[axis+1:])
          elif _extrap == 'const':
              end = np.take(a, [0], axis=axis)
              _a = np.repeat(end, _Npad, axis=axis)
          else:
              raise ValueError("left extrap not supported")
          if isinstance(extrap_, bool):
              if extrap_:
                  end = np.take(a, [-1], axis=axis)
                  ratio = end / np.take(a, [-2], axis=axis)
                  exp = np.arange(1, Npad_ + 1).reshape(to_axis)
                  a_ = end * ratio ** exp
              else:
                  a_ = np.zeros(a.shape[:axis] + (Npad_,) + a.shape[axis+1:])
          elif extrap_ == 'const':
              end = np.take(a, [-1], axis=axis)
              a_ = np.repeat(end, Npad_, axis=axis)
          else:
              raise ValueError("right extrap not supported")
  
          return np.concatenate((_a, a, a_), axis=axis)