code: def test_image_set_data_different_dtype():
      size = (80, 80)
      data = np.array([[0, 127]], dtype=np.int8)
      left = (40, 10)
      right = (40, 70)
      white = (255, 255, 255, 255)
      black = (0, 0, 0, 255)
  
      with TestingCanvas(size=size[::-1], bgcolor="w") as c:
          view = c.central_widget.add_view()
          view.camera = PanZoomCamera((0, 0, 2, 1))
          image = Image(
              data=data, cmap="grays", clim=[0, 127], parent=view.scene
          )
  
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], white)
  
          # same data as float should change nothing
          image.set_data(data.astype(np.float32))
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], white)
  
          # something inverted, different dtype
          new_data = np.array([[127, 0]], dtype=np.float16)
          image.set_data(new_data)
          render = c.render()
          assert np.allclose(render[left], white)
          assert np.allclose(render[right], black)
  
          # out of bounds should clip (2000 > 127)
          new_data = np.array([[0, 2000]], dtype=np.float64)
          image.set_data(new_data)
          render = c.render()
          assert np.allclose(render[left], black)
          assert np.allclose(render[right], white)
  
file_path: vispy/vispy/visuals/tests/test_image.py
imports: from unittest import mock
  from vispy.scene import Image, PanZoomCamera
  from vispy.testing import requires_application, TestingCanvas, run_tests_if_main, IS_CI
  from vispy.testing.image_tester import assert_image_approved, downsample
  import numpy
  import pytest
  from vispy.testing.rendered_array_tester import compare_render, max_for_dtype
label_desc: Use image node_id 13 for calling a global function with example usage: test_image_set_data_different_dtype() without return types