Skip to content

Commit 0429cf1

Browse files
authored
Update napari to 0.6.2 and add bermuda (#368)
* simplify conditional * bump version, change to ctrl+l * add bermuda * add blog post * correct doc reference * use export_figure * remove argument * match type hint * verify path * update artefact path * revert viewer theme change * check readthedocs with pydanticv2 * constrain dask * constrain dask * attempt fix mac * add warning * change caplog index * change access of deprecated _dock_widgets access
1 parent aea2eb5 commit 0429cf1

File tree

12 files changed

+35
-20
lines changed

12 files changed

+35
-20
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
uses: actions/upload-artifact@v4
7070
with:
7171
name: plotting-results-${{ matrix.python-version }}-${{ matrix.platform }}
72-
path: /home/runner/work/napari-spatialdata/napari-spatialdata/tests/plots/*
72+
path: /Users/runner/work/napari-spatialdata/napari-spatialdata/tests/plots/generated/*
7373

7474
test_benchmarks:
7575
name: test benchmarks

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
[link-pypi]: https://pypi.org/project/napari-spatialdata/
1818

1919
This repository contains a napari plugin for interactively exploring and annotating
20-
SpatialData objects. Here you can find the [napari-spatialdata documentation]
21-
(https://spatialdata.scverse.org/projects/napari/en/stable/notebooks/spatialdata.html). `napari-spatialdata` is part of the `SpatialData` ecosystem. To learn more about SpatialData, please see the [spatialdata documentation](https://spatialdata.scverse.org/).
20+
SpatialData objects. Here you can find the [napari-spatialdata documentation](https://spatialdata.scverse.org/projects/napari/en/stable/notebooks/spatialdata.html). `napari-spatialdata` is part of the `SpatialData` ecosystem. To learn more about SpatialData, please see the [spatialdata documentation](https://spatialdata.scverse.org/).
2221

2322
## Installation
2423

@@ -28,6 +27,13 @@ You can install `napari-spatialdata` via [pip]:
2827

2928
The `all` command will install the qt bindings `PyQt5`.
3029

30+
Napari now also includes multiple triangulation backends. These improve the speed by which a napari 'Shapes' layer gets
31+
loaded (this does not improve the speed of editing large numbers of shapes yet!). See also the napari
32+
[documentation](https://napari.org/stable/guides/triangulation.html) and already slightly older [blog post](https://napari.org/island-dispatch/blog/triangles_speedup_beta.html). For installation via
33+
pip:
34+
35+
pip install napari-spatialdata[all, bermuda]
36+
3137
You can find more details on this in the [installation instructions](https://spatialdata.scverse.org/en/stable/installation.html).
3238

3339
## Using napari-spatialdata as default zarr reader

setup.cfg

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ install_requires =
3737
anndata
3838
click
3939
cycler
40-
dask>=2024.4.1
40+
dask>=2024.4.1,<=2024.11.2
4141
geopandas
4242
loguru
4343
matplotlib
44-
napari>=0.4.19.post1,<0.5.6
44+
napari>=0.6.2
4545
napari-matplotlib
4646
numba
4747
numpy
@@ -66,6 +66,9 @@ package_dir =
6666

6767

6868
[options.extras_require]
69+
bermuda =
70+
bermuda
71+
6972
test =
7073
loguru
7174
pytest
@@ -92,7 +95,7 @@ doc =
9295
squidpy
9396

9497
readthedocs =
95-
pydantic<2
98+
pydantic>2
9699

97100
# this is just to trigger pip to check for pre-releases as well
98101
pre =

src/napari_spatialdata/_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def __init__(self, napari_viewer: Viewer, model: DataModel | None = None) -> Non
426426
super().__init__()
427427

428428
self._viewer = napari_viewer
429-
self._model = model if model else napari_viewer.window._dock_widgets["SpatialData"].widget().viewer_model._model
429+
self._model = model if model else napari_viewer.window.dock_widgets["SpatialData"].viewer_model.model
430430

431431
self._select_layer()
432432
self._viewer.layers.selection.events.changed.connect(self._select_layer)

src/napari_spatialdata/_viewer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def __init__(self, viewer: Viewer, sdata: EventedList) -> None:
5252
self.sdata = sdata
5353
self._model = DataModel()
5454
self._layer_event_caches: dict[str, list[dict[str, Any]]] = {}
55+
self.viewer.bind_key("Ctrl-L", self._inherit_metadata, overwrite=True)
56+
57+
logger.warning(
58+
"Due to Shift-L being used as shortcut in napari, it is being deprecated and might not link a new layer"
59+
" to an existing SpatialData object in the viewer. Please use ⌘-L on MacOS or else Ctrl-L.",
60+
)
5561
self.viewer.bind_key("Shift-L", self._inherit_metadata, overwrite=True)
5662
self.viewer.bind_key("Shift-E", self._save_to_sdata, overwrite=True)
5763
self.viewer.layers.events.inserted.connect(self._on_layer_insert)

src/napari_spatialdata/utils/_test_utils.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,22 @@ def click_list_widget_item(
7171
raise ValueError(f"{click} is not a valid click")
7272

7373

74-
def take_screenshot(viewer: napari.Viewer, canvas_only: bool = False) -> ArrayLike | Any:
75-
"""Take screenshot of the Napari viewer.
74+
def export_figure(viewer: napari.Viewer) -> ArrayLike | Any:
75+
"""Export figure from the data displayed in the Napari viewer.
7676
7777
Parameters
7878
----------
7979
viewer
8080
Instance of napari Viewer.
81-
canvas_only
82-
If True, only the canvas is saved, not the viewer window.
8381
8482
Returns
8583
-------
86-
The screenshot as an array.
84+
The exported figure as an array.
8785
"""
88-
logger.info("Taking screenshot of viewer")
89-
# to distinguish between the black of the image background and the black of the napari background (now white)
90-
# TODO (melonora): remove when napari allows for getting rid of margins.
86+
logger.info("Export figure of data in viewer canvas")
9187
old_theme = viewer.theme
9288
viewer.theme = "light"
93-
interactive_screenshot = viewer.screenshot(canvas_only=canvas_only, size=(202, 284))
89+
interactive_screenshot = viewer.export_figure()
9490
viewer.theme = old_theme
9591
viewer.close()
9692

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from spatialdata.datasets import blobs
2323
from spatialdata.models import TableModel
2424

25-
from napari_spatialdata.utils._test_utils import save_image, take_screenshot
25+
from napari_spatialdata.utils._test_utils import export_figure, save_image
2626

2727
HERE: Path = Path(__file__).parent
2828

@@ -214,7 +214,7 @@ def compare(cls, basename: str, tolerance: float | None = None):
214214
out_path = ACTUAL / f"{basename}.png"
215215

216216
viewer = napari.current_viewer()
217-
save_image(take_screenshot(viewer, canvas_only=True), out_path)
217+
save_image(export_figure(viewer), str(out_path))
218218

219219
if tolerance is None:
220220
# see https://github.com/theislab/squidpy/pull/302
169 KB
Loading
5.78 KB
Loading
154 KB
Loading

0 commit comments

Comments
 (0)