code: def test_colormap_discrete():
      """Test discrete colormaps."""
      cm = Colormap(["r", "g"], interpolation="zero")
      assert_allclose(cm[-1].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.0].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.49].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.51].rgba, [[0, 1, 0, 1]])
      assert_allclose(cm[1.0].rgba, [[0, 1, 0, 1]])
  
      cm = Colormap(["r", "g", "b"], interpolation="zero")
      assert_allclose(cm[-1].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.0].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.32].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.34].rgba, [[0, 1, 0, 1]])
      assert_allclose(cm[0.66].rgba, [[0, 1, 0, 1]])
      assert_allclose(cm[0.67].rgba, [[0, 0, 1, 1]])
      assert_allclose(cm[0.99].rgba, [[0, 0, 1, 1]])
      assert_allclose(cm[1].rgba, [[0, 0, 1, 1]])
      assert_allclose(cm[1.1].rgba, [[0, 0, 1, 1]])
  
      cm = Colormap(
          ["r", "g", "b"], [0.0, 0.1, 0.8, 1.0], interpolation="zero"
      )
      assert_allclose(cm[-1].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.0].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.099].rgba, [[1, 0, 0, 1]])
      assert_allclose(cm[0.101].rgba, [[0, 1, 0, 1]])
      assert_allclose(cm[0.799].rgba, [[0, 1, 0, 1]])
      assert_allclose(cm[0.801].rgba, [[0, 0, 1, 1]])
      assert_allclose(cm[1].rgba, [[0, 0, 1, 1]], 1e-6, 1e-6)
      assert_allclose(cm[2].rgba, [[0, 0, 1, 1]], 1e-6, 1e-6)
  
file_path: vispy/vispy/color/tests/test_color.py
imports: import numpy
  from numpy.testing import assert_array_equal, assert_allclose
  from vispy.color import Color, ColorArray, get_color_names, Colormap, get_color_dict, get_colormap, get_colormaps
  from vispy.visuals.shaders import Function
  from vispy.util import use_log_level
  from vispy.testing import run_tests_if_main, assert_equal, assert_raises, assert_true
label_desc: Use image node_id 7 for calling a global function with example usage: test_colormap_discrete() without return types