Skip to content

Commit

Permalink
Merge branch 'develop' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneahmed authored Dec 2, 2024
2 parents 95140ca + 741463c commit 975d46b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 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
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
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
19 changes: 10 additions & 9 deletions tiatoolbox/visualization/bokeh_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,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

0 comments on commit 975d46b

Please sign in to comment.