code: def test_dtype_preservation():
      reseed()
  
      size = (4, 16, 16, 3)
      images = [
          np.random.uniform(0, 255, size).astype(np.uint8),
          np.random.uniform(0, 65535, size).astype(np.uint16),
          np.random.uniform(0, 4294967295, size).astype(np.uint32),
          np.random.uniform(-128, 127, size).astype(np.int16),
          np.random.uniform(-32768, 32767, size).astype(np.int32),
          np.random.uniform(0.0, 1.0, size).astype(np.float32),
          np.random.uniform(-1000.0, 1000.0, size).astype(np.float16),
          np.random.uniform(-1000.0, 1000.0, size).astype(np.float32),
          np.random.uniform(-1000.0, 1000.0, size).astype(np.float64),
      ]
  
      default_dtypes = set([arr.dtype for arr in images])
      # Some dtypes are here removed per augmenter, because the respective
      # augmenter does not support them. This test currently only checks whether
      # dtypes are preserved from in- to output for all dtypes that are supported
      # per augmenter.
      # dtypes are here removed via list comprehension instead of
      # `default_dtypes - set([dtype])`, because the latter one simply never
      # removed the dtype(s) for some reason
  
      def _not_dts(dts):
          return [dt for dt in default_dtypes if dt not in dts]
  
      augs = [
          (
              iaa.Add((-5, 5), name="Add"),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.AddElementwise((-5, 5), name="AddElementwise"),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.AdditiveGaussianNoise(
                  0.01 * 255, name="AdditiveGaussianNoise"
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.Multiply((0.95, 1.05), name="Multiply"),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.Dropout(0.01, name="Dropout"),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.CoarseDropout(0.01, size_px=6, name="CoarseDropout"),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.Invert(0.01, per_channel=True, name="Invert"),
              default_dtypes,
          ),
          (
              iaa.GaussianBlur(sigma=(0.95, 1.05), name="GaussianBlur"),
              _not_dts([np.float16]),
          ),
          (
              iaa.AverageBlur((3, 5), name="AverageBlur"),
              _not_dts([np.uint32, np.int32, np.float16]),
          ),
          (
              iaa.MedianBlur((3, 5), name="MedianBlur"),
              _not_dts([np.uint32, np.int32, np.float16, np.float64]),
          ),
          (
              iaa.BilateralBlur((3, 5), name="BilateralBlur"),
              _not_dts(
                  [
                      np.uint16,
                      np.uint32,
                      np.int16,
                      np.int32,
                      np.float16,
                      np.float64,
                  ]
              ),
          ),
          (
              iaa.Sharpen(
                  (0.0, 0.1), lightness=(1.0, 1.2), name="Sharpen"
              ),
              _not_dts([np.uint32, np.int32, np.float16, np.uint32]),
          ),
          (
              iaa.Emboss(
                  alpha=(0.0, 0.1), strength=(0.5, 1.5), name="Emboss"
              ),
              _not_dts([np.uint32, np.int32, np.float16, np.uint32]),
          ),
          (
              iaa.EdgeDetect(alpha=(0.0, 0.1), name="EdgeDetect"),
              _not_dts([np.uint32, np.int32, np.float16, np.uint32]),
          ),
          (
              iaa.DirectedEdgeDetect(
                  alpha=(0.0, 0.1),
                  direction=0,
                  name="DirectedEdgeDetect",
              ),
              _not_dts([np.uint32, np.int32, np.float16, np.uint32]),
          ),
          (iaa.Fliplr(0.5, name="Fliplr"), default_dtypes),
          (iaa.Flipud(0.5, name="Flipud"), default_dtypes),
          (
              iaa.Affine(
                  translate_px=(-5, 5), name="Affine-translate-px"
              ),
              _not_dts([np.uint32, np.int32]),
          ),
          (
              iaa.Affine(
                  translate_percent=(-0.05, 0.05),
                  name="Affine-translate-percent",
              ),
              _not_dts([np.uint32, np.int32]),
          ),
          (
              iaa.Affine(rotate=(-20, 20), name="Affine-rotate"),
              _not_dts([np.uint32, np.int32]),
          ),
          (
              iaa.Affine(shear=(-20, 20), name="Affine-shear"),
              _not_dts([np.uint32, np.int32]),
          ),
          (
              iaa.Affine(scale=(0.9, 1.1), name="Affine-scale"),
              _not_dts([np.uint32, np.int32]),
          ),
          (
              iaa.PiecewiseAffine(
                  scale=(0.001, 0.005), name="PiecewiseAffine"
              ),
              default_dtypes,
          ),
          (
              iaa.ElasticTransformation(
                  alpha=(0.1, 0.2),
                  sigma=(0.1, 0.2),
                  name="ElasticTransformation",
              ),
              _not_dts([np.float16]),
          ),
          (
              iaa.Sequential(
                  [iaa.Identity(), iaa.Identity()],
                  name="SequentialNoop",
              ),
              default_dtypes,
          ),
          (
              iaa.SomeOf(
                  1, [iaa.Identity(), iaa.Identity()], name="SomeOfNoop"
              ),
              default_dtypes,
          ),
          (
              iaa.OneOf(
                  [iaa.Identity(), iaa.Identity()], name="OneOfNoop"
              ),
              default_dtypes,
          ),
          (
              iaa.Sometimes(0.5, iaa.Identity(), name="SometimesNoop"),
              default_dtypes,
          ),
          (
              iaa.Sequential(
                  [iaa.Add((-5, 5)), iaa.AddElementwise((-5, 5))],
                  name="Sequential",
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.SomeOf(
                  1,
                  [iaa.Add((-5, 5)), iaa.AddElementwise((-5, 5))],
                  name="SomeOf",
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.OneOf(
                  [iaa.Add((-5, 5)), iaa.AddElementwise((-5, 5))],
                  name="OneOf",
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.Sometimes(0.5, iaa.Add((-5, 5)), name="Sometimes"),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (iaa.Identity(name="Identity"), default_dtypes),
          (
              iaa.BlendAlpha(
                  (0.0, 0.1), iaa.Identity(), name="BlendAlphaIdentity"
              ),
              _not_dts([np.float64]),
          ),  # float64 requires float128 support
          (
              iaa.BlendAlphaElementwise(
                  (0.0, 0.1),
                  iaa.Identity(),
                  name="BlendAlphaElementwiseIdentity",
              ),
              _not_dts([np.float64]),
          ),  # float64 requires float128 support
          (
              iaa.BlendAlphaSimplexNoise(
                  iaa.Identity(), name="BlendAlphaSimplexNoiseIdentity"
              ),
              _not_dts([np.float64]),
          ),  # float64 requires float128 support
          (
              iaa.BlendAlphaFrequencyNoise(
                  exponent=(-2, 2),
                  foreground=iaa.Identity(),
                  name="BlendAlphaFrequencyNoiseIdentity",
              ),
              _not_dts([np.float64]),
          ),
          (
              iaa.BlendAlpha(
                  (0.0, 0.1), iaa.Add(10), name="BlendAlpha"
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.BlendAlphaElementwise(
                  (0.0, 0.1), iaa.Add(10), name="BlendAlphaElementwise"
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.BlendAlphaSimplexNoise(
                  iaa.Add(10), name="BlendAlphaSimplexNoise"
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.BlendAlphaFrequencyNoise(
                  exponent=(-2, 2),
                  foreground=iaa.Add(10),
                  name="BlendAlphaFrequencyNoise",
              ),
              _not_dts([np.uint32, np.int32, np.float64]),
          ),
          (
              iaa.Superpixels(p_replace=0.01, n_segments=64),
              _not_dts([np.float16, np.float32, np.float64]),
          ),
          (
              iaa.Resize({"height": 4, "width": 4}, name="Resize"),
              _not_dts(
                  [
                      np.uint16,
                      np.uint32,
                      np.int16,
                      np.int32,
                      np.float32,
                      np.float16,
                      np.float64,
                  ]
              ),
          ),
          (
              iaa.CropAndPad(px=(-10, 10), name="CropAndPad"),
              _not_dts(
                  [
                      np.uint16,
                      np.uint32,
                      np.int16,
                      np.int32,
                      np.float32,
                      np.float16,
                      np.float64,
                  ]
              ),
          ),
          (
              iaa.Pad(px=(0, 10), name="Pad"),
              _not_dts(
                  [
                      np.uint16,
                      np.uint32,
                      np.int16,
                      np.int32,
                      np.float32,
                      np.float16,
                      np.float64,
                  ]
              ),
          ),
          (
              iaa.Crop(px=(0, 10), name="Crop"),
              _not_dts(
                  [
                      np.uint16,
                      np.uint32,
                      np.int16,
                      np.int32,
                      np.float32,
                      np.float16,
                      np.float64,
                  ]
              ),
          ),
      ]
  
      for aug, allowed_dtypes in augs:
          for images_i in images:
              if images_i.dtype in allowed_dtypes:
                  images_aug = aug.augment_images(images_i)
                  assert images_aug.dtype == images_i.dtype
  
file_path: imgaug/test/augmenters/test_mixed_files.py
imports: from __future__ import print_function, division, absolute_import
  import sys
  import numpy
  import skimage
  import skimage.data
  import six.moves
  import imgaug
  from imgaug import augmenters
  from imgaug.testutils import create_random_images, array_equal_lists, keypoints_equal, reseed, assertWarns
label_desc: Use image node_id 3 for calling a global function with example usage: test_dtype_preservation() and returns: unknown