code: def test_linear_region_vertical_horizontal():
      """Test vertical and horizontal LinearRegionVisual with a single color"""
      # Definition of the region
      pos = np.array([5, 15, 24, 36, 40, 42], dtype=np.float32)
      # Expected internal pos buffer for vertical region
      expected_pos_v = np.array(
          [
              [5.0, -1.0],
              [5.0, 1.0],
              [15.0, -1.0],
              [15.0, 1.0],
              [24.0, -1.0],
              [24.0, 1.0],
              [36.0, -1.0],
              [36.0, 1.0],
              [40.0, -1.0],
              [40.0, 1.0],
              [42.0, -1.0],
              [42.0, 1.0],
          ],
          dtype=np.float32,
      )
      # Expected internal pos buffer for horizontal region
      expected_pos_h = np.array(
          [expected_pos_v[:, 1] * -1, expected_pos_v[:, 0]],
          dtype=np.float32,
      ).T
  
      # Test both horizontal and vertical region
      for is_vertical, reference_image in [
          (True, "linear_region1.png"),
          (False, "linear_region1_h.png"),
      ]:
          expected_pos = (
              expected_pos_v if is_vertical else expected_pos_h
          )
  
          with TestingCanvas() as c:
              # Check set_data is working correctly within visual constructor
              region = visuals.LinearRegion(
                  pos=pos,
                  color=[0.0, 1.0, 0.0, 0.5],
                  vertical=is_vertical,
                  parent=c.scene,
              )
              assert np.all(region._pos == expected_pos)
              assert np.all(region.pos == pos)
              assert region.is_vertical == is_vertical
  
              # Check set_data is working as expected when passing a list as
              # pos argument
              region.set_data(pos=list(pos))
              assert np.all(region._pos == expected_pos)
              assert np.all(region.pos == pos)
  
              # Check set_data is working as expected when passing a tuple as
              # pos argument
              region.set_data(pos=tuple(pos))
              assert np.all(region._pos == expected_pos)
              assert np.all(region.pos == pos)
  
              # Test with different dtypes that must be converted to float32
              for t in [np.int64, np.float64, np.int32]:
                  region.set_data(pos=pos.astype(t))
                  assert np.all(region._pos == expected_pos)
                  assert np.all(region.pos == pos)
  
              assert_image_approved(
                  c.render(), "visuals/%s" % reference_image
              )
  
              # Check ValueError is raised when pos is not 1D
              assert_raises(
                  ValueError, region.set_data, pos=[[1, 2], [3, 4]]
              )
  
file_path: vispy/vispy/visuals/tests/test_linear_region.py
imports: import numpy
  from vispy.scene import visuals
  from vispy.testing import requires_application, TestingCanvas, run_tests_if_main
  from vispy.testing.image_tester import assert_image_approved
  from vispy.testing import assert_raises
label_desc: Use image node_id 1 for calling a global function with example usage: test_linear_region_vertical_horizontal() without return types