running install tests ============================= test session starts ============================== platform linux -- Python 3.7.4, pytest-5.1.0, py-1.8.0, pluggy-0.12.0 rootdir: /build/imgaug-0.2.9 collected 388 items test/test_dtypes.py .. [ 0%] test/test_imgaug.py .....................FF........F..F.... [ 10%] test/test_multicore.py ................ [ 14%] test/test_parameters.py ................................... [ 23%] test/augmentables/test_batches.py ... [ 24%] test/augmentables/test_bbs.py .. [ 25%] test/augmentables/test_heatmaps.py .......... [ 27%] test/augmentables/test_kps.py .. [ 28%] test/augmentables/test_lines.py ........................................ [ 38%] ............ [ 41%] test/augmentables/test_normalization.py ...................... [ 47%] test/augmentables/test_polys.py ........................................ [ 57%] ................ [ 61%] test/augmentables/test_segmaps.py ........... [ 64%] test/augmentables/test_utils.py ... [ 65%] test/augmenters/test_arithmetic.py ................ [ 69%] test/augmenters/test_blend.py ... [ 70%] test/augmenters/test_blur.py .............. [ 73%] test/augmenters/test_color.py .. [ 74%] test/augmenters/test_contrast.py ..................................... [ 83%] test/augmenters/test_convolutional.py ... [ 84%] test/augmenters/test_flip.py .... [ 85%] test/augmenters/test_geometric.py .....F [ 87%] test/augmenters/test_meta.py .................................. [ 95%] test/augmenters/test_mixed_files.py .... [ 96%] test/augmenters/test_segmentation.py . [ 97%] test/augmenters/test_size.py ....... [ 98%] test/augmenters/test_weather.py .... [100%] =================================== FAILURES =================================== _________________________________ test_quokka __________________________________ def test_quokka(): img = ia.quokka() assert img.shape == (643, 960, 3) > assert np.allclose( np.average(img, axis=(0, 1)), [107.93576659, 118.18765066, 122.99378564] ) E assert False E + where False = (array([107.92622311, 118.19145607, 122.98959467]), [107.93576659, 118.18765066, 122.99378564]) E + where = np.allclose E + and array([107.92622311, 118.19145607, 122.98959467]) = (Array([[[ 49, 78, 82],\n [ 49, 78, 82],\n [ 49, 78, 82],\n ...,\n [ 38, 66, 78],\n ...[236, 237, 231],\n ...,\n [209, 210, 205],\n [209, 210, 205],\n [208, 209, 204]]], dtype=uint8), axis=(0, 1)) E + where = np.average test/test_imgaug.py:457: AssertionError ______________________________ test_quokka_square ______________________________ def test_quokka_square(): img = ia.quokka_square() assert img.shape == (643, 643, 3) > assert np.allclose( np.average(img, axis=(0, 1)), [111.25929196, 121.19431175, 125.71316898] ) E assert False E + where False = (array([111.24956403, 121.19801475, 125.70819134]), [111.25929196, 121.19431175, 125.71316898]) E + where = np.allclose E + and array([111.24956403, 121.19801475, 125.70819134]) = (Array([[[ 49, 78, 82],\n [ 49, 78, 82],\n [ 49, 78, 82],\n ...,\n [ 49, 79, 90],\n ...[236, 237, 231],\n ...,\n [234, 234, 232],\n [234, 234, 232],\n [235, 235, 233]]], dtype=uint8), axis=(0, 1)) E + where = np.average test/test_imgaug.py:480: AssertionError ___________________________________ test_pad ___________________________________ def test_pad(): # ------- # uint, int # ------- for dtype in [np.uint8, np.uint16, np.uint32, np.int8, np.int16, np.int32, np.int64]: min_value, center_value, max_value = iadt.get_value_range_of_dtype(dtype) arr = np.zeros((3, 3), dtype=dtype) + max_value arr_pad = ia.pad(arr) assert arr_pad.shape == (3, 3) # For some reason, arr_pad.dtype.type == dtype fails here for int64 but not for the other dtypes, # even though int64 is the dtype of arr_pad. Also checked .name and .str for them -- all same value. assert arr_pad.dtype == np.dtype(dtype) assert np.array_equal(arr_pad, arr) arr_pad = ia.pad(arr, top=1) assert arr_pad.shape == (4, 3) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[0, :] == 0) arr_pad = ia.pad(arr, right=1) assert arr_pad.shape == (3, 4) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[:, -1] == 0) arr_pad = ia.pad(arr, bottom=1) assert arr_pad.shape == (4, 3) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[-1, :] == 0) arr_pad = ia.pad(arr, left=1) assert arr_pad.shape == (3, 4) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[:, 0] == 0) arr_pad = ia.pad(arr, top=1, right=2, bottom=3, left=4) assert arr_pad.shape == (3+(1+3), 3+(2+4)) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[0, :] == 0) assert np.all(arr_pad[:, -2:] == 0) assert np.all(arr_pad[-3:, :] == 0) assert np.all(arr_pad[:, :4] == 0) arr_pad = ia.pad(arr, top=1, cval=10) assert arr_pad.shape == (4, 3) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[0, :] == 10) arr = np.zeros((3, 3, 3), dtype=dtype) + 127 arr_pad = ia.pad(arr, top=1) assert arr_pad.shape == (4, 3, 3) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[0, :, 0] == 0) assert np.all(arr_pad[0, :, 1] == 0) assert np.all(arr_pad[0, :, 2] == 0) v1 = int(center_value + 0.25 * max_value) v2 = int(center_value + 0.40 * max_value) arr = np.zeros((3, 3), dtype=dtype) + v1 arr[1, 1] = v2 arr_pad = ia.pad(arr, top=1, mode="maximum") assert arr_pad.shape == (4, 3) assert arr_pad.dtype == np.dtype(dtype) assert arr_pad[0, 0] == v1 assert arr_pad[0, 1] == v2 assert arr_pad[0, 2] == v1 v1 = int(center_value + 0.25 * max_value) arr = np.zeros((3, 3), dtype=dtype) arr_pad = ia.pad(arr, top=1, mode="constant", cval=v1) assert arr_pad.shape == (4, 3) assert arr_pad.dtype == np.dtype(dtype) assert arr_pad[0, 0] == v1 assert arr_pad[0, 1] == v1 assert arr_pad[0, 2] == v1 assert arr_pad[1, 0] == 0 for nb_channels in [1, 2, 3, 4, 5]: v1 = int(center_value + 0.25 * max_value) arr = np.zeros((3, 3, nb_channels), dtype=dtype) arr_pad = ia.pad(arr, top=1, mode="constant", cval=v1) assert arr_pad.shape == (4, 3, nb_channels) assert arr_pad.dtype == np.dtype(dtype) assert np.all(arr_pad[0, 0, :] == v1) assert np.all(arr_pad[0, 1, :] == v1) assert np.all(arr_pad[0, 2, :] == v1) assert np.all(arr_pad[1, 0, :] == 0) arr = np.zeros((1, 1), dtype=dtype) + 0 arr_pad = ia.pad(arr, top=4, mode="linear_ramp", cval=100) assert arr_pad.shape == (5, 1) assert arr_pad.dtype == np.dtype(dtype) assert arr_pad[0, 0] == 100 > assert arr_pad[1, 0] == 75 E assert 139 == 75 test/test_imgaug.py:1151: AssertionError __________________________________ test_pool ___________________________________ def test_pool(): # ----- # uint, int # ----- for dtype in [np.uint8, np.uint16, np.uint32, np.int8, np.int16, np.int32]: min_value, center_value, max_value = iadt.get_value_range_of_dtype(dtype) for func in [np.min, np.average, np.max]: arr = np.array([ [0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15] ], dtype=dtype) arr_pooled = ia.pool(arr, 2, func) assert arr_pooled.shape == (2, 2) assert arr_pooled.dtype == np.dtype(dtype) assert arr_pooled[0, 0] == int(func([0, 1, 4, 5])) assert arr_pooled[0, 1] == int(func([2, 3, 6, 7])) assert arr_pooled[1, 0] == int(func([8, 9, 12, 13])) assert arr_pooled[1, 1] == int(func([10, 11, 14, 15])) arr = np.array([ [0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15] ], dtype=dtype) arr = np.tile(arr[:, :, np.newaxis], (1, 1, 3)) arr[..., 1] += 1 arr[..., 2] += 2 arr_pooled = ia.pool(arr, 2, func) assert arr_pooled.shape == (2, 2, 3) assert arr_pooled.dtype == np.dtype(dtype) for c in sm.xrange(3): assert arr_pooled[0, 0, c] == int(func([0, 1, 4, 5])) + c assert arr_pooled[0, 1, c] == int(func([2, 3, 6, 7])) + c assert arr_pooled[1, 0, c] == int(func([8, 9, 12, 13])) + c assert arr_pooled[1, 1, c] == int(func([10, 11, 14, 15])) + c for value in [min_value, min_value+50, min_value+100, 0, 10, max_value, int(center_value + 0.10*max_value), int(center_value + 0.20*max_value), int(center_value + 0.25*max_value), int(center_value + 0.33*max_value)]: arr = np.full((4, 4), value, dtype=dtype) arr_pooled = ia.pool(arr, 2, func) assert arr_pooled.shape == (2, 2) assert arr_pooled.dtype == np.dtype(dtype) assert np.all(arr_pooled == value) arr = np.full((4, 4, 3), value, dtype=dtype) arr_pooled = ia.pool(arr, 2, func) assert arr_pooled.shape == (2, 2, 3) assert arr_pooled.dtype == np.dtype(dtype) assert np.all(arr_pooled == value) # ----- # float # ----- for dtype in [np.float16, np.float32, np.float64, np.float128]: def _allclose(a, b): atol = 1e-4 if dtype == np.float16 else 1e-8 return np.allclose(a, b, atol=atol, rtol=0) for func in [np.min, np.average, np.max]: arr = np.array([ [0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15] ], dtype=dtype) arr_pooled = ia.pool(arr, 2, func) assert arr_pooled.shape == (2, 2) assert arr_pooled.dtype == np.dtype(dtype) assert arr_pooled[0, 0] == func([0, 1, 4, 5]) assert arr_pooled[0, 1] == func([2, 3, 6, 7]) assert arr_pooled[1, 0] == func([8, 9, 12, 13]) assert arr_pooled[1, 1] == func([10, 11, 14, 15]) arr = np.array([ [0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15] ], dtype=dtype) arr = np.tile(arr[:, :, np.newaxis], (1, 1, 3)) arr[..., 1] += 1 arr[..., 2] += 2 arr_pooled = ia.pool(arr, 2, func) assert arr_pooled.shape == (2, 2, 3) assert arr_pooled.dtype == np.dtype(dtype) for c in sm.xrange(3): assert arr_pooled[0, 0, c] == func([0, 1, 4, 5]) + c assert arr_pooled[0, 1, c] == func([2, 3, 6, 7]) + c assert arr_pooled[1, 0, c] == func([8, 9, 12, 13]) + c assert arr_pooled[1, 1, c] == func([10, 11, 14, 15]) + c isize = np.dtype(dtype).itemsize for value in [(-1) * (1000 ** (isize-1)), -50.0, 0.0, 50.0, 1000 ** (isize-1)]: arr = np.full((4, 4), value, dtype=dtype) arr_pooled = ia.pool(arr, 2, func) dt = np.result_type(arr_pooled, 1.) y = np.array(arr_pooled, dtype=dt, copy=False, subok=True) assert arr_pooled.shape == (2, 2) assert arr_pooled.dtype == np.dtype(dtype) > assert _allclose(arr_pooled, float(value)) E assert False E + where False = ._allclose at 0x7fffc9663290>(array([[-1.e+45, -1.e+45],\n [-1.e+45, -1.e+45]], dtype=float128), -1e+45) E + where -1e+45 = float(-10000000000000000...0000000000000000000) test/test_imgaug.py:1585: AssertionError __________________________________ test_Rot90 __________________________________ def test_Rot90(): img = np.arange(4*4*3).reshape((4, 4, 3)).astype(np.uint8) hms = ia.HeatmapsOnImage(img[..., 0:1].astype(np.float32) / 255, shape=(4, 4, 3)) hms_smaller = ia.HeatmapsOnImage(np.float32([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]), shape=(4, 8, 3)) kpsoi = ia.KeypointsOnImage([ia.Keypoint(x=1, y=2), ia.Keypoint(x=2, y=3)], shape=(4, 8, 3)) psoi = ia.PolygonsOnImage( [ia.Polygon([(1, 1), (3, 1), (3, 3), (1, 3)])], shape=(4, 8, 3) ) # k=0, k=4 for k in [0, 4]: aug = iaa.Rot90(k, keep_size=False) img_aug = aug.augment_image(img) assert img_aug.dtype == np.uint8 assert np.array_equal(img_aug, img) hms_aug = aug.augment_heatmaps([hms])[0] assert hms_aug.arr_0to1.dtype == hms.arr_0to1.dtype assert np.allclose(hms_aug.arr_0to1, hms.arr_0to1) assert hms_aug.shape == hms.shape kpsoi_aug = aug.augment_keypoints([kpsoi])[0] assert kpsoi_aug.shape == kpsoi.shape for kp_aug, kp in zip(kpsoi_aug.keypoints, kpsoi.keypoints): assert np.allclose([kp_aug.x, kp_aug.y], [kp.x, kp.y]) psoi_aug = aug.augment_polygons(psoi) assert psoi_aug.shape == psoi.shape assert len(psoi_aug.polygons) == 1 assert psoi_aug.polygons[0].is_valid for poly_aug, poly in zip(psoi_aug.polygons, psoi.polygons): assert np.allclose(poly_aug.exterior, poly.exterior) # k=1, k=5 for k in [1, 5]: aug = iaa.Rot90(k, keep_size=False) img_aug = aug.augment_image(img) assert img_aug.dtype == np.uint8 assert np.array_equal(img_aug, np.rot90(img, 1, axes=(1, 0))) hms_aug = aug.augment_heatmaps([hms])[0] assert hms_aug.arr_0to1.dtype == hms.arr_0to1.dtype assert np.allclose(hms_aug.arr_0to1, np.rot90(hms.arr_0to1, 1, axes=(1, 0))) assert hms_aug.shape == (4, 4, 3) hms_smaller_aug = aug.augment_heatmaps([hms_smaller])[0] assert hms_smaller_aug.arr_0to1.dtype == hms_smaller.arr_0to1.dtype assert np.allclose(hms_smaller_aug.arr_0to1, np.rot90(hms_smaller.arr_0to1, 1, axes=(1, 0))) assert hms_smaller_aug.shape == (8, 4, 3) kpsoi_aug = aug.augment_keypoints([kpsoi])[0] assert kpsoi_aug.shape == (8, 4, 3) expected = [(1, 1), (0, 2)] for kp_aug, kp in zip(kpsoi_aug.keypoints, expected): assert np.allclose([kp_aug.x, kp_aug.y], [kp[0], kp[1]]) psoi_aug = aug.augment_polygons(psoi) assert psoi_aug.shape == (8, 4, 3) assert len(psoi_aug.polygons) == 1 assert psoi_aug.polygons[0].is_valid expected = [(4-1-1, 1), (4-1-1, 3), (4-3-1, 3), (4-1-3, 1)] assert psoi_aug.polygons[0].exterior_almost_equals(expected) # k=2 aug = iaa.Rot90(2, keep_size=False) img_aug = aug.augment_image(img) assert img_aug.dtype == np.uint8 assert np.array_equal(img_aug, np.rot90(img, 2, axes=(1, 0))) hms_aug = aug.augment_heatmaps([hms])[0] assert hms_aug.arr_0to1.dtype == hms.arr_0to1.dtype assert np.allclose(hms_aug.arr_0to1, np.rot90(hms.arr_0to1, 2, axes=(1, 0))) assert hms_aug.shape == (4, 4, 3) hms_smaller_aug = aug.augment_heatmaps([hms_smaller])[0] assert hms_smaller_aug.arr_0to1.dtype == hms_smaller.arr_0to1.dtype assert np.allclose(hms_smaller_aug.arr_0to1, np.rot90(hms_smaller.arr_0to1, 2, axes=(1, 0))) assert hms_smaller_aug.shape == (4, 8, 3) kpsoi_aug = aug.augment_keypoints([kpsoi])[0] assert kpsoi_aug.shape == (4, 8, 3) expected = [(6, 1), (5, 0)] for kp_aug, kp in zip(kpsoi_aug.keypoints, expected): assert np.allclose([kp_aug.x, kp_aug.y], [kp[0], kp[1]]) psoi_aug = aug.augment_polygons(psoi) assert psoi_aug.shape == (4, 8, 3) assert len(psoi_aug.polygons) == 1 assert psoi_aug.polygons[0].is_valid expected = [(8-1-1, 2), (8-1-3, 2), (8-1-3, 0), (8-1-1, 0)] assert psoi_aug.polygons[0].exterior_almost_equals(expected) # k=3, k=-1 for k in [3, -1]: aug = iaa.Rot90(k, keep_size=False) img_aug = aug.augment_image(img) assert img_aug.dtype == np.uint8 assert np.array_equal(img_aug, np.rot90(img, 3, axes=(1, 0))) hms_aug = aug.augment_heatmaps([hms])[0] assert hms_aug.arr_0to1.dtype == hms.arr_0to1.dtype assert np.allclose(hms_aug.arr_0to1, np.rot90(hms.arr_0to1, 3, axes=(1, 0))) assert hms_aug.shape == (4, 4, 3) hms_smaller_aug = aug.augment_heatmaps([hms_smaller])[0] assert hms_smaller_aug.arr_0to1.dtype == hms_smaller.arr_0to1.dtype assert np.allclose(hms_smaller_aug.arr_0to1, np.rot90(hms_smaller.arr_0to1, 3, axes=(1, 0))) assert hms_smaller_aug.shape == (8, 4, 3) kpsoi_aug = aug.augment_keypoints([kpsoi])[0] assert kpsoi_aug.shape == (8, 4, 3) expected = [(2, 6), (3, 5)] for kp_aug, kp in zip(kpsoi_aug.keypoints, expected): assert np.allclose([kp_aug.x, kp_aug.y], [kp[0], kp[1]]) psoi_aug = aug.augment_polygons(psoi) assert psoi_aug.shape == (8, 4, 3) assert len(psoi_aug.polygons) == 1 assert psoi_aug.polygons[0].is_valid expected = [(4-1-2, 6), (4-1-2, 4), (4-1-0, 4), (4-1-0, 6)] assert psoi_aug.polygons[0].exterior_almost_equals(expected) # verify once without np.rot90 img_aug = iaa.Rot90(k=1, keep_size=False).augment_image( np.uint8([[1, 0, 0], [0, 2, 0]]) ) expected = np.uint8([[0, 1], [2, 0], [0, 0]]) assert np.array_equal(img_aug, expected) # keep_size=True, k=1 aug = iaa.Rot90(1, keep_size=True) img_nonsquare = np.arange(5*4*3).reshape((5, 4, 3)).astype(np.uint8) img_aug = aug.augment_image(img_nonsquare) assert img_aug.dtype == np.uint8 assert np.array_equal( img_aug, ia.imresize_single_image(np.rot90(img_nonsquare, 1, axes=(1, 0)), (5, 4), interpolation="cubic") ) hms_aug = aug.augment_heatmaps([hms])[0] assert hms_aug.arr_0to1.dtype == hms.arr_0to1.dtype assert np.allclose(hms_aug.arr_0to1, np.rot90(hms.arr_0to1, 1, axes=(1, 0))) assert hms_aug.shape == (4, 4, 3) hms_smaller_aug = aug.augment_heatmaps([hms_smaller])[0] assert hms_smaller_aug.arr_0to1.dtype == hms_smaller.arr_0to1.dtype hms_smaller_rot = np.rot90(hms_smaller.arr_0to1, 1, axes=(1, 0)) hms_smaller_rot = np.clip(ia.imresize_single_image(hms_smaller_rot, (2, 3), interpolation="cubic"), 0.0, 1.0) assert np.allclose(hms_smaller_aug.arr_0to1, hms_smaller_rot) assert hms_smaller_aug.shape == (4, 8, 3) kpsoi_aug = aug.augment_keypoints([kpsoi])[0] assert kpsoi_aug.shape == (4, 8, 3) expected = [(1, 1), (0, 2)] expected = [(8*x/4, 4*y/8) for x, y in expected] for kp_aug, kp in zip(kpsoi_aug.keypoints, expected): assert np.allclose([kp_aug.x, kp_aug.y], [kp[0], kp[1]]) psoi_aug = aug.augment_polygons(psoi) assert psoi_aug.shape == (4, 8, 3) assert len(psoi_aug.polygons) == 1 assert psoi_aug.polygons[0].is_valid expected = [(4-1-1, 1), (4-1-1, 3), (4-3-1, 3), (4-1-3, 1)] expected = [(8*x/4, 4*y/8) for x, y in expected] assert psoi_aug.polygons[0].exterior_almost_equals(expected) # test parameter stochasticity aug = iaa.Rot90([1, 3]) assert isinstance(aug.k, iap.Choice) assert len(aug.k.a) == 2 assert aug.k.a[0] == 1 assert aug.k.a[1] == 3 class _TwoValueParam(iap.StochasticParameter): def __init__(self, v1, v2): super(_TwoValueParam, self).__init__() self.v1 = v1 self.v2 = v2 def _draw_samples(self, size, random_state): arr = np.full(size, self.v1, dtype=np.int32) arr[1::2] = self.v2 return arr aug = iaa.Rot90(_TwoValueParam(1, 2), keep_size=False) imgs_aug = aug.augment_images([img] * 4) assert np.array_equal(imgs_aug[0], np.rot90(img, 1, axes=(1, 0))) assert np.array_equal(imgs_aug[1], np.rot90(img, 2, axes=(1, 0))) assert np.array_equal(imgs_aug[2], np.rot90(img, 1, axes=(1, 0))) assert np.array_equal(imgs_aug[3], np.rot90(img, 2, axes=(1, 0))) hms_aug = aug.augment_heatmaps([hms_smaller] * 4) assert hms_aug[0].shape == (8, 4, 3) assert hms_aug[1].shape == (4, 8, 3) assert hms_aug[2].shape == (8, 4, 3) assert hms_aug[3].shape == (4, 8, 3) assert np.allclose(hms_aug[0].arr_0to1, np.rot90(hms_smaller.arr_0to1, 1, axes=(1, 0))) assert np.allclose(hms_aug[1].arr_0to1, np.rot90(hms_smaller.arr_0to1, 2, axes=(1, 0))) assert np.allclose(hms_aug[2].arr_0to1, np.rot90(hms_smaller.arr_0to1, 1, axes=(1, 0))) assert np.allclose(hms_aug[3].arr_0to1, np.rot90(hms_smaller.arr_0to1, 2, axes=(1, 0))) kpsoi_aug = aug.augment_keypoints([kpsoi] * 4) assert kpsoi_aug[0].shape == (8, 4, 3) assert kpsoi_aug[1].shape == (4, 8, 3) assert kpsoi_aug[2].shape == (8, 4, 3) assert kpsoi_aug[3].shape == (4, 8, 3) assert np.allclose([kpsoi_aug[0].keypoints[0].x, kpsoi_aug[0].keypoints[0].y], [1, 1]) assert np.allclose([kpsoi_aug[0].keypoints[1].x, kpsoi_aug[0].keypoints[1].y], [0, 2]) assert np.allclose([kpsoi_aug[1].keypoints[0].x, kpsoi_aug[1].keypoints[0].y], [6, 1]) assert np.allclose([kpsoi_aug[1].keypoints[1].x, kpsoi_aug[1].keypoints[1].y], [5, 0]) assert np.allclose([kpsoi_aug[2].keypoints[0].x, kpsoi_aug[2].keypoints[0].y], [1, 1]) assert np.allclose([kpsoi_aug[2].keypoints[1].x, kpsoi_aug[2].keypoints[1].y], [0, 2]) assert np.allclose([kpsoi_aug[3].keypoints[0].x, kpsoi_aug[3].keypoints[0].y], [6, 1]) assert np.allclose([kpsoi_aug[3].keypoints[1].x, kpsoi_aug[3].keypoints[1].y], [5, 0]) psoi_aug = aug.augment_polygons([psoi] * 4) assert psoi_aug[0].shape == (8, 4, 3) assert psoi_aug[1].shape == (4, 8, 3) assert psoi_aug[2].shape == (8, 4, 3) assert psoi_aug[3].shape == (4, 8, 3) expected_rot1 = [(4-1-1, 1), (4-1-1, 3), (4-3-1, 3), (4-1-3, 1)] expected_rot2 = [(8-1-1, 2), (8-1-3, 2), (8-1-3, 0), (8-1-1, 0)] assert psoi_aug[0].polygons[0].exterior_almost_equals(expected_rot1) assert psoi_aug[1].polygons[0].exterior_almost_equals(expected_rot2) assert psoi_aug[2].polygons[0].exterior_almost_equals(expected_rot1) assert psoi_aug[3].polygons[0].exterior_almost_equals(expected_rot2) # test empty keypoints aug = iaa.Rot90(k=1, keep_size=False) kpsoi_aug = aug.augment_keypoints(ia.KeypointsOnImage([], shape=(4, 8, 3))) assert len(kpsoi_aug.keypoints) == 0 assert kpsoi_aug.shape == (8, 4, 3) # test empty polygons aug = iaa.Rot90(k=1, keep_size=False) psoi_aug = aug.augment_polygons(ia.PolygonsOnImage([], shape=(4, 8, 3))) assert len(psoi_aug.polygons) == 0 assert psoi_aug.shape == (8, 4, 3) # get_parameters() aug = iaa.Rot90([1, 3], keep_size=False) assert aug.get_parameters()[0] == aug.k assert aug.get_parameters()[1] is False ################### # test other dtypes ################### aug = iaa.Rot90(2) # bool image = np.zeros((3, 3), dtype=bool) image[0, 0] = True image_aug = aug.augment_image(image) assert image_aug.dtype == image.dtype assert np.all(image_aug[0, 0] == 0) assert np.all(image_aug[2, 2] == 1) # uint, int for dtype in [np.uint8, np.uint16, np.uint32, np.uint64, np.int8, np.int16, np.int32, np.int64]: min_value, center_value, max_value = iadt.get_value_range_of_dtype(dtype) image = np.zeros((3, 3), dtype=dtype) image[0, 0] = max_value image_aug = aug.augment_image(image) assert image_aug.dtype == np.dtype(dtype) assert np.all(image_aug[0, 0] == 0) assert np.all(image_aug[2, 2] == max_value) # float for dtype in [np.float16, np.float32, np.float64, np.float128]: def _allclose(a, b): atol = 1e-4 if dtype == np.float16 else 1e-8 return np.allclose(a, b, atol=atol, rtol=0) isize = np.dtype(dtype).itemsize values = [0, 1.0, 10.0, 100.0, 500 ** (isize-1), 1000 ** (isize-1)] values = values + [(-1) * value for value in values] for value in values: image = np.zeros((3, 3), dtype=dtype) image[0, 0] = value image_aug = aug.augment_image(image) assert image_aug.dtype == np.dtype(dtype) assert _allclose(image_aug[0, 0], 0) > assert _allclose(image_aug[2, 2], float(value)) E assert False E + where False = ._allclose at 0x7fffc8d82e60>(3.0517578125e+40, 3.0517578125e+40) E + where 3.0517578125e+40 = float(305175781250000000...0000000000000000000) test/augmenters/test_geometric.py:4096: AssertionError =============================== warnings summary =============================== /nix/store/jg1h9afkxrnv5skznk4msl6lzxx00xaz-python3.7-PyWavelets-1.0.3/lib/python3.7/site-packages/pywt/_utils.py:6 /nix/store/jg1h9afkxrnv5skznk4msl6lzxx00xaz-python3.7-PyWavelets-1.0.3/lib/python3.7/site-packages/pywt/_utils.py:6: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Iterable test/augmenters/test_arithmetic.py::test_ReplaceElementwise test/augmenters/test_arithmetic.py::test_ReplaceElementwise /nix/store/5qfb84vbps55ip13kv5qnvh7aml9qfkq-python3.7-numpy-1.17.0/lib/python3.7/site-packages/numpy/core/_methods.py:132: DeprecationWarning: Converting the output of clip from dtype('float64') to dtype('int64') is deprecated. Pass `casting="unsafe"` explicitly to silence this warning, or correct the type of the variables. um.clip, a, min, max, out=out, casting=casting, **kwargs) -- Docs: https://docs.pytest.org/en/latest/warnings.html ============ 5 failed, 383 passed, 3 warnings in 199.71s (0:03:19) =============