Skip to content

Commit 9a6f33a

Browse files
committed
Add test for histogram widget when setting bin parameters
1 parent cf5b17f commit 9a6f33a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Loading

src/napari_matplotlib/tests/test_histogram.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
assert_figures_not_equal,
1010
)
1111

12+
@pytest.mark.mpl_image_compare
13+
def test_histogram_2D_bins(make_napari_viewer, astronaut_data):
14+
viewer = make_napari_viewer()
15+
viewer.theme = "light"
16+
viewer.add_image(astronaut_data[0], **astronaut_data[1])
17+
widget = HistogramWidget(viewer)
18+
viewer.window.add_dock_widget(widget)
19+
widget.bins_start = -50
20+
widget.bins_stop = 300
21+
widget.bins_num = 35
22+
fig = widget.figure
23+
# Need to return a copy, as original figure is too eagerley garbage
24+
# collected by the widget
25+
return deepcopy(fig)
1226

1327
@pytest.mark.mpl_image_compare
1428
def test_histogram_2D(make_napari_viewer, astronaut_data):
@@ -20,7 +34,6 @@ def test_histogram_2D(make_napari_viewer, astronaut_data):
2034
# collected by the widget
2135
return deepcopy(fig)
2236

23-
2437
@pytest.mark.mpl_image_compare
2538
def test_histogram_3D(make_napari_viewer, brain_data):
2639
viewer = make_napari_viewer()

0 commit comments

Comments
 (0)