code: def test_normalize_segmentation_maps(self):
      # ----
      # None
      # ----
      segmaps_norm = normalization.normalize_segmentation_maps(None)
      assert segmaps_norm is None
  
      # ----
      # array
      # ----
      for dt in [np.dtype("int32"), np.dtype("uint16"), np.dtype(bool)]:
          # NOTE: use np.full(shape, 1, dtype=dt) here and below instead of
          # np.zeros(shape, dtype=dt) + 1, because the latter one converts
          # dtype bool_ to int64.
          segmaps_norm = normalization.normalize_segmentation_maps(
              np.full((1, 1, 1, 1), 1, dtype=dt),
              shapes=[np.zeros((1, 1, 3), dtype=np.uint8)],
          )
          assert isinstance(segmaps_norm, list)
          assert isinstance(segmaps_norm[0], ia.SegmentationMapsOnImage)
          assert np.allclose(segmaps_norm[0].arr[..., 0], 1)
  
          segmaps_norm = normalization.normalize_segmentation_maps(
              np.full((1, 1, 1, 1), 1, dtype=dt),
              shapes=np.zeros((1, 1, 1, 3), dtype=np.uint8),
          )
          assert isinstance(segmaps_norm, list)
          assert isinstance(segmaps_norm[0], ia.SegmentationMapsOnImage)
          assert np.allclose(segmaps_norm[0].arr[..., 0], 1)
  
          # --> segmaps for too many images
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  np.full((2, 1, 1), 1, dtype=dt),
                  shapes=[np.zeros((1, 1, 3), dtype=np.uint8)],
              )
  
          # --> too few segmaps
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  np.full((1, 1, 1), 1, dtype=dt),
                  shapes=np.zeros((2, 1, 1, 3), dtype=np.uint8),
              )
  
          # --> images None
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  np.full((1, 1, 1), 1, dtype=dt), shapes=None
              )
  
      # ----
      # single SegmentationMapsOnImage
      # ----
      segmaps_norm = normalization.normalize_segmentation_maps(
          ia.SegmentationMapsOnImage(
              np.full((1, 1, 1), 1, dtype=np.int32), shape=(1, 1, 3)
          ),
          shapes=None,
      )
      assert isinstance(segmaps_norm, list)
      assert isinstance(segmaps_norm[0], ia.SegmentationMapsOnImage)
      assert np.allclose(segmaps_norm[0].arr[..., 0], 0 + 1)
  
      # ----
      # empty iterable
      # ----
      segmaps_norm = normalization.normalize_segmentation_maps(
          [], shapes=None
      )
      assert segmaps_norm is None
  
      # ----
      # iterable of arrays
      # ----
      for dt in [np.dtype("int32"), np.dtype("uint16"), np.dtype(bool)]:
          segmaps_norm = normalization.normalize_segmentation_maps(
              [np.full((1, 1, 1), 1, dtype=dt)],
              shapes=[np.zeros((1, 1, 3), dtype=np.uint8)],
          )
          assert isinstance(segmaps_norm, list)
          assert isinstance(segmaps_norm[0], ia.SegmentationMapsOnImage)
          assert np.allclose(segmaps_norm[0].arr[..., 0], 1)
  
          segmaps_norm = normalization.normalize_segmentation_maps(
              [np.full((1, 1, 1), 1, dtype=dt)],
              shapes=np.zeros((1, 1, 1, 3), dtype=np.uint8),
          )
          assert isinstance(segmaps_norm, list)
          assert isinstance(segmaps_norm[0], ia.SegmentationMapsOnImage)
          assert np.allclose(segmaps_norm[0].arr[..., 0], 1)
  
          # --> segmaps for too many images
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  [
                      np.full((1, 1, 1), 1, dtype=np.int32),
                      np.full((1, 1, 1), 1, dtype=np.int32),
                  ],
                  shapes=[np.zeros((1, 1, 3), dtype=np.uint8)],
              )
  
          # --> too few segmaps
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  [np.full((1, 1, 1), 1, dtype=np.int32)],
                  shapes=np.zeros((2, 1, 1, 3), dtype=np.uint8),
              )
  
          # --> images None
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  [np.full((1, 1, 1), 1, dtype=np.int32)], shapes=None
              )
  
          # --> wrong number of dimensions
          with self.assertRaises(ValueError):
              _segmaps_norm = normalization.normalize_segmentation_maps(
                  [np.full((1, 1, 1, 1), 1, dtype=np.int32)],
                  shapes=np.zeros((1, 1, 1, 3), dtype=np.uint8),
              )
  
      # ----
      # iterable of SegmentationMapsOnImage
      # ----
      segmaps_norm = normalization.normalize_segmentation_maps(
          [
              ia.SegmentationMapsOnImage(
                  np.full((1, 1, 1), 1, dtype=np.int32), shape=(1, 1, 3)
              )
          ],
          shapes=None,
      )
      assert isinstance(segmaps_norm, list)
      assert isinstance(segmaps_norm[0], ia.SegmentationMapsOnImage)
      assert np.allclose(segmaps_norm[0].arr[..., 0], 1)
  
imports: from __future__ import print_function, division, absolute_import
  import sys
  import numpy
  import six.moves
  import imgaug
  import imgaug.augmentables.normalization
  from imgaug.testutils import reseed
label_desc: Use image node_id 11 for calling the TestNormalization obj's underlying member method code with example usage: obj.test_normalize_segmentation_maps() without return types