From f377eb4f851e1d1fdbc92b142928e2982414a141 Mon Sep 17 00:00:00 2001 From: Wadim Kehl Date: Tue, 23 Aug 2022 11:43:09 +0900 Subject: [PATCH] fix: fixing the numpy dtype warnings > v1.19 (#117) * ci: fixing the numpy dtype warnings > v1.19 * ci: fixing the numpy dtype warnings > v1.19 * Merge branch 'master' into chore/wadim/np_warnings --- dgp/datasets/base_dataset.py | 2 +- dgp/datasets/frame_dataset.py | 2 +- dgp/utils/camera.py | 2 +- dgp/utils/structures/instance_mask.py | 6 +++--- dgp/utils/visualization_utils.py | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dgp/datasets/base_dataset.py b/dgp/datasets/base_dataset.py index 879a4a34..4c8d0a08 100644 --- a/dgp/datasets/base_dataset.py +++ b/dgp/datasets/base_dataset.py @@ -363,7 +363,7 @@ def annotation_index(self): total_annotations += list(self.autolabeled_scenes.keys()) scene_annotation_index = xr.DataArray( - np.zeros((len(self.data), len(total_annotations)), dtype=np.bool), + np.zeros((len(self.data), len(total_annotations)), dtype=bool), dims=["datums", "annotations"], coords={"annotations": total_annotations} ) diff --git a/dgp/datasets/frame_dataset.py b/dgp/datasets/frame_dataset.py index eaa4b445..00549336 100644 --- a/dgp/datasets/frame_dataset.py +++ b/dgp/datasets/frame_dataset.py @@ -20,7 +20,7 @@ from dgp.datasets import BaseDataset, DatasetMetadata SUPPORTED_ANNOTATIONS_TABLE = xr.DataArray( - np.zeros((len(DATUM_TYPE_TO_SUPPORTED_ANNOTATION_TYPE), len(ALL_ANNOTATION_TYPES)), dtype=np.bool), + np.zeros((len(DATUM_TYPE_TO_SUPPORTED_ANNOTATION_TYPE), len(ALL_ANNOTATION_TYPES)), dtype=bool), dims=["datum_types", "annotations"], coords={ "datum_types": list(DATUM_TYPE_TO_SUPPORTED_ANNOTATION_TYPE), diff --git a/dgp/utils/camera.py b/dgp/utils/camera.py index fcb30184..1e68d93e 100644 --- a/dgp/utils/camera.py +++ b/dgp/utils/camera.py @@ -334,7 +334,7 @@ def in_frustum(self, X, height, width): Bool array for X which are inside frustum """ if not len(X): - return np.array([], dtype=np.bool) + return np.array([], dtype=bool) corners = np.asarray([(0, 0), (width - 1, 0), (width - 1, height - 1), (0, height - 1)], dtype=np.float32) rays = self.unproject(corners) diff --git a/dgp/utils/structures/instance_mask.py b/dgp/utils/structures/instance_mask.py index ca5400f2..5ba304e7 100644 --- a/dgp/utils/structures/instance_mask.py +++ b/dgp/utils/structures/instance_mask.py @@ -13,7 +13,7 @@ class InstanceMask2D(): Parameters ---------- - mask: np.ndarray[np.bool, np.uint8, np.int64] + mask: np.ndarray[bool, np.uint8, np.int64] 2D boolean array describiing instance mask. class_id: int, default: GENERIC_OBJECT_CLASS @@ -28,7 +28,7 @@ class InstanceMask2D(): defaults to empty dict. """ def __init__(self, mask, class_id=GENERIC_OBJECT_CLASS, instance_id=None, color=(0, 0, 0), attributes=None): - assert mask.dtype in (np.bool, np.uint8, np.int64) + assert mask.dtype in (bool, np.uint8, np.int64) self._bitmask = mask self._class_id = class_id @@ -120,7 +120,7 @@ class RLEMask(): Parameters ---------- - size: list[int] or np.ndarray[np.int] + size: list[int] or np.ndarray[int] Height and width of mask. counts: list[int] Count-encoding of RLE format. diff --git a/dgp/utils/visualization_utils.py b/dgp/utils/visualization_utils.py index d8c7eebd..1bdaadee 100644 --- a/dgp/utils/visualization_utils.py +++ b/dgp/utils/visualization_utils.py @@ -99,7 +99,7 @@ def mosaic(items, scale=1.0, pad=3, grid_width=None): N = len(items) assert N > 0, 'No items to mosaic!' grid_width = grid_width if grid_width else np.ceil(np.sqrt(N)).astype(int) - grid_height = np.ceil(N * 1. / grid_width).astype(np.int) + grid_height = np.ceil(N * 1.0 / grid_width).astype(int) input_size = items[0].shape[:2] target_shape = (int(input_size[1] * scale), int(input_size[0] * scale)) mosaic_items = [] @@ -340,7 +340,7 @@ def clip_norm(v, x): v_2d = row_tail - row v_2d = clip_norm(v_2d, velocity_max_pix * W) cx, cy = row - cx2, cy2 = row + v_2d.astype(np.int) + cx2, cy2 = row + v_2d.astype(int) cx2 = np.clip(cx2, 0, W - 1) cy2 = np.clip(cy2, 0, H - 1) cv2.arrowedLine(img, (cx, cy), (cx2, cy2), color, thickness=2, line_type=cv2.LINE_AA) @@ -552,7 +552,7 @@ def clip_norm(v, x): v_2d = clip_norm(v_2d, velocity_max_pix * W) cx, cy = row - cx2, cy2 = row + v_2d.astype(np.int) + cx2, cy2 = row + v_2d.astype(int) cx2 = np.clip(cx2, 0, W - 1) cy2 = np.clip(cy2, 0, H - 1)