code: def test_color_interpretation():
      """Test basic color interpretation API"""
      # test useful ways of single color init
      r = ColorArray("r")
      print(r)  # test repr
      r2 = ColorArray(r)
      assert_equal(r, r2)
      r2.rgb = 0, 0, 0
      assert_equal(r2, ColorArray("black"))
      assert_equal(
          r, ColorArray("r")
      )  # modifying new one preserves old
      assert_equal(r, r.copy())
      assert_equal(r, ColorArray("#ff0000"))
      assert_equal(r, ColorArray("#FF0000FF"))
      assert_equal(r, ColorArray("red"))
      assert_equal(r, ColorArray("red", alpha=1.0))
      assert_equal(
          ColorArray((1, 0, 0, 0.1)), ColorArray("red", alpha=0.1)
      )
      assert_array_equal(r.rgb.ravel(), (1.0, 0.0, 0.0))
      assert_array_equal(r.rgba.ravel(), (1.0, 0.0, 0.0, 1.0))
      assert_array_equal(r.RGBA.ravel(), (255, 0, 0, 255))
  
      # handling multiple colors
      rgb = ColorArray(list("rgb"))
      print(rgb)  # multi repr
      assert_array_equal(rgb, ColorArray(np.eye(3)))
      # complex/annoying case
      rgb = ColorArray(["r", (0, 1, 0), "#0000ffff"])
      assert_array_equal(rgb, ColorArray(np.eye(3)))
      assert_raises(
          RuntimeError, ColorArray, ["r", np.eye(3)]
      )  # can't nest
  
      # getting/setting properties
      r = ColorArray("#ffff")
      assert_equal(r, ColorArray("white"))
      r = ColorArray("#ff000000")
      assert_true(
          "turquoise" in get_color_names()
      )  # make sure our JSON loaded
      assert_equal(r.alpha, 0)
      r.alpha = 1.0
      assert_equal(r, ColorArray("r"))
      r.alpha = 0
      r.rgb = (1, 0, 0)
      assert_equal(r.alpha, 0)
      assert_equal(r.hex, ["#ff0000"])
      r.alpha = 1
      r.hex = "00ff00"
      assert_equal(r, ColorArray("g"))
      assert_array_equal(r.rgb.ravel(), (0.0, 1.0, 0.0))
      r.RGB = 255, 0, 0
      assert_equal(r, ColorArray("r"))
      assert_array_equal(r.RGB.ravel(), (255, 0, 0))
      r.RGBA = 255, 0, 0, 0
      assert_equal(r, ColorArray("r", alpha=0))
      w = ColorArray()
      w.rgb = (
          ColorArray("r").rgb
          + ColorArray("g").rgb
          + ColorArray("b").rgb
      )
      assert_equal(w, ColorArray("white"))
      w = ColorArray("white")
      assert_equal(w, w.darker().lighter())
      assert_equal(w, w.darker(0.1).darker(-0.1))
      w2 = w.darker()
      assert_true(w != w2)
      w.darker(copy=False)
      assert_equal(w, w2)
      with use_log_level("warning", record=True, print_msg=False) as w:
          w = ColorArray("white")
          w.value = 2
          assert_equal(len(w), 1)
      assert_equal(w, ColorArray("white"))
  
      # warnings and errors
      assert_raises(ValueError, ColorArray, "#ffii00")  # non-hex
      assert_raises(ValueError, ColorArray, "#ff000")  # too short
      assert_raises(ValueError, ColorArray, [0, 0])  # not enough vals
      assert_raises(ValueError, ColorArray, [2, 0, 0])  # val > 1
      assert_raises(ValueError, ColorArray, [-1, 0, 0])  # val < 0
      c = ColorArray([2.0, 0.0, 0.0], clip=True)  # val > 1
      assert_true(np.all(c.rgb <= 1))
      c = ColorArray([-1.0, 0.0, 0.0], clip=True)  # val < 0
      assert_true(np.all(c.rgb >= 0))
  
      # make sure our color dict works
      for key in get_color_names():
          assert_true(ColorArray(key))
      assert_raises(
          ValueError, ColorArray, "foo"
      )  # unknown color error
  
      _color_dict = get_color_dict()
      assert isinstance(_color_dict, dict)
      assert set(_color_dict.keys()) == set(get_color_names())
  
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 3 for calling a global function with example usage: test_color_interpretation() without return types