Skip to content

Commit

Permalink
[NumPy] Remove references to deprecated NumPy type aliases.
Browse files Browse the repository at this point in the history
This change replaces references to a number of deprecated NumPy type aliases (np.bool, np.int, np.float, np.complex, np.object, np.str) with their recommended replacement (bool, int, float, complex, object, str).

NumPy 1.24 drops the deprecated aliases, so we must remove uses before updating NumPy.

PiperOrigin-RevId: 497174980
  • Loading branch information
hawkinsp authored and copybara-github committed Dec 22, 2022
1 parent 89a50fa commit 98c0d63
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def eval_grid(self, grid):
"""
# initialize output feature grid
ogrid = np.zeros([self.ijk.shape[0], self.codelen])
niters = np.ceil(self.ijk.shape[0] / self.grid_batch).astype(np.int)
niters = np.ceil(self.ijk.shape[0] / self.grid_batch).astype(int)
for idx in range(niters):
sid = idx * self.grid_batch
eid = min(sid + self.grid_batch, self.ijk.shape[0])
Expand Down Expand Up @@ -580,7 +580,7 @@ def evaluate_feature_grid(self, feature_grid, mask, res_per_part=4,
output_grid = np.ones([res_per_part*s[0],
res_per_part*s[1],
res_per_part*s[2]], dtype=np.float32).reshape(-1)
mask = mask.astype(np.bool)
mask = mask.astype(bool)
if self.overlap:
mask = np.stack([mask[:-1, :-1, :-1],
mask[:-1, :-1, 1:],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def np_shifted_crop(v, idx_grid, shift, crop_size, ntarget):
vall = v.copy()
point_idxs = np.arange(v.shape[0])
point_grid_idx = np.floor(vxyz / crop_size).astype(np.int32)
valid_mask = np.ones(point_grid_idx.shape[0]).astype(np.bool)
valid_mask = np.ones(point_grid_idx.shape[0]).astype(bool)
for i in range(3):
valid_mask = np.logical_and(valid_mask, point_grid_idx[:, i] >= 0)
valid_mask = np.logical_and(valid_mask,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def feature_grid(self):


def occupancy_sparse_to_dense(occ_idx, grid_shape):
dense = np.zeros(grid_shape, dtype=np.bool).ravel()
dense = np.zeros(grid_shape, dtype=bool).ravel()
occ_idx_f = (occ_idx[:, 0] * grid_shape[1] * grid_shape[2] +
occ_idx[:, 1] * grid_shape[2] + occ_idx[:, 2])
dense[occ_idx_f] = True
Expand Down

0 comments on commit 98c0d63

Please sign in to comment.