Skip to content

Commit

Permalink
Add simple test
Browse files Browse the repository at this point in the history
Codestyle

Codestyle
  • Loading branch information
rosteen committed Jan 5, 2024
1 parent 4801c6a commit a410c78
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions jdaviz/configs/cubeviz/plugins/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def test_spectrum_at_spaxel(cubeviz_helper, spectrum1d_cube):
assert len(flux_viewer.native_marks) == 2
assert len(spectrum_viewer.data()) == 1

# Move to spaxel location
flux_viewer.toolbar.active_tool.on_mouse_move(
{'event': 'mousemove', 'domain': {'x': x, 'y': y}, 'altKey': False})
assert flux_viewer.toolbar.active_tool._mark in spectrum_viewer.figure.marks
assert flux_viewer.toolbar.active_tool._mark.visible is True

# Click on spaxel location
flux_viewer.toolbar.active_tool.on_mouse_event(
{'event': 'click', 'domain': {'x': x, 'y': y}, 'altKey': False})
Expand All @@ -30,6 +36,11 @@ def test_spectrum_at_spaxel(cubeviz_helper, spectrum1d_cube):
assert len(subsets) == 1
assert isinstance(reg, RectanglePixelRegion)

# Mouse leave event
flux_viewer.toolbar.active_tool.on_mouse_move(
{'event': 'mouseleave', 'domain': {'x': x, 'y': y}, 'altKey': False})
assert flux_viewer.toolbar.active_tool._mark.visible is False

# Deselect tool
flux_viewer.toolbar.active_tool = None
assert len(flux_viewer.native_marks) == 3
Expand Down
6 changes: 3 additions & 3 deletions jdaviz/configs/cubeviz/plugins/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def on_mouse_move(self, data):
self._mark.visible = False
else:
self._mark.visible = True
y_values = spectrum.flux[x,y,:]
y_values = spectrum.flux[x, y, :]
if np.all(np.isnan(y_values)):
self._mark.visible=False
self._mark.visible = False
return
self._mark.update_xy(spectrum.spectral_axis.value, y_values)
self._spectrum_viewer.state.y_max = np.nanmax(y_values.value) * 1.2
self._spectrum_viewer.state.y_min = np.nanmin(y_values.value) * 0.8
self._spectrum_viewer.state.y_min = np.nanmin(y_values.value) * 0.8

0 comments on commit a410c78

Please sign in to comment.