From 70db1863028226f603dc08f33d2e3e96c915c27c Mon Sep 17 00:00:00 2001 From: Mostafa Jahanifar <74412979+mostafajahanifar@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:46:28 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Immutable=20Output=20f?= =?UTF-8?q?rom=20`WSIReader`=20(#850)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Resolve issue #837 The output of WSI readers (read_rect, read_region, etc) are immutable, i.e. Read-only. We assume that created Numpy arrays created from PIL images in the `background_composite` are mutable by default. After Numpy v1.16.0, doing np.asarray(pil_image) will return an immutable Numpy array. Gladly, there is an easy fix for this, we should use `np.array()` instead of `np.asarray`. --- tiatoolbox/utils/transforms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiatoolbox/utils/transforms.py b/tiatoolbox/utils/transforms.py index adb769df9..8fd096b32 100644 --- a/tiatoolbox/utils/transforms.py +++ b/tiatoolbox/utils/transforms.py @@ -53,9 +53,9 @@ def background_composite( ) composite.alpha_composite(image) if not alpha: - return np.asarray(composite.convert("RGB")) + return np.array(composite.convert("RGB")) - return np.asarray(composite) + return np.array(composite) def _convert_scalar_to_width_height(array: np.ndarray) -> np.ndarray: From 015652cc5c2357070592c8d46f5f2ff9a905a5c6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 13:36:31 +0100 Subject: [PATCH 2/2] [pre-commit.ci] pre-commit autoupdate (#851) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * :pushpin: Update `ruff` version. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com> --- .github/workflows/python-package.yml | 2 +- .pre-commit-config.yaml | 2 +- requirements/requirements_dev.txt | 2 +- tiatoolbox/visualization/bokeh_app/main.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 688840262..559779617 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -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.6.1 pytest pytest-cov pytest-runner + python -m pip install ruff==0.6.2 pytest pytest-cov pytest-runner pip install -r requirements/requirements.txt - name: Cache tiatoolbox static assets uses: actions/cache@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67256a495..5c608239e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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.6.1 + rev: v0.6.2 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index 111fe7e84..a8392667e 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -11,7 +11,7 @@ pytest>=7.2.0 pytest-cov>=4.0.0 pytest-runner>=6.0 pytest-xdist[psutil] -ruff==0.6.1 # This will be updated by pre-commit bot to latest version +ruff==0.6.2 # This will be updated by pre-commit bot to latest version toml>=0.10.2 twine>=4.0.1 wheel>=0.37.1 diff --git a/tiatoolbox/visualization/bokeh_app/main.py b/tiatoolbox/visualization/bokeh_app/main.py index e86168506..6f9aff33d 100644 --- a/tiatoolbox/visualization/bokeh_app/main.py +++ b/tiatoolbox/visualization/bokeh_app/main.py @@ -689,7 +689,7 @@ def slide_toggle_cb(attr: str) -> None: # noqa: ARG001 UI["p"].renderers[0].alpha = 0.0 -def node_select_cb(attr: str, old: int, new: int) -> None: # noqa: ARG001 +def node_select_cb(attr: str, old: int, new: int) -> None: """Placeholder callback to do something on node selection.""" # Do something on node select if desired