Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit208af97

Browse files
authored
Merge branch 'main' into feat/hist-bin-params
2 parents67a8641 +0501fab commit208af97

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

‎.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ repos:
1717
-id:napari-plugin-checks
1818

1919
-repo:https://github.com/pre-commit/mirrors-mypy
20-
rev:v1.10.0
20+
rev:v1.10.1
2121
hooks:
2222
-id:mypy
2323
additional_dependencies:[numpy, matplotlib]
2424

2525
-repo:https://github.com/astral-sh/ruff-pre-commit
2626
# Ruff version.
27-
rev:'v0.4.2'
27+
rev:'v0.5.1'
2828
hooks:
2929
-id:ruff
3030

‎docs/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
Changelog
22
=========
3+
4+
2.0.3
5+
-----
6+
Bug fixes
7+
~~~~~~~~~
8+
- Fix an error that happened when the histogram widget was open, but a layer that doesn't support
9+
histogramming (e.g., a labels layer) was selected.
10+
311
2.0.2
412
-----
513
Dependencies
614
~~~~~~~~~~~~
715
napari-matplotlib now adheres to `SPEC 0<https://scientific-python.org/specs/spec-0000/>`_, and has:
16+
817
- Dropped support for Python 3.9
918
- Added support for Python 3.12
1019
- Added a minimum required numpy verison of 1.23
20+
- Pinned the maximum napari version to ``< 0.5``.
21+
Version 3.0 of ``napari-matplotlib`` will introduce support for ``napari`` version 0.5.
1122

1223
2.0.1
1324
-----

‎setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ project_urls =
2828
packages = find:
2929
install_requires =
3030
matplotlib
31-
napari
31+
napari<0.5
3232
numpy>=1.23
3333
tinycss2
3434
python_requires = >=3.10

‎src/napari_matplotlib/base.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,24 @@ def _setup_callbacks(self) -> None:
224224
self._update_layers
225225
)
226226

227+
@property
228+
def_valid_layer_selection(self)->bool:
229+
"""
230+
Return `True` if layer selection is valid.
231+
"""
232+
returnself.n_selected_layersinself.n_layers_inputandall(
233+
isinstance(layer,self.input_layer_types)forlayerinself.layers
234+
)
235+
227236
def_update_layers(self,event:napari.utils.events.Event)->None:
228237
"""
229238
Update the ``layers`` attribute with currently selected layers and re-draw.
230239
"""
231240
self.layers=list(self.viewer.layers.selection)
232241
self.layers=sorted(self.layers,key=lambdalayer:layer.name)
233242
self.on_update_layers()
234-
self._draw()
243+
ifself._valid_layer_selection:
244+
self._draw()
235245

236246
def_draw(self)->None:
237247
"""
@@ -243,10 +253,7 @@ def _draw(self) -> None:
243253
withmplstyle.context(self.napari_theme_style_sheet):
244254
# everything should be done in the style context
245255
self.clear()
246-
ifself.n_selected_layersinself.n_layers_inputandall(
247-
isinstance(layer,self.input_layer_types)
248-
forlayerinself.layers
249-
):
256+
ifself._valid_layer_selection:
250257
self.draw()
251258
self.canvas.draw()# type: ignore[no-untyped-call]
252259

‎src/napari_matplotlib/histogram.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ def on_update_layers(self) -> None:
9999
Called when the selected layers are updated.
100100
"""
101101
super().on_update_layers()
102-
forlayerinself.viewer.layers:
103-
layer.events.contrast_limits.connect(self._update_contrast_lims)
102+
ifself._valid_layer_selection:
103+
self.layers[0].events.contrast_limits.connect(
104+
self._update_contrast_lims
105+
)
104106

105107
ifnotself.layers:
106108
return
@@ -274,10 +276,12 @@ def draw(self) -> None:
274276
# get the colormap from the layer depending on its type
275277
ifisinstance(self.layers[0],napari.layers.Points):
276278
colormap=self.layers[0].face_colormap
277-
self.layers[0].face_color=self.x_axis_key
279+
ifself.x_axis_key:
280+
self.layers[0].face_color=self.x_axis_key
278281
elifisinstance(self.layers[0],napari.layers.Vectors):
279282
colormap=self.layers[0].edge_colormap
280-
self.layers[0].edge_color=self.x_axis_key
283+
ifself.x_axis_key:
284+
self.layers[0].edge_color=self.x_axis_key
281285
else:
282286
colormap=None
283287

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp