From 70e49b06d7838c7d902e29dc91a209ece3765bd2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:03:12 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.1...v1.11.2) - [github.com/astral-sh/ruff-pre-commit: v0.5.7 → v0.6.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.7...v0.6.8) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96a9f72a..899506b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ default_stages: minimum_pre_commit_version: 2.9.3 repos: - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy additional_dependencies: [numpy>=1.23] @@ -49,7 +49,7 @@ repos: hooks: - id: blacken-docs - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.6.8 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 633adf6e4204fbd45c7aaa03d57a5598b4a72a0d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:03:38 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- benchmarks/benchmark_qt_widget.py | 1 + docs/notebooks/mibitof_analysis.ipynb | 21 ++++++------- docs/notebooks/nanostring_analysis.ipynb | 22 ++++++------- docs/notebooks/scatterwidget.ipynb | 39 ++++++++++++------------ docs/notebooks/spatialdata.ipynb | 23 +++++++------- examples/spatialdata_visium.py | 3 +- tests/conftest.py | 3 +- tests/test_cli.py | 3 +- tests/test_interactive.py | 2 +- tests/test_scatterwidgets.py | 1 + tests/test_spatialdata.py | 9 +++--- tests/test_utils.py | 3 +- tests/test_view.py | 5 +-- tests/test_viewer.py | 9 +++--- tests/test_widgets.py | 5 +-- 15 files changed, 80 insertions(+), 69 deletions(-) diff --git a/benchmarks/benchmark_qt_widget.py b/benchmarks/benchmark_qt_widget.py index d09973db..684e23ff 100644 --- a/benchmarks/benchmark_qt_widget.py +++ b/benchmarks/benchmark_qt_widget.py @@ -2,6 +2,7 @@ from napari import Viewer from napari.layers import Image from napari.utils.events import EventedList + from napari_spatialdata._sdata_widgets import SdataWidget diff --git a/docs/notebooks/mibitof_analysis.ipynb b/docs/notebooks/mibitof_analysis.ipynb index 624faa71..d5981515 100644 --- a/docs/notebooks/mibitof_analysis.ipynb +++ b/docs/notebooks/mibitof_analysis.ipynb @@ -46,12 +46,11 @@ "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", - "from napari_spatialdata import Interactive\n", "from spatialdata import SpatialData\n", - "import squidpy as sq\n", - "import scanpy as sc\n", "\n", - "plt.rcParams['figure.figsize'] = (20, 20)" + "from napari_spatialdata import Interactive\n", + "\n", + "plt.rcParams[\"figure.figsize\"] = (20, 20)" ] }, { @@ -205,7 +204,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -254,7 +253,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -295,7 +294,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -347,7 +346,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -398,7 +397,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -439,7 +438,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -480,7 +479,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] } ], diff --git a/docs/notebooks/nanostring_analysis.ipynb b/docs/notebooks/nanostring_analysis.ipynb index 8b1ec202..3923b775 100644 --- a/docs/notebooks/nanostring_analysis.ipynb +++ b/docs/notebooks/nanostring_analysis.ipynb @@ -46,12 +46,12 @@ "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", - "from napari_spatialdata import Interactive\n", - "from spatialdata import SpatialData\n", - "import squidpy as sq\n", "import scanpy as sc\n", + "from spatialdata import SpatialData\n", + "\n", + "from napari_spatialdata import Interactive\n", "\n", - "plt.rcParams['figure.figsize'] = (20, 20)" + "plt.rcParams[\"figure.figsize\"] = (20, 20)" ] }, { @@ -278,7 +278,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -327,7 +327,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -390,7 +390,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -431,7 +431,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -483,7 +483,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -572,7 +572,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -613,7 +613,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] } ], diff --git a/docs/notebooks/scatterwidget.ipynb b/docs/notebooks/scatterwidget.ipynb index bbe8611a..d0205346 100644 --- a/docs/notebooks/scatterwidget.ipynb +++ b/docs/notebooks/scatterwidget.ipynb @@ -41,12 +41,13 @@ "cell_type": "code", "execution_count": 10, "metadata": {}, + "outputs": [], "source": [ - "from napari_spatialdata import QtAdataScatterWidget\n", + "import matplotlib.pyplot as plt\n", "import squidpy as sq\n", - "import matplotlib.pyplot as plt" - ], - "outputs": [] + "\n", + "from napari_spatialdata import QtAdataScatterWidget" + ] }, { "attachments": {}, @@ -60,10 +61,10 @@ "cell_type": "code", "execution_count": 11, "metadata": {}, + "outputs": [], "source": [ "adata = sq.datasets.visium_hne_adata()" - ], - "outputs": [] + ] }, { "attachments": {}, @@ -77,10 +78,10 @@ "cell_type": "code", "execution_count": 13, "metadata": {}, + "outputs": [], "source": [ "%gui qt5" - ], - "outputs": [] + ] }, { "attachments": {}, @@ -94,11 +95,11 @@ "cell_type": "code", "execution_count": 14, "metadata": {}, + "outputs": [], "source": [ "widget = QtAdataScatterWidget(adata)\n", "widget.show()" - ], - "outputs": [] + ] }, { "attachments": {}, @@ -112,11 +113,11 @@ "cell_type": "code", "execution_count": 15, "metadata": {}, + "outputs": [], "source": [ "plt.imshow(widget.screenshot())\n", - "plt.axis('off')" - ], - "outputs": [] + "plt.axis(\"off\")" + ] }, { "attachments": {}, @@ -130,21 +131,21 @@ "cell_type": "code", "execution_count": 19, "metadata": {}, + "outputs": [], "source": [ "plt.imshow(widget.screenshot())\n", - "plt.axis('off')" - ], - "outputs": [] + "plt.axis(\"off\")" + ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, + "outputs": [], "source": [ "plt.imshow(widget.screenshot())\n", - "plt.axis('off')" - ], - "outputs": [] + "plt.axis(\"off\")" + ] } ], "metadata": { diff --git a/docs/notebooks/spatialdata.ipynb b/docs/notebooks/spatialdata.ipynb index 540714a2..30dcbace 100644 --- a/docs/notebooks/spatialdata.ipynb +++ b/docs/notebooks/spatialdata.ipynb @@ -66,10 +66,11 @@ "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", - "from napari_spatialdata import Interactive\n", "from spatialdata import SpatialData\n", "\n", - "plt.rcParams['figure.figsize'] = (20, 20)\n", + "from napari_spatialdata import Interactive\n", + "\n", + "plt.rcParams[\"figure.figsize\"] = (20, 20)\n", "\n", "FILE_PATH = \"../../../data/cosmx/data.zarr\" # Change this\n", "sdata = SpatialData.read(FILE_PATH)" @@ -156,7 +157,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -246,7 +247,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -299,7 +300,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -358,7 +359,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -401,7 +402,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -459,7 +460,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -502,7 +503,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -543,7 +544,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] }, { @@ -584,7 +585,7 @@ ], "source": [ "plt.imshow(interactive.screenshot())\n", - "plt.axis('off')" + "plt.axis(\"off\")" ] } ], diff --git a/examples/spatialdata_visium.py b/examples/spatialdata_visium.py index 52e97db8..1b0cb6af 100644 --- a/examples/spatialdata_visium.py +++ b/examples/spatialdata_visium.py @@ -3,9 +3,10 @@ # The dataset can be downloaded from https://spatialdata.scverse.org/en/latest/tutorials/notebooks/datasets/README.html -from napari_spatialdata import Interactive from spatialdata import SpatialData +from napari_spatialdata import Interactive + if __name__ == "__main__": sdata = SpatialData.read("../data/visium/data.zarr") # Change this path! i = Interactive(sdata) diff --git a/tests/conftest.py b/tests/conftest.py index de7732de..1da8f66a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,13 +12,14 @@ from anndata import AnnData from loguru import logger from matplotlib.testing.compare import compare_images -from napari_spatialdata.utils._test_utils import save_image, take_screenshot from scipy import ndimage as ndi from skimage import data from spatialdata import SpatialData from spatialdata._types import ArrayLike from spatialdata.datasets import blobs +from napari_spatialdata.utils._test_utils import save_image, take_screenshot + HERE: Path = Path(__file__).parent SEED = 42 diff --git a/tests/test_cli.py b/tests/test_cli.py index 6f889ae5..617a122d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2,9 +2,10 @@ from click.testing import CliRunner from napari.viewer import Viewer -from napari_spatialdata.__main__ import cli from spatialdata.datasets import blobs +from napari_spatialdata.__main__ import cli + def test_view_exists(): runner = CliRunner() diff --git a/tests/test_interactive.py b/tests/test_interactive.py index 9a465d15..88ed8d18 100644 --- a/tests/test_interactive.py +++ b/tests/test_interactive.py @@ -1,7 +1,7 @@ -from napari_spatialdata._interactive import Interactive from spatialdata import SpatialData from spatialdata.models import Image2DModel +from napari_spatialdata._interactive import Interactive from tests.conftest import PlotTester, PlotTesterMeta diff --git a/tests/test_scatterwidgets.py b/tests/test_scatterwidgets.py index 1cbbff3e..0fe80652 100644 --- a/tests/test_scatterwidgets.py +++ b/tests/test_scatterwidgets.py @@ -2,6 +2,7 @@ import numpy as np import pandas as pd + from napari_spatialdata._model import DataModel from napari_spatialdata._scatterwidgets import MatplotlibWidget diff --git a/tests/test_spatialdata.py b/tests/test_spatialdata.py index ce6d5cf7..a70e18ef 100644 --- a/tests/test_spatialdata.py +++ b/tests/test_spatialdata.py @@ -12,10 +12,6 @@ from multiscale_spatial_image import to_multiscale from napari.layers import Image, Labels, Points from napari.utils.events import EventedList -from napari_spatialdata import QtAdataViewWidget -from napari_spatialdata._sdata_widgets import CoordinateSystemWidget, ElementWidget, SdataWidget -from napari_spatialdata.constants import config -from napari_spatialdata.utils._test_utils import click_list_widget_item, get_center_pos_listitem from numpy import int64 from spatialdata import SpatialData, deepcopy from spatialdata._core.query.relational_query import get_element_instances @@ -25,6 +21,11 @@ from spatialdata.transformations.operations import set_transformation from xarray import DataArray +from napari_spatialdata import QtAdataViewWidget +from napari_spatialdata._sdata_widgets import CoordinateSystemWidget, ElementWidget, SdataWidget +from napari_spatialdata.constants import config +from napari_spatialdata.utils._test_utils import click_list_widget_item, get_center_pos_listitem + RNG = np.random.default_rng(seed=0) diff --git a/tests/test_utils.py b/tests/test_utils.py index d4f16f05..428aedc5 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -4,6 +4,8 @@ import numpy as np import pytest from anndata import AnnData +from spatialdata.datasets import blobs + from napari_spatialdata.utils._utils import ( _adjust_channels_order, _get_categorical, @@ -13,7 +15,6 @@ _position_cluster_labels, _set_palette, ) -from spatialdata.datasets import blobs def test_get_categorical(adata_labels: AnnData): diff --git a/tests/test_view.py b/tests/test_view.py index 61b9f3d5..6d373d92 100644 --- a/tests/test_view.py +++ b/tests/test_view.py @@ -3,11 +3,12 @@ import numpy as np import pytest from napari.utils.events import EventedList +from spatialdata.datasets import blobs +from spatialdata.transformations import Affine, set_transformation + from napari_spatialdata._sdata_widgets import SdataWidget from napari_spatialdata._view import QtAdataViewWidget from napari_spatialdata.utils._test_utils import click_list_widget_item, get_center_pos_listitem -from spatialdata.datasets import blobs -from spatialdata.transformations import Affine, set_transformation @pytest.mark.parametrize("widget", [QtAdataViewWidget]) diff --git a/tests/test_viewer.py b/tests/test_viewer.py index d5405bc4..d66a5b7f 100644 --- a/tests/test_viewer.py +++ b/tests/test_viewer.py @@ -4,15 +4,16 @@ import numpy as np import pytest from napari.utils.events import EventedList -from napari_spatialdata import QtAdataViewWidget -from napari_spatialdata._sdata_widgets import SdataWidget -from napari_spatialdata.utils._test_utils import click_list_widget_item, get_center_pos_listitem -from napari_spatialdata.utils._utils import _get_transform from qtpy.QtCore import Qt from spatialdata.datasets import blobs from spatialdata.models import Image2DModel from spatialdata.transformations import Scale, Translation, set_transformation +from napari_spatialdata import QtAdataViewWidget +from napari_spatialdata._sdata_widgets import SdataWidget +from napari_spatialdata.utils._test_utils import click_list_widget_item, get_center_pos_listitem +from napari_spatialdata.utils._utils import _get_transform + sdata = blobs(extra_coord_system="space") diff --git a/tests/test_widgets.py b/tests/test_widgets.py index b27bb634..5c4b506f 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -7,11 +7,12 @@ from anndata.tests.helpers import assert_equal from napari.layers import Image, Labels from napari.utils.events import EventedList +from spatialdata import SpatialData +from spatialdata._types import ArrayLike + from napari_spatialdata._model import DataModel from napari_spatialdata._sdata_widgets import SdataWidget from napari_spatialdata._view import QtAdataScatterWidget, QtAdataViewWidget -from spatialdata import SpatialData -from spatialdata._types import ArrayLike # make_napari_viewer is a pytest fixture that returns a napari viewer object