code: def test_use_uniforms():
      """Test using uniform arrays"""
      VERT_SHADER = """
      attribute vec2 a_pos;
      varying vec2 v_pos;
  
      void main (void)
      {
          v_pos = a_pos;
          gl_Position = vec4(a_pos, 0., 1.);
      }
      """
  
      FRAG_SHADER = """
      varying vec2 v_pos;
      uniform vec3 u_color[2];
  
      void main()
      {
          gl_FragColor = vec4((u_color[0] + u_color[1]) / 2., 1.);
      }
      """
      shape = (500, 500)
      with Canvas(size=shape) as c:
          c.set_current()
          c.context.glir.set_verbose(True)
          assert_equal(c.size, shape[::-1])
          shape = (3, 3)
          set_viewport((0, 0) + shape)
          program = Program(VERT_SHADER, FRAG_SHADER)
          program["a_pos"] = [
              [-1.0, -1.0],
              [1.0, -1.0],
              [-1.0, 1.0],
              [1.0, 1.0],
          ]
          program["u_color"] = np.ones((2, 3))
          c.context.clear("k")
          c.set_current()
          program.draw("triangle_strip")
          out = _screenshot()
          assert_allclose(
              out[:, :, 0] / 255.0, np.ones(shape), atol=1.0 / 255.0
          )
  
          # now set one element
          program["u_color[1]"] = np.zeros(3, np.float32)
          c.context.clear("k")
          program.draw("triangle_strip")
          out = _screenshot()
          assert_allclose(
              out[:, :, 0] / 255.0,
              127.5 / 255.0 * np.ones(shape),
              atol=1.0 / 255.0,
          )
  
          # and the other
          assert_raises(
              ValueError,
              program.__setitem__,
              "u_color",
              np.zeros(3, np.float32),
          )
          program["u_color"] = np.zeros((2, 3), np.float32)
          program["u_color[0]"] = np.ones(3, np.float32)
          c.context.clear((0.33,) * 3)
          program.draw("triangle_strip")
          out = _screenshot()
          assert_allclose(
              out[:, :, 0] / 255.0,
              127.5 / 255.0 * np.ones(shape),
              atol=1.0 / 255.0,
          )
  
file_path: vispy/vispy/gloo/tests/test_use_gloo.py
imports: import sys
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from vispy.app import Canvas
  from vispy.gloo import Texture2D, Texture3D, Program, FrameBuffer, RenderBuffer, set_viewport, clear
  from vispy.gloo.util import draw_texture, _screenshot
  from vispy.testing import requires_application, has_pyopengl, run_tests_if_main, assert_raises, assert_equal, IS_TRAVIS_CI
label_desc: Use image node_id 4 for calling a global function with example usage: test_use_uniforms() without return types