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
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Added 3D scatter test with different z-axis from default
  • Loading branch information
ruaridhg committed Jun 2, 2023
commit e9abea925b42fe6f3857574df6bc6e3328a9dec8
3 changes: 3 additions & 0 deletions src/napari_matplotlib/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import napari
import numpy.typing as npt
from numpy import array
from qtpy.QtWidgets import QComboBox, QLabel, QVBoxLayout, QWidget

from .base import NapariMPLWidget
Expand Down Expand Up @@ -93,6 +94,8 @@ def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
"""
x = self.layers[0].data[self.current_z]
y = self.layers[1].data[self.current_z]
print("x data size = ", array(x).shape)
print("y data size = ", array(y).shape)
x_axis_name = self.layers[0].name
y_axis_name = self.layers[1].name

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/napari_matplotlib/tests/scatter/test_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,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 = 9
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)