code: def shift(
      input,
      shift,
      output=None,
      order=3,
      mode="constant",
      cval=0.0,
      prefilter=True,
  ):
      """
      Shift an array.
  
      The array is shifted using spline interpolation of the requested order.
      Points outside the boundaries of the input are filled according to the
      given mode.
  
      Parameters
      ----------
      %(input)s
      shift : float or sequence
          The shift along the axes. If a float, `shift` is the same for each
          axis. If a sequence, `shift` should contain one value for each axis.
      %(output)s
      order : int, optional
          The order of the spline interpolation, default is 3.
          The order has to be in the range 0-5.
      %(mode_interp_constant)s
      %(cval)s
      %(prefilter)s
  
      Returns
      -------
      shift : ndarray
          The shifted input.
  
      See Also
      --------
      affine_transform : Affine transformations
  
      Notes
      -----
      For complex-valued `input`, this function shifts the real and imaginary
      components independently.
  
      .. versionadded:: 1.6.0
          Complex-valued support added.
  
      Examples
      --------
      Import the necessary modules and an exemplary image.
  
      >>> from scipy.ndimage import shift
      >>> import matplotlib.pyplot as plt
      >>> from scipy import datasets
      >>> image = datasets.ascent()
  
      Shift the image vertically by 20 pixels.
  
      >>> image_shifted_vertically = shift(image, (20, 0))
  
      Shift the image vertically by -200 pixels and horizontally by 100 pixels.
  
      >>> image_shifted_both_directions = shift(image, (-200, 100))
  
      Plot the original and the shifted images.
  
      >>> fig, axes = plt.subplots(3, 1, figsize=(4, 12))
      >>> plt.gray()  # show the filtered result in grayscale
      >>> top, middle, bottom = axes
      >>> for ax in axes:
      ...     ax.set_axis_off()  # remove coordinate system
      >>> top.imshow(image)
      >>> top.set_title("Original image")
      >>> middle.imshow(image_shifted_vertically)
      >>> middle.set_title("Vertically shifted image")
      >>> bottom.imshow(image_shifted_both_directions)
      >>> bottom.set_title("Image shifted in both directions")
      >>> fig.tight_layout()
      """
      if order < 0 or order > 5:
          raise RuntimeError("spline order not supported")
      input = numpy.asarray(input)
      if input.ndim < 1:
          raise RuntimeError("input and output rank must be > 0")
      complex_output = numpy.iscomplexobj(input)
      output = _ni_support._get_output(
          output, input, complex_output=complex_output
      )
      if complex_output:
          # import under different name to avoid confusion with shift parameter
          from scipy.ndimage._interpolation import shift as _shift
  
          kwargs = dict(order=order, mode=mode, prefilter=prefilter)
          _shift(
              input.real,
              shift,
              output=output.real,
              cval=numpy.real(cval),
              **kwargs,
          )
          _shift(
              input.imag,
              shift,
              output=output.imag,
              cval=numpy.imag(cval),
              **kwargs,
          )
          return output
      if prefilter and order > 1:
          padded, npad = _prepad_for_spline_filter(input, mode, cval)
          filtered = spline_filter(
              padded, order, output=numpy.float64, mode=mode
          )
      else:
          npad = 0
          filtered = input
      mode = _ni_support._extend_mode_to_code(mode)
      shift = _ni_support._normalize_sequence(shift, input.ndim)
      shift = [-ii for ii in shift]
      shift = numpy.asarray(shift, dtype=numpy.float64)
      if not shift.flags.contiguous:
          shift = shift.copy()
      _nd_image.zoom_shift(
          filtered, None, shift, output, order, mode, cval, npad, False
      )
      return output
  
file_path: scipy/scipy/ndimage/_interpolation.py
imports: import itertools
  import warnings
  import numpy
  from scipy._lib._util import normalize_axis_index
  from scipy import special
  from .None import _ni_support
  from .None import _nd_image
  from ._ni_docstrings import docfiller
label_desc: Use image node_id 7 for calling a global function with example usage: shift(input, shift, output, order, mode, cval, prefilter) and returns: output, output