code: def test_numpy_to_image():
      def to_image(dtype, bands=1, boolean=0):
          if bands == 1:
              if boolean:
                  data = [0, 255] * 50
              else:
                  data = list(range(100))
              a = numpy.array(data, dtype=dtype)
              a.shape = TEST_IMAGE_SIZE
              i = Image.fromarray(a)
              if list(i.getdata()) != data:
                  print("data mismatch for", dtype)
          else:
              data = list(range(100))
              a = numpy.array([[x] * bands for x in data], dtype=dtype)
              a.shape = TEST_IMAGE_SIZE[0], TEST_IMAGE_SIZE[1], bands
              i = Image.fromarray(a)
              if list(i.getchannel(0).getdata()) != list(range(100)):
                  print("data mismatch for", dtype)
          return i
  
      # Check supported 1-bit integer formats
      assert_image(to_image(bool, 1, 1), "1", TEST_IMAGE_SIZE)
      assert_image(to_image(numpy.bool8, 1, 1), "1", TEST_IMAGE_SIZE)
  
      # Check supported 8-bit integer formats
      assert_image(to_image(numpy.uint8), "L", TEST_IMAGE_SIZE)
      assert_image(to_image(numpy.uint8, 3), "RGB", TEST_IMAGE_SIZE)
      assert_image(to_image(numpy.uint8, 4), "RGBA", TEST_IMAGE_SIZE)
      assert_image(to_image(numpy.int8), "I", TEST_IMAGE_SIZE)
  
      # Check non-fixed-size integer types
      # These may fail, depending on the platform, since we have no native
      # 64-bit int image types.
      # assert_image(to_image(numpy.uint), "I", TEST_IMAGE_SIZE)
      # assert_image(to_image(numpy.int), "I", TEST_IMAGE_SIZE)
  
      # Check 16-bit integer formats
      if Image._ENDIAN == "<":
          assert_image(to_image(numpy.uint16), "I;16", TEST_IMAGE_SIZE)
      else:
          assert_image(to_image(numpy.uint16), "I;16B", TEST_IMAGE_SIZE)
  
      assert_image(to_image(numpy.int16), "I", TEST_IMAGE_SIZE)
  
      # Check 32-bit integer formats
      assert_image(to_image(numpy.uint32), "I", TEST_IMAGE_SIZE)
      assert_image(to_image(numpy.int32), "I", TEST_IMAGE_SIZE)
  
      # Check 64-bit integer formats
      with pytest.raises(TypeError):
          to_image(numpy.uint64)
      with pytest.raises(TypeError):
          to_image(numpy.int64)
  
      # Check floating-point formats
      assert_image(to_image(float), "F", TEST_IMAGE_SIZE)
      with pytest.raises(TypeError):
          to_image(numpy.float16)
      assert_image(to_image(numpy.float32), "F", TEST_IMAGE_SIZE)
      assert_image(to_image(numpy.float64), "F", TEST_IMAGE_SIZE)
  
      assert_image(to_image(numpy.uint8, 2), "LA", (10, 10))
      assert_image(to_image(numpy.uint8, 3), "RGB", (10, 10))
      assert_image(to_image(numpy.uint8, 4), "RGBA", (10, 10))
  
file_path: pillow-simd/Tests/test_numpy.py
imports: import pytest
  from PIL import Image
  from .helper import assert_deep_equal, assert_image, hopper
label_desc: Use image node_id 1 for calling a global function with example usage: test_numpy_to_image() and returns: i