diff --git a/imgaug/augmentables/polys.py b/imgaug/augmentables/polys.py index f139ffb75..afd25a3b0 100644 --- a/imgaug/augmentables/polys.py +++ b/imgaug/augmentables/polys.py @@ -950,7 +950,7 @@ def extract_from_image(self, image): rr_face, cc_face = skimage.draw.polygon( yy_mask, xx_mask, shape=(height_mask, width_mask)) - mask = np.zeros((height_mask, width_mask), dtype=np.bool) + mask = np.zeros((height_mask, width_mask), dtype=np.bool_) mask[rr_face, cc_face] = True if image.ndim == 3: diff --git a/imgaug/augmenters/meta.py b/imgaug/augmenters/meta.py index 9279a0a4d..1de256e8e 100644 --- a/imgaug/augmenters/meta.py +++ b/imgaug/augmenters/meta.py @@ -3384,7 +3384,7 @@ def _get_augmenter_active(self, nb_rows, random_state): # pylint: disable=invalid-name nn = self._get_n(nb_rows, random_state) nn = [min(n, len(self)) for n in nn] - augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool) + augmenter_active = np.zeros((nb_rows, len(self)), dtype=np.bool_) for row_idx, n_true in enumerate(nn): if n_true > 0: augmenter_active[row_idx, 0:n_true] = 1 diff --git a/imgaug/parameters.py b/imgaug/parameters.py index 8167d4ee5..dbf60e12a 100644 --- a/imgaug/parameters.py +++ b/imgaug/parameters.py @@ -2588,7 +2588,7 @@ def _draw_samples(self, size, random_state): # result = np.float_power(samples, exponents) # TODO why was float32 type here replaced with complex number # formulation? - result = np.power(samples.astype(np.complex), exponents).real + result = np.power(samples.astype(np.complex_), exponents).real if result.dtype != samples_dtype: result = result.astype(samples_dtype) @@ -3558,7 +3558,7 @@ def _draw_samples_hw(self, height, width, random_state): wn = wn.astype(np.float32) # equivalent but slightly faster then: - # wn_freqs_mul = np.zeros(treal.shape, dtype=np.complex) + # wn_freqs_mul = np.zeros(treal.shape, dtype=np.complex_) # wn_freqs_mul.real = wn[0] # wn_freqs_mul.imag = wn[1] # wn_inv = np.fft.ifft2(wn_freqs_mul).real diff --git a/test/augmentables/test_bbs.py b/test/augmentables/test_bbs.py index f0caecc2e..f35dbbc53 100644 --- a/test/augmentables/test_bbs.py +++ b/test/augmentables/test_bbs.py @@ -749,7 +749,7 @@ def test_draw_label_on_image(self): def _get_standard_draw_box_on_image_vars(cls): image = np.zeros((10, 10, 3), dtype=np.uint8) bb = ia.BoundingBox(y1=1, x1=1, y2=3, x2=3) - bb_mask = np.zeros(image.shape[0:2], dtype=np.bool) + bb_mask = np.zeros(image.shape[0:2], dtype=np.bool_) bb_mask[1:3+1, 1] = True bb_mask[1:3+1, 3] = True bb_mask[1, 1:3+1] = True @@ -823,7 +823,7 @@ def test_draw_box_on_image_no_copy(self): def test_draw_box_on_image_bb_outside_of_image(self): image = np.zeros((10, 10, 3), dtype=np.uint8) bb = ia.BoundingBox(y1=-1, x1=-1, y2=2, x2=2) - bb_mask = np.zeros(image.shape[0:2], dtype=np.bool) + bb_mask = np.zeros(image.shape[0:2], dtype=np.bool_) bb_mask[2, 0:3] = True bb_mask[0:3, 2] = True @@ -837,7 +837,7 @@ def test_draw_box_on_image_bb_outside_of_image(self): def test_draw_box_on_image_bb_outside_of_image_and_very_small(self): image, bb, bb_mask = self._get_standard_draw_box_on_image_vars() bb = ia.BoundingBox(y1=-1, x1=-1, y2=1, x2=1) - bb_mask = np.zeros(image.shape[0:2], dtype=np.bool) + bb_mask = np.zeros(image.shape[0:2], dtype=np.bool_) bb_mask[0:1+1, 1] = True bb_mask[1, 0:1+1] = True @@ -850,7 +850,7 @@ def test_draw_box_on_image_bb_outside_of_image_and_very_small(self): def test_draw_box_on_image_size_2(self): image, bb, _ = self._get_standard_draw_box_on_image_vars() - bb_mask = np.zeros(image.shape[0:2], dtype=np.bool) + bb_mask = np.zeros(image.shape[0:2], dtype=np.bool_) bb_mask[0:5, 0:5] = True bb_mask[2, 2] = False diff --git a/test/augmentables/test_kps.py b/test/augmentables/test_kps.py index c00d417ee..6df1b48e6 100644 --- a/test/augmentables/test_kps.py +++ b/test/augmentables/test_kps.py @@ -624,7 +624,7 @@ def test_draw_on_image(self): kpi = ia.KeypointsOnImage(keypoints=kps, shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -640,7 +640,7 @@ def test_draw_on_image_alpha_is_50_percent(self): kpi = ia.KeypointsOnImage(keypoints=kps, shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -659,7 +659,7 @@ def test_draw_on_image_size_3(self): kpi = ia.KeypointsOnImage(keypoints=kps, shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -678,7 +678,7 @@ def test_draw_on_image_blue_color(self): kpi = ia.KeypointsOnImage(keypoints=kps, shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -694,7 +694,7 @@ def test_draw_on_image_single_int_as_color(self): kpi = ia.KeypointsOnImage(keypoints=kps, shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -710,7 +710,7 @@ def test_draw_on_image_copy_is_false(self): kpi = ia.KeypointsOnImage(keypoints=kps, shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -733,7 +733,7 @@ def test_draw_on_image_keypoint_is_outside_of_image(self): ) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -766,7 +766,7 @@ def test_draw_on_image_one_kp_at_bottom_right_corner(self): shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -784,7 +784,7 @@ def test_draw_on_image_one_kp_at_bottom_right_corner_and_raise_true(self): shape=(5, 5, 3)) image = np.zeros((5, 5, 3), dtype=np.uint8) + 10 - kps_mask = np.zeros(image.shape[0:2], dtype=np.bool) + kps_mask = np.zeros(image.shape[0:2], dtype=np.bool_) kps_mask[2, 1] = 1 kps_mask[4, 3] = 1 @@ -908,7 +908,7 @@ def test_to_keypoint_image_size_1(self): image = kpi.to_keypoint_image(size=1) - kps_mask = np.zeros((5, 5, 2), dtype=np.bool) + kps_mask = np.zeros((5, 5, 2), dtype=np.bool_) kps_mask[2, 1, 0] = 1 kps_mask[4, 3, 1] = 1 assert np.all(image[kps_mask] == 255) @@ -920,7 +920,7 @@ def test_to_keypoint_image_size_3(self): image = kpi.to_keypoint_image(size=3) - kps_mask = np.zeros((5, 5, 2), dtype=np.bool) + kps_mask = np.zeros((5, 5, 2), dtype=np.bool_) kps_mask[2-1:2+1+1, 1-1:1+1+1, 0] = 1 kps_mask[4-1:4+1+1, 3-1:3+1+1, 1] = 1 assert np.all(image[kps_mask] >= 128) diff --git a/test/augmentables/test_segmaps.py b/test/augmentables/test_segmaps.py index 8b23a10b3..85719f2ac 100644 --- a/test/augmentables/test_segmaps.py +++ b/test/augmentables/test_segmaps.py @@ -107,7 +107,7 @@ def test_bool_arr_3d(self): def test_boolean_masks(self): # Test for #189 (boolean mask inputs into SegmentationMapsOnImage not # working) - for dt in [bool, np.bool]: + for dt in [bool, np.bool_]: arr = np.array([ [0, 0, 0], [0, 1, 0], diff --git a/test/test_dtypes.py b/test/test_dtypes.py index 549ed57b6..9cc658b7e 100644 --- a/test/test_dtypes.py +++ b/test/test_dtypes.py @@ -378,9 +378,6 @@ def test_int_to_uint_with_clip(self): # TODO is the copy_* function still used anywhere class Test_copy_dtypes_for_restore(unittest.TestCase): def test_images_as_list(self): - # TODO using dtype=np.bool is causing this to fail as it ends up - # being instead of . - # Any problems from that for the library? images = [ np.zeros((1, 1, 3), dtype=np.uint8), np.zeros((10, 16, 3), dtype=np.float32), diff --git a/test/test_imgaug.py b/test/test_imgaug.py index a7fdd7026..30a9ff417 100644 --- a/test/test_imgaug.py +++ b/test/test_imgaug.py @@ -225,7 +225,7 @@ class _Dummy(object): np.zeros((1, 2), dtype=np.float16), np.zeros((100,), dtype=np.float32), np.zeros((1, 2), dtype=np.float64), - np.zeros((1, 2), dtype=np.bool) + np.zeros((1, 2), dtype=np.bool_) ] for value in values_true: assert ia.is_integer_array(value) is True @@ -250,7 +250,7 @@ class _Dummy(object): np.zeros((1, 2), dtype=np.uint16), np.zeros((1, 2), dtype=np.int32), np.zeros((1, 2), dtype=np.int64), - np.zeros((1, 2), dtype=np.bool) + np.zeros((1, 2), dtype=np.bool_) ] for value in values_true: assert ia.is_float_array(value) is True