Skip to content

Commit

Permalink
Merge branch 'develop' into feature-extractor-example
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneahmed authored Dec 2, 2024
2 parents d22c039 + 741463c commit ad1563b
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 39 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.7.4 pytest pytest-cov pytest-runner
python -m pip install ruff==0.8.1 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.7.4
rev: v0.8.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/annotation_store.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"from typing import TYPE_CHECKING, Any\n",
"\n",
"import numpy as np\n",
"from IPython.display import display\n",
"from IPython.display import display_svg\n",
"from matplotlib import patheffects\n",
"from matplotlib import pyplot as plt\n",
"from shapely import affinity\n",
Expand Down Expand Up @@ -444,7 +444,7 @@
],
"source": [
"for n in range(4):\n",
" display(cell_polygon(xy=(0, 0), n_points=20, repeat_first=False, seed=n))"
" display_svg(cell_polygon(xy=(0, 0), n_points=20, repeat_first=False, seed=n))"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pytest>=7.2.0
pytest-cov>=4.0.0
pytest-runner>=6.0
pytest-xdist[psutil]
ruff==0.7.4 # This will be updated by pre-commit bot to latest version
ruff==0.8.1 # This will be updated by pre-commit bot to latest version
toml>=0.10.2
twine>=4.0.1
wheel>=0.37.1
2 changes: 1 addition & 1 deletion tiatoolbox/annotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
SQLiteStore,
)

__all__ = ["AnnotationStore", "SQLiteStore", "DictionaryStore", "Annotation"]
__all__ = ["Annotation", "AnnotationStore", "DictionaryStore", "SQLiteStore"]
10 changes: 6 additions & 4 deletions tiatoolbox/annotation/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,11 +1371,13 @@ def bquery(
for key, annotation in self.items()
if (
query_geometry is None
or isinstance(query_geometry, (Polygon, Point, LineString))
and Polygon.from_bounds(*annotation.geometry.bounds).intersects(
Polygon.from_bounds(*query_geometry.bounds),
or (
isinstance(query_geometry, (Polygon, Point, LineString))
and Polygon.from_bounds(*annotation.geometry.bounds).intersects(
Polygon.from_bounds(*query_geometry.bounds),
)
and self._eval_where(where, annotation.properties)
)
and self._eval_where(where, annotation.properties)
)
}

Expand Down
4 changes: 2 additions & 2 deletions tiatoolbox/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
)

__all__ = [
"SCCNN",
"HoVerNet",
"HoVerNetPlus",
"IDaRS",
"MapDe",
"MicroNet",
"NuClick",
"SCCNN",
"MultiTaskSegmentor",
"NuClick",
"NucleusInstanceSegmentor",
"PatchPredictor",
"SemanticSegmentor",
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/models/architecture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from tiatoolbox.models.models_abc import IOConfigABC


__all__ = ["get_pretrained_model", "fetch_pretrained_weights"]
__all__ = ["fetch_pretrained_weights", "get_pretrained_model"]
PRETRAINED_INFO = rcParam["pretrained_model_info"]


Expand Down
4 changes: 2 additions & 2 deletions tiatoolbox/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
)

__all__ = [
"download_data",
"imread",
"imwrite",
"save_yaml",
"save_as_json",
"download_data",
"save_yaml",
"unzip_data",
]
21 changes: 11 additions & 10 deletions tiatoolbox/utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,26 +914,27 @@ def _set_mapper(

def __setattr__(
self: AnnotationRenderer,
__name: str,
__value: str | list | dict | None,
name: str,
value: str | list | dict | None,
/,
) -> None:
"""Set attribute each time an attribute is set."""
if __name == "mapper":
if name == "mapper":
# save a more readable version of the mapper too
_ = self._set_mapper(__value)
_ = self._set_mapper(value)
return
if __name == "blur_radius" and isinstance(__value, int):
if name == "blur_radius" and isinstance(value, int):
# need to change additional settings
if __value > 0:
self.__dict__["blur"] = ImageFilter.GaussianBlur(__value)
if value > 0:
self.__dict__["blur"] = ImageFilter.GaussianBlur(value)
self.__dict__["edge_thickness"] = 0
else:
self.__dict__["blur"] = None
self.__dict__["edge_thickness"] = self.__dict__["edge_thickness_old"]
elif __name == "edge_thickness":
self.__dict__["edge_thickness_old"] = __value
elif name == "edge_thickness":
self.__dict__["edge_thickness_old"] = value

self.__dict__[__name] = __value
self.__dict__[name] = value

def render_annotations(
self: AnnotationRenderer,
Expand Down
25 changes: 12 additions & 13 deletions tiatoolbox/visualization/bokeh_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,8 @@ def get_mapper_for_prop(prop: str, mapper_type: str = "auto") -> str | dict[str,
prop_vals = json.loads(resp.text)
# If auto, guess what cmap should be
if (
(len(prop_vals) > MAX_CAT or len(prop_vals) == 0)
and mapper_type == "auto"
or mapper_type == "continuous"
):
(len(prop_vals) > MAX_CAT or len(prop_vals) == 0) and mapper_type == "auto"
) or mapper_type == "continuous":
cmap = (
"viridis" if UI["cmap_select"].value == "dict" else UI["cmap_select"].value
)
Expand Down Expand Up @@ -647,24 +645,25 @@ def __init__(self: ViewerState, slide_path: str | Path) -> None:

def __setattr__(
self: ViewerState,
__name: str,
__value: Any, # noqa: ANN401
name: str,
value: Any, # noqa: ANN401
/,
) -> None:
"""Set an attribute of the viewer state."""
if __name == "types":
self.__dict__["mapper"] = make_color_dict(__value)
if name == "types":
self.__dict__["mapper"] = make_color_dict(value)
self.__dict__["colors"] = list(self.mapper.values())
if self.cprop == "type":
update_mapper()
# We will standardise the types to strings, keep dict of originals
self.__dict__["orig_types"] = {str(x): x for x in __value}
__value = [str(x) for x in __value]
self.__dict__["orig_types"] = {str(x): x for x in value}
value = [str(x) for x in value]

if __name == "wsi":
z = ZoomifyGenerator(__value, tile_size=256)
if name == "wsi":
z = ZoomifyGenerator(value, tile_size=256)
self.__dict__["num_zoom_levels"] = z.level_count

self.__dict__[__name] = __value
self.__dict__[name] = value


# endregion
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/wsicore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

# Top level imports
__all__ = [
"WSIReader",
"WSIMeta",
"WSIReader",
]

0 comments on commit ad1563b

Please sign in to comment.