8c21a9ff3a02bd5078dc6c4e3eabbc09d89d6bfd,test/augmentables/test_normalization.py,TestNormalization,test_normalize_segmentation_maps,#TestNormalization#,1192
Before Change
// ----
// array
// ----
for dt in [np.dtype("int32"), np.dtype("uint32"), np.dtype(bool)]:
segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((1, 1, 1), dtype=dt) + 1,
shapes=[np.zeros((1, 1, 3), dtype=np.uint8)]
)
assert isinstance(segmaps_norm, list)
assert isinstance(segmaps_norm[0], ia.SegmentationMapOnImage)
assert np.allclose(segmaps_norm[0].arr[..., 1], 1)
segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((1, 1, 1), dtype=dt) + 1,
shapes=np.zeros((1, 1, 1, 3), dtype=np.uint8)
)
assert isinstance(segmaps_norm, list)
assert isinstance(segmaps_norm[0], ia.SegmentationMapOnImage)
assert np.allclose(segmaps_norm[0].arr[..., 1], 1)
// --> segmaps for too many images
with self.assertRaises(ValueError):
_segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((2, 1, 1), dtype=dt) + 1,
shapes=[np.zeros((1, 1, 3), dtype=np.uint8)]
)
// --> too few segmaps
with self.assertRaises(ValueError):
_segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((1, 1, 1), dtype=dt) + 1,
shapes=np.zeros((2, 1, 1, 3), dtype=np.uint8)
)
// --> images None
with self.assertRaises(ValueError):
_segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((1, 1, 1), dtype=dt) + 1,
shapes=None
)
After Change
// --> segmaps for too many images
with self.assertRaises(ValueError):
_segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((2, 1, 1), dtype=dt) + 1,
shapes=[np.zeros((1, 1, 3), dtype=np.uint8)]
)
// --> too few segmaps
with self.assertRaises(ValueError):
_segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((1, 1, 1), dtype=dt) + 1,
shapes=np.zeros((2, 1, 1, 3), dtype=np.uint8)
)
// --> images None
with self.assertRaises(ValueError):
_segmaps_norm = normalization.normalize_segmentation_maps(
np.zeros((1, 1, 1), dtype=dt) + 1,
shapes=None
)
// ----
// single SegmentationMapsOnImage
// ----
segmaps_norm = normalization.normalize_segmentation_maps(
ia.SegmentationMapsOnImage(
np.zeros((1, 1, 1), dtype=np.int32) + 1,
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.zeros((1, 1, 1), dtype=dt) + 1],
shapes=[np.zeros((1, 1, 3), dtype=np.uint8)]
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 2
Instances
Project Name: aleju/imgaug
Commit Name: 8c21a9ff3a02bd5078dc6c4e3eabbc09d89d6bfd
Time: 2019-07-23
Author: kontakt@ajung.name
File Name: test/augmentables/test_normalization.py
Class Name: TestNormalization
Method Name: test_normalize_segmentation_maps
Project Name: aleju/imgaug
Commit Name: 8c21a9ff3a02bd5078dc6c4e3eabbc09d89d6bfd
Time: 2019-07-23
Author: kontakt@ajung.name
File Name: test/augmentables/test_normalization.py
Class Name: TestNormalization
Method Name: test_invert_normalize_segmentation_maps