code: def test_volume_clims_and_gamma(
      texture_format, input_dtype, clim_on_init
  ):
      """Test volume visual with clims and gamma on shader.
  
      Test is parameterized based on ``texture_format`` and should produce
      relatively the same results for each format.
  
      Currently just using np.ones since the angle of view made more complicated samples
      challenging, but this confirms gamma and clims works in the shader.
      The VolumeVisual defaults to the "grays" colormap so although we compare
      data using RGBA arrays, each R/G/B channel should be the same.
  
      """
      size = (40, 40)
      if texture_format == "__dtype__":
          texture_format = input_dtype
      np.random.seed(0)  # make tests the same every time
      data = _make_test_data(size[:1] * 3, input_dtype)
      clim = (0, 1)
      new_clim = (0.3, 0.8)
      max = max_for_dtype(input_dtype)
      if max != 1:
          clim = (clim[0] * max, clim[1] * max)
          new_clim = (new_clim[0] * max, new_clim[1] * max)
  
      kwargs = {}
      if clim_on_init:
          kwargs["clim"] = clim
      with TestingCanvas(size=size, bgcolor="k") as c:
          v = c.central_widget.add_view(border_width=0)
          volume = scene.visuals.Volume(
              data,
              interpolation="nearest",
              parent=v.scene,
              method="mip",
              texture_format=texture_format,
              **kwargs,
          )
          v.camera = "arcball"
          v.camera.fov = 0
          v.camera.scale_factor = 40.0
          v.camera.center = (19.5, 19.5, 19.5)
  
          rendered = c.render()
          _dtype = rendered.dtype
          shape_ratio = rendered.shape[0] // data.shape[0]
          rendered1 = downsample(
              rendered, shape_ratio, axis=(0, 1)
          ).astype(_dtype)
          predicted = data.max(axis=1)
          compare_render(predicted, rendered1)
  
          # adjust contrast limits
          volume.clim = new_clim
          rendered2 = downsample(
              c.render(), shape_ratio, axis=(0, 1)
          ).astype(_dtype)
          scaled_data = (
              np.clip(data, new_clim[0], new_clim[1]) - new_clim[0]
          ) / (new_clim[1] - new_clim[0])
          predicted = scaled_data.max(axis=1)
          compare_render(predicted, rendered2, previous_render=rendered)
  
          # adjust gamma
          volume.gamma = 2
          rendered3 = downsample(
              c.render(), shape_ratio, axis=(0, 1)
          ).astype(_dtype)
          predicted = (scaled_data**2).max(axis=1)
          compare_render(
              predicted, rendered3, previous_render=rendered2
          )
  
imports: import pytest
  import numpy
  from vispy import scene
  from vispy.testing import TestingCanvas, requires_application, run_tests_if_main, requires_pyopengl, raises
  from vispy.testing.image_tester import assert_image_approved, downsample
  from vispy.testing.rendered_array_tester import compare_render, max_for_dtype
label_desc: Use image node_id 4 for calling a global function with example usage: test_volume_clims_and_gamma(texture_format, input_dtype, clim_on_init) without return types