Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
pre-commit-ci[bot] committed Feb 19, 2024
1 parent bd0a223 commit 05165ef
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tiatoolbox/utils/misc.py
Original file line number Diff line number Diff line change
@@ -983,7 +983,7 @@ def select_cv2_interpolation(scale_factor: float | npt.NDArray[np.float64]) -> s
interpolation type
"""
if np.any(scale_factor > 1.0): # noqa: PLR2004
if np.any(scale_factor > 1.0):
return "cubic"
return "area"

2 changes: 1 addition & 1 deletion tiatoolbox/utils/transforms.py
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ def imresize(
scale_factor_array = img.shape[:2][::-1] / np.array(output_size_array)

# Return original if scale factor is 1
if np.all(scale_factor_array == 1.0): # noqa: PLR2004
if np.all(scale_factor_array == 1.0):
return img

# Get appropriate cv2 interpolation enum
14 changes: 7 additions & 7 deletions tiatoolbox/utils/visualization.py
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ def overlay_prediction_mask(
msg,
)
if np.issubdtype(img.dtype, np.floating):
if not (img.max() <= 1.0 and img.min() >= 0): # noqa: PLR2004
if not (img.max() <= 1.0 and img.min() >= 0):
msg = "Not support float `img` outside [0, 1]."
raise ValueError(msg)
img = np.array(img * 255, dtype=np.uint8)
@@ -157,7 +157,7 @@ def overlay_prediction_mask(
cv2.addWeighted(rgb_prediction, alpha, overlay, 1 - alpha, 0, overlay)
overlay = overlay.astype(np.uint8)

if min_val > 0.0: # noqa: PLR2004
if min_val > 0.0:
overlay[~prediction_sel] = img[~prediction_sel]

if ax is None and not return_ax:
@@ -310,7 +310,7 @@ def overlay_probability_map(
overlay[overlay > 255.0] = 255.0 # noqa: PLR2004
overlay = overlay.astype(np.uint8)

if min_val > 0.0: # noqa: PLR2004
if min_val > 0.0:
overlay[~prediction_sel] = img[~prediction_sel]

if ax is None and not return_ax:
@@ -374,23 +374,23 @@ def _validate_overlay_probability_map(
msg,
)

if prediction.max() > 1.0: # noqa: PLR2004
if prediction.max() > 1.0:
msg = "Not support float `prediction` outside [0, 1]."
raise ValueError(msg)
if prediction.min() < 0:
msg = "Not support float `prediction` outside [0, 1]."
raise ValueError(msg)

# if `min_val` is defined, only display the overlay for areas with prob > min_val
if min_val < 0.0: # noqa: PLR2004
if min_val < 0.0:
msg = f"`min_val={min_val}` is not between [0, 1]."
raise ValueError(msg)
if min_val > 1.0: # noqa: PLR2004
if min_val > 1.0:
msg = f"`min_val={min_val}` is not between [0, 1]."
raise ValueError(msg)

if np.issubdtype(img.dtype, np.floating):
if img.max() > 1.0: # noqa: PLR2004
if img.max() > 1.0:
msg = "Not support float `img` outside [0, 1]."
raise ValueError(msg)
if img.min() < 0:
4 changes: 2 additions & 2 deletions tiatoolbox/wsicore/wsireader.py
Original file line number Diff line number Diff line change
@@ -5519,7 +5519,7 @@ def read_rect(
utils.transforms.background_composite(base_region, alpha=True),
)
im_region = Image.fromarray(im_region)
if self.alpha < 1.0: # noqa: PLR2004
if self.alpha < 1.0:
im_region.putalpha(
im_region.getchannel("A").point(lambda i: i * self.alpha),
)
@@ -5712,7 +5712,7 @@ class docstrings for more information.
utils.transforms.background_composite(base_region, alpha=True),
)
im_region = Image.fromarray(im_region)
if self.alpha < 1.0: # noqa: PLR2004
if self.alpha < 1.0:
im_region.putalpha(
im_region.getchannel("A").point(lambda i: i * self.alpha),
)

0 comments on commit 05165ef

Please sign in to comment.