Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ imagecodecs>=2022.9.26
joblib>=1.1.1
jupyterlab>=3.5.2
matplotlib>=3.6.2
numpy>=1.23.5, <1.24 # v1.24 produces error on Windows
numba>=0.57.0
numpy>=1.23.5
opencv-python>=4.6.0
openslide-python>=1.2.0
pandas>=2.0.0
Expand Down
4 changes: 3 additions & 1 deletion tests/models/test_patch_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def test_patch_dataset_crash(tmp_path):
_ = PatchDataset(imgs)

# ndarray of mixed dtype
imgs = np.array([np.random.randint(0, 255, (4, 5, 3)), "Should crash"])
imgs = np.array(
[np.random.randint(0, 255, (4, 5, 3)), "Should crash"], dtype=object
)
with pytest.raises(ValueError, match="Provided input array is non-numerical."):
_ = PatchDataset(imgs)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_imresize():
# test for dtype conversion, pairs of
# (original type, converted type)
test_dtypes = [
(np.bool, np.uint8),
(np.bool_, np.uint8),
(np.int8, np.int16),
(np.int16, np.int16),
(np.int32, np.float32),
Expand Down Expand Up @@ -1053,8 +1053,8 @@ def edge_mask(bounds: Tuple[int, int, int, int]) -> np.ndarray:
l, t, r, b = bounds
slide_width, slide_height = slide_dimensions
x, y = np.meshgrid(np.arange(l, r), np.arange(t, b), indexing="ij")
under = np.logical_or(x < 0, y < 0).astype(np.int)
over = np.logical_or(x >= slide_width, y >= slide_height).astype(np.int)
under = np.logical_or(x < 0, y < 0).astype(np.int_)
over = np.logical_or(x >= slide_width, y >= slide_height).astype(np.int_)
return under, over

loc = (-5, -5)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def read_bounds_level_consistency(wsi, bounds):
# from interpolation when calculating the downsampled levels. This
# adds some tolerance for the comparison.
blurred = [cv2.GaussianBlur(img, (5, 5), cv2.BORDER_REFLECT) for img in resized]
as_float = [img.astype(np.float) for img in blurred]
as_float = [img.astype(np.float_) for img in blurred]

# Pair-wise check resolutions for mean squared error
for i, a in enumerate(as_float):
Expand Down Expand Up @@ -2373,7 +2373,7 @@ def test_read_rect_level_consistency(sample_key, reader_class, kwargs):
# from interpolation when calculating the downsampled levels. This
# adds some tolerance for the comparison.
blurred = [cv2.GaussianBlur(img, (5, 5), cv2.BORDER_REFLECT) for img in resized]
as_float = [img.astype(np.float) for img in blurred]
as_float = [img.astype(np.float_) for img in blurred]

# Pair-wise check resolutions for mean squared error
for i, a in enumerate(as_float):
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/tools/registration/wsi_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def compute_feature_distances(
axis=len(features_x.shape),
)

feature_size_2d = np.int(np.sqrt(feature_distance.shape[0]))
feature_size_2d = np.int_(np.sqrt(feature_distance.shape[0]))
ref_feature_size_2d = factor * feature_size_2d
feature_size, ref_feature_size = feature_size_2d**2, ref_feature_size_2d**2
feature_grid = np.kron(
Expand Down
4 changes: 2 additions & 2 deletions tiatoolbox/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def dice(gt_mask, pred_mask):
if gt_mask.shape != pred_mask.shape:
raise ValueError(f'{"Shape mismatch between the two masks."}')

gt_mask = gt_mask.astype(np.bool)
pred_mask = pred_mask.astype(np.bool)
gt_mask = gt_mask.astype(np.bool_)
pred_mask = pred_mask.astype(np.bool_)
sum_masks = gt_mask.sum() + pred_mask.sum()
if sum_masks == 0:
return np.NAN
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/utils/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def imresize(img, scale_factor=None, output_size=None, interpolation="optimise")
# error). The `converted type` has been selected so that
# they can maintain the numeric precision of the `original type`.
dtype_mapping = [
(np.bool, np.uint8),
(np.bool_, np.uint8),
(np.int8, np.int16),
(np.int16, np.int16),
(np.int32, np.float32),
Expand Down
6 changes: 3 additions & 3 deletions tiatoolbox/wsicore/wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,15 +911,15 @@ def _find_tile_params(
level = np.log2(rescale)
if not level.is_integer():
raise ValueError
level = np.int(level)
level = np.int_(level)
slide_dimension = self.info.level_dimensions[level]
rescale = 1
# Raise index error if desired pyramid level not embedded
# in level_dimensions
except IndexError:
level = 0
slide_dimension = self.info.level_dimensions[level]
rescale = np.int(rescale)
rescale = np.int_(rescale)
logger.warning(
"Reading WSI at level 0. Desired tile_objective_value %s "
"not available.",
Expand Down Expand Up @@ -2508,7 +2508,7 @@ def _info(self):
box = glymur_wsi.box
description = box[3].xml.find("description")
matches = re.search(r"(?<=AppMag = )\d\d", description.text)
objective_power = np.int(matches[0])
objective_power = np.int_(matches[0])
image_header = box[2].box[0]
slide_dimensions = (image_header.width, image_header.height)

Expand Down