Skip to content

3D scatter test #152

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 2, 2023
Merged
Binary file modified src/napari_matplotlib/tests/baseline/test_histogram_3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/napari_matplotlib/tests/baseline/test_slice_3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/napari_matplotlib/tests/scatter/test_scatter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from copy import deepcopy

import pytest
from numpy import array

from napari_matplotlib import ScatterWidget

Expand All @@ -23,3 +24,27 @@ def test_scatter_2D(make_napari_viewer, astronaut_data):
viewer.layers.selection.add(viewer.layers[0])
viewer.layers.selection.add(viewer.layers[1])
return deepcopy(fig)


@pytest.mark.mpl_image_compare
def test_scatter_3D(make_napari_viewer, brain_data):
viewer = make_napari_viewer()
widget = ScatterWidget(viewer)
fig = widget.figure

viewer.add_image(brain_data[0], **brain_data[1], name="brain")

viewer.add_image(
brain_data[0] * -1, **brain_data[1], name="brain_reversed"
)
# De-select existing selection
viewer.layers.selection.clear()
# pdb.set_trace()
axis = viewer.dims.last_used
slice_no = array(brain_data[0]).shape[0] - 1
viewer.dims.set_current_step(axis, slice_no)
# Select images
viewer.layers.selection.add(viewer.layers[0])
viewer.layers.selection.add(viewer.layers[1])

return deepcopy(fig)
4 changes: 4 additions & 0 deletions src/napari_matplotlib/tests/test_histogram.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from copy import deepcopy

import pytest
from numpy import array

from napari_matplotlib import HistogramWidget
from napari_matplotlib.tests.helpers import (
Expand All @@ -23,6 +24,9 @@ def test_histogram_2D(make_napari_viewer, astronaut_data):
def test_histogram_3D(make_napari_viewer, brain_data):
viewer = make_napari_viewer()
viewer.add_image(brain_data[0], **brain_data[1])
axis = viewer.dims.last_used
slice_no = array(brain_data[0]).shape[0] - 1
viewer.dims.set_current_step(axis, slice_no)
fig = HistogramWidget(viewer).figure
# Need to return a copy, as original figure is too eagerley garbage
# collected by the widget
Expand Down
4 changes: 4 additions & 0 deletions src/napari_matplotlib/tests/test_slice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from copy import deepcopy

import pytest
from numpy import array

from napari_matplotlib import SliceWidget

Expand All @@ -9,6 +10,9 @@
def test_slice_3D(make_napari_viewer, brain_data):
viewer = make_napari_viewer()
viewer.add_image(brain_data[0], **brain_data[1])
axis = viewer.dims.last_used
slice_no = array(brain_data[0]).shape[0] - 1
viewer.dims.set_current_step(axis, slice_no)
fig = SliceWidget(viewer).figure
# Need to return a copy, as original figure is too eagerley garbage
# collected by the widget
Expand Down