diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 999b445b8..59dbe158a 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -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 diff --git a/tests/models/test_patch_predictor.py b/tests/models/test_patch_predictor.py index bc8cc33c4..f79e8a031 100644 --- a/tests/models/test_patch_predictor.py +++ b/tests/models/test_patch_predictor.py @@ -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) diff --git a/tests/test_utils.py b/tests/test_utils.py index cf8119053..63601df88 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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), @@ -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) diff --git a/tests/test_wsireader.py b/tests/test_wsireader.py index 341d72f0b..0a4ec0443 100644 --- a/tests/test_wsireader.py +++ b/tests/test_wsireader.py @@ -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): @@ -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): diff --git a/tiatoolbox/tools/registration/wsi_registration.py b/tiatoolbox/tools/registration/wsi_registration.py index 54fb48f1a..73d99f654 100644 --- a/tiatoolbox/tools/registration/wsi_registration.py +++ b/tiatoolbox/tools/registration/wsi_registration.py @@ -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( diff --git a/tiatoolbox/utils/metrics.py b/tiatoolbox/utils/metrics.py index 900d79e10..f6a632458 100644 --- a/tiatoolbox/utils/metrics.py +++ b/tiatoolbox/utils/metrics.py @@ -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 diff --git a/tiatoolbox/utils/transforms.py b/tiatoolbox/utils/transforms.py index dc5ca896f..7b215e1c0 100644 --- a/tiatoolbox/utils/transforms.py +++ b/tiatoolbox/utils/transforms.py @@ -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), diff --git a/tiatoolbox/wsicore/wsireader.py b/tiatoolbox/wsicore/wsireader.py index 8329ef04f..489df37ca 100644 --- a/tiatoolbox/wsicore/wsireader.py +++ b/tiatoolbox/wsicore/wsireader.py @@ -911,7 +911,7 @@ 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 @@ -919,7 +919,7 @@ def _find_tile_params( 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.", @@ -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)