File tree 5 files changed +34
-12
lines changed
5 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,14 @@ repos:
17
17
- id : napari-plugin-checks
18
18
19
19
- repo : https://github.com/pre-commit/mirrors-mypy
20
- rev : v1.10.0
20
+ rev : v1.10.1
21
21
hooks :
22
22
- id : mypy
23
23
additional_dependencies : [numpy, matplotlib]
24
24
25
25
- repo : https://github.com/astral-sh/ruff-pre-commit
26
26
# Ruff version.
27
- rev : ' v0.4.2 '
27
+ rev : ' v0.5.1 '
28
28
hooks :
29
29
- id : ruff
30
30
Original file line number Diff line number Diff line change 1
1
Changelog
2
2
=========
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
+
3
11
2.0.2
4
12
-----
5
13
Dependencies
6
14
~~~~~~~~~~~~
7
15
napari-matplotlib now adheres to `SPEC 0 <https://scientific-python.org/specs/spec-0000/ >`_, and has:
16
+
8
17
- Dropped support for Python 3.9
9
18
- Added support for Python 3.12
10
19
- 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.
11
22
12
23
2.0.1
13
24
-----
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ project_urls =
28
28
packages = find:
29
29
install_requires =
30
30
matplotlib
31
- napari
31
+ napari<0.5
32
32
numpy>=1.23
33
33
tinycss2
34
34
python_requires = >=3.10
Original file line number Diff line number Diff line change @@ -224,14 +224,24 @@ def _setup_callbacks(self) -> None:
224
224
self ._update_layers
225
225
)
226
226
227
+ @property
228
+ def _valid_layer_selection (self ) -> bool :
229
+ """
230
+ Return `True` if layer selection is valid.
231
+ """
232
+ return self .n_selected_layers in self .n_layers_input and all (
233
+ isinstance (layer , self .input_layer_types ) for layer in self .layers
234
+ )
235
+
227
236
def _update_layers (self , event : napari .utils .events .Event ) -> None :
228
237
"""
229
238
Update the ``layers`` attribute with currently selected layers and re-draw.
230
239
"""
231
240
self .layers = list (self .viewer .layers .selection )
232
241
self .layers = sorted (self .layers , key = lambda layer : layer .name )
233
242
self .on_update_layers ()
234
- self ._draw ()
243
+ if self ._valid_layer_selection :
244
+ self ._draw ()
235
245
236
246
def _draw (self ) -> None :
237
247
"""
@@ -243,10 +253,7 @@ def _draw(self) -> None:
243
253
with mplstyle .context (self .napari_theme_style_sheet ):
244
254
# everything should be done in the style context
245
255
self .clear ()
246
- if self .n_selected_layers in self .n_layers_input and all (
247
- isinstance (layer , self .input_layer_types )
248
- for layer in self .layers
249
- ):
256
+ if self ._valid_layer_selection :
250
257
self .draw ()
251
258
self .canvas .draw () # type: ignore[no-untyped-call]
252
259
Original file line number Diff line number Diff line change @@ -99,8 +99,10 @@ def on_update_layers(self) -> None:
99
99
Called when the selected layers are updated.
100
100
"""
101
101
super ().on_update_layers ()
102
- for layer in self .viewer .layers :
103
- layer .events .contrast_limits .connect (self ._update_contrast_lims )
102
+ if self ._valid_layer_selection :
103
+ self .layers [0 ].events .contrast_limits .connect (
104
+ self ._update_contrast_lims
105
+ )
104
106
105
107
if not self .layers :
106
108
return
@@ -274,10 +276,12 @@ def draw(self) -> None:
274
276
# get the colormap from the layer depending on its type
275
277
if isinstance (self .layers [0 ], napari .layers .Points ):
276
278
colormap = self .layers [0 ].face_colormap
277
- self .layers [0 ].face_color = self .x_axis_key
279
+ if self .x_axis_key :
280
+ self .layers [0 ].face_color = self .x_axis_key
278
281
elif isinstance (self .layers [0 ], napari .layers .Vectors ):
279
282
colormap = self .layers [0 ].edge_colormap
280
- self .layers [0 ].edge_color = self .x_axis_key
283
+ if self .x_axis_key :
284
+ self .layers [0 ].edge_color = self .x_axis_key
281
285
else :
282
286
colormap = None
283
287
You can’t perform that action at this time.
0 commit comments