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

Fix Labels object has no attribute rgb error#315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
samcunliffe merged 1 commit intomatplotlib:mainfromK-Meech:km/labels-error
Oct 30, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletionssrc/napari_matplotlib/histogram.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,15 +99,12 @@ def on_update_layers(self) -> None:
Called when the selected layers are updated.
"""
super().on_update_layers()
if self._valid_layer_selection:
if self._valid_layer_selection and self.layers:
self.layers[0].events.contrast_limits.connect(self._update_contrast_lims)

if not self.layers:
return

# Reset the num bins based on new layer data
layer_data = self._get_layer_data(self.layers[0])
self._set_widget_nums_bins(data=layer_data)
# Reset the num bins based on new layer data
layer_data = self._get_layer_data(self.layers[0])
self._set_widget_nums_bins(data=layer_data)

def _update_contrast_lims(self) -> None:
for lim, line in zip(
Expand Down
10 changes: 10 additions & 0 deletionssrc/napari_matplotlib/tests/test_histogram.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,3 +164,13 @@ def test_change_contrast(make_napari_viewer, astronaut_data):
# update contrast limits of image layer, and check no errors are thrown
image_layer = viewer.layers[0]
image_layer.contrast_limits = [2, 50]


def test_select_labels_layer(make_napari_viewer):
"""Test that no errors are thrown when the Histogram widget
is opened with a labels layer selected."""
viewer = make_napari_viewer()
viewer.add_labels(np.ones(shape=(5, 5, 5), dtype="uint8"))

widget = HistogramWidget(viewer)
viewer.window.add_dock_widget(widget)

[8]ページ先頭

©2009-2025 Movatter.jp