Skip to content

Commit

Permalink
Merge branch 'dev-define-engines-abc' into dev-define-patchpredictor
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneahmed authored Jul 17, 2024
2 parents 936eda7 + f85c6a6 commit 0b25bec
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
sudo apt update
sudo apt-get install -y libopenslide-dev openslide-tools libopenjp2-7 libopenjp2-tools
python -m pip install --upgrade pip
python -m pip install ruff==0.5.1 pytest pytest-cov pytest-runner
python -m pip install ruff==0.5.2 pytest pytest-cov pytest-runner
pip install -r requirements/requirements.txt
- name: Cache tiatoolbox static assets
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repos:
- id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.1
rev: v0.5.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pytest>=7.2.0
pytest-cov>=4.0.0
pytest-runner>=6.0
pytest-xdist[psutil]
ruff==0.5.1 # This will be updated by pre-commit bot to latest version
ruff==0.5.2 # This will be updated by pre-commit bot to latest version
toml>=0.10.2
twine>=4.0.1
wheel>=0.37.1
16 changes: 8 additions & 8 deletions tiatoolbox/tools/registration/wsi_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class DFBRFeatureExtractor(torch.nn.Module):
"""

def __init__(self: torch.nn.Module) -> None:
def __init__(self: DFBRFeatureExtractor) -> None:
"""Initialize :class:`DFBRFeatureExtractor`."""
super().__init__()
output_layers_id: list[str] = ["16", "23", "30"]
Expand Down Expand Up @@ -434,8 +434,8 @@ class DFBRegister:
def __init__(self: DFBRegister, patch_size: tuple[int, int] = (224, 224)) -> None:
"""Initialize :class:`DFBRegister`."""
self.patch_size = patch_size
self.x_scale: list[float] = []
self.y_scale: list[float] = []
self.x_scale: np.ndarray
self.y_scale: np.ndarray
self.feature_extractor = DFBRFeatureExtractor()

# Make this function private when full pipeline is implemented.
Expand Down Expand Up @@ -796,7 +796,7 @@ def find_points_inside_boundary(mask: np.ndarray, points: np.ndarray) -> np.ndar
return PatchExtractor.filter_coordinates(
mask_reader,
bbox_coord,
mask.shape[::-1],
(mask.shape[1], mask.shape[0]),
)

def filtering_matching_points(
Expand Down Expand Up @@ -1521,21 +1521,21 @@ def get_patch_dimensions(
"""
width, height = size[0], size[1]

x = [
x_info = [
np.linspace(1, width, width, endpoint=True),
np.ones(height) * width,
np.linspace(1, width, width, endpoint=True),
np.ones(height),
]
x = np.array(list(itertools.chain.from_iterable(x)))
x = np.array(list(itertools.chain.from_iterable(x_info)))

y = [
y_info = [
np.ones(width),
np.linspace(1, height, height, endpoint=True),
np.ones(width) * height,
np.linspace(1, height, height, endpoint=True),
]
y = np.array(list(itertools.chain.from_iterable(y)))
y = np.array(list(itertools.chain.from_iterable(y_info)))

points = np.array([x, y]).transpose()
transform = transform * [[1, 1, 0], [1, 1, 0], [1, 1, 1]] # remove translation
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ def dice(gt_mask: np.ndarray, pred_mask: np.ndarray) -> float:
pred_mask = pred_mask.astype(np.bool_)
sum_masks = gt_mask.sum() + pred_mask.sum()
if sum_masks == 0:
return np.NAN
return np.nan
return 2 * np.logical_and(gt_mask, pred_mask).sum() / sum_masks

0 comments on commit 0b25bec

Please sign in to comment.