code: def test_clim_handling_cpu():
      ref_data = np.array([[10, 10, 5], [15, 25, 15]])
  
      # f32 - auto clim
      st = CPUScaledStub()
      st.set_clim("auto")
      st.scale_and_set_data(ref_data.astype(np.float32))
      assert st.clim == (5, 25)
      assert st.clim_normalized == (0, 1)
      assert np.all(st._data == (ref_data - 5) / 20)
  
      # Updating clim keeps data the same if not changing too much
      st.set_clim((0, 20))
      assert st.clim == (0, 20)
      assert st.clim_normalized == (-0.25, 0.75)
      assert np.all(st._data == (ref_data - 5) / 20)
  
      # f32 - custom clim
      st = CPUScaledStub()
      st.set_clim((0, 20))
      st.scale_and_set_data(ref_data.astype(np.float32))
      assert st.clim == (0, 20)
      assert st.clim_normalized == (0, 1)
      assert np.all(st._data == ref_data / 20)
  
      # f32 - flat clim
      st = CPUScaledStub()
      st.set_clim((10, 10))
      st.scale_and_set_data(ref_data.astype(np.float32))
      assert st.clim == (10, 10)
      assert st.clim_normalized == (0, np.inf)
      # assert np.min(st._data) == 0 - does not matter
  
      # f32 - auto clim
      st = CPUScaledStub()
      st.set_clim("auto")
      assert st.clim == "auto"
      pytest.raises(RuntimeError, getattr, st, "clim_normalized")
      st.scale_and_set_data(ref_data.astype(np.float32))
      assert st.clim == (5, 25)
      assert st.clim_normalized == (0, 1)
  
file_path: vispy/vispy/visuals/tests/test_scalable_textures.py
imports: import numpy
  import pytest
  from vispy.testing import run_tests_if_main
  from vispy.visuals._scalable_textures import get_default_clim_from_dtype, get_default_clim_from_data, CPUScaledTextureMixin, GPUScaledTextureMixin
label_desc: Use image node_id 3 for calling a global function with example usage: test_clim_handling_cpu() without return types