code: def test_image_interpolation():
      """Test different interpolations"""
      size = (81, 81)
      data = np.array([[0, 1]], dtype=int)
      left = (40, 0)
      right = (40, 80)
      center_left = (40, 39)
      center = (40, 40)
      center_right = (40, 41)
      white = (255, 255, 255, 255)
      black = (0, 0, 0, 255)
      gray = (128, 128, 128, 255)
  
      with TestingCanvas(size=size[::-1], bgcolor="w") as c:
          view = c.central_widget.add_view(border_width=0)
          view.camera = PanZoomCamera((0, 0, 2, 1))
          image = Image(data=data, cmap="grays", parent=view.scene)
  
          # needed to properly initialize the canvas
          render = c.render()
  
          image.interpolation = "nearest"
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], white)
          assert np.allclose(render[center_left], black)
          assert np.allclose(render[center_right], white)
  
          image.interpolation = "bilinear"
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], white)
          assert np.allclose(
              render[center], gray, atol=5
          )  # we just want gray, this is not quantitative
  
          image.interpolation = "custom"
          image.custom_kernel = np.array([[0]])  # no sampling
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], black)
          assert np.allclose(render[center], black)
  
          image.custom_kernel = np.array([[1]])  # same as linear
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], white)
          assert np.allclose(render[center], gray, atol=5)
  
file_path: vispy/vispy/visuals/tests/test_image.py
imports: from unittest import mock
  from vispy.scene import Image, PanZoomCamera
  from vispy.testing import requires_application, TestingCanvas, run_tests_if_main, IS_CI
  from vispy.testing.image_tester import assert_image_approved, downsample
  import numpy
  import pytest
  from vispy.testing.rendered_array_tester import compare_render, max_for_dtype
label_desc: Use image node_id 12 for calling a global function with example usage: test_image_interpolation() without return types