Skip to content

Commit

Permalink
compat: Support numpy >=1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
mdraw committed Jun 21, 2023
1 parent ce73d7f commit a8b8fa0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions elektronn3/data/coord_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def make_dest_coords(sh):
Make coordinate list for destination array of shape sh
"""
zz,xx,yy = np.mgrid[0:sh[0], 0:sh[1], 0:sh[2]]
hh = np.ones(sh, dtype=np.int)
hh = np.ones(sh, dtype=np.int64)
coords = np.concatenate([zz[...,None], xx[...,None],
yy[...,None], hh[...,None]], axis=-1)
return coords.astype(floatX)
Expand Down Expand Up @@ -382,8 +382,8 @@ def warp_slice(

# check corners
src_corners = src_corners[:,:3]
lo = np.min(np.floor(src_corners), 0).astype(np.int)
hi = np.max(np.ceil(src_corners + 1), 0).astype(np.int)
lo = np.min(np.floor(src_corners), 0).astype(np.int64)
hi = np.max(np.ceil(src_corners + 1), 0).astype(np.int64)
# compute/transform dense coords
dest_coords = make_dest_coords(patch_shape)
src_coords = np.tensordot(dest_coords, M_inv, axes=[[-1], [1]])
Expand Down Expand Up @@ -438,8 +438,8 @@ def warp_slice(
target_offset[2]:(target_offset[2] + target_patch_shape[2])
]
# shift coords to be w.r.t. to origin of target_src array
lo_targ = np.floor(src_coords_target.min(2).min(1).min(0) - target_src_offset).astype(np.int)
hi_targ = np.ceil(src_coords_target.max(2).max(1).max(0) + 1 - target_src_offset).astype(np.int)
lo_targ = np.floor(src_coords_target.min(2).min(1).min(0) - target_src_offset).astype(np.int64)
hi_targ = np.ceil(src_coords_target.max(2).max(1).max(0) + 1 - target_src_offset).astype(np.int64)
if np.any(lo_targ < 0) or np.any(hi_targ >= target_src_shape - 1):
raise WarpingOOBError("Out of bounds for target_src")

Expand Down
2 changes: 1 addition & 1 deletion elektronn3/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def _ensure_matching_shapes(self, inp: np.ndarray) -> Tuple[np.ndarray, Optional
padded_out_shape = np.array(self.out_shape)
padded_out_shape[1:] = np.ceil(self.out_shape[1:] / self.tile_shape) * self.tile_shape
if self.offset is None:
offset = np.zeros(shape=len(padded_out_shape) - 1, dtype=np.int)
offset = np.zeros(shape=len(padded_out_shape) - 1, dtype=np.int64)
else:
offset = np.array(self.offset)
padded_inp_shape = (*inp.shape[:2], *padded_out_shape[1:] + 2 * offset)
Expand Down
2 changes: 1 addition & 1 deletion elektronn3/training/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def add_timeticks(ax, times, steps, time_str='mins', num=5):
k = int(np.log10(k)) # 10-base of locators
m = int(np.round(float(N) / (num * 10 ** k))) # multiple of base
s = max(m * 10 ** k, 1)
x_labs = np.arange(0, N, s, dtype=np.int)
x_labs = np.arange(0, N, s, dtype=np.int64)
x_ticks = np.interp(x_labs, times, steps)
ax.set_xticks(x_ticks)
ax.set_xticklabels(x_labs)
Expand Down

0 comments on commit a8b8fa0

Please sign in to comment.