Skip to content

Commit

Permalink
Backport PR #2056 on branch v3.3.x (fix initial slice of uncert-viewe…
Browse files Browse the repository at this point in the history
…r) (#2060)

* Backport PR #2056: fix initial slice of uncert-viewer

* update mouseover test

NOTE: this is just switching one wrong value for another since #2009 is not being backported

---------

Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: Kyle Conroy <[email protected]>
  • Loading branch information
3 people authored Mar 3, 2023
1 parent 042dfab commit 1d30ceb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Bug Fixes
Cubeviz
^^^^^^^

* Fix initial slice of uncertainty viewer. [#2056]

Imviz
^^^^^

Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/cubeviz/plugins/slice/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def _on_data_added(self, msg):
if len(msg.data.shape) == 3:
self.max_value = msg.data.shape[-1] - 1
self._watch_viewer(msg.viewer, True)
msg.viewer.state.slices = (0, 0, int(self.slice))

elif isinstance(msg.viewer, BqplotProfileView):
self._watch_viewer(msg.viewer, True)
Expand Down
10 changes: 6 additions & 4 deletions jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ def test_slice(cubeviz_helper, spectrum1d_cube):
app.add_data(spectrum1d_cube, 'test')
app.add_data_to_viewer("spectrum-viewer", "test")
app.add_data_to_viewer("flux-viewer", "test")
app.add_data_to_viewer("uncert-viewer", "test")

# sample cube only has 2 slices with wavelengths [4.62280007e-07 4.62360028e-07] m
assert sl.slice == 1
assert cubeviz_helper.app.get_viewer("flux-viewer").state.slices[-1] == 1
assert cubeviz_helper.app.get_viewer("uncert-viewer").state.slices[-1] == 1
cubeviz_helper.select_slice(0)
assert sl.slice == 0

Expand All @@ -47,17 +50,16 @@ def test_slice(cubeviz_helper, spectrum1d_cube):
sl._on_wavelength_updated({'new': '1.2.3'})
assert sl.slice == 0

# there is only one watched viewer, since the uncertainty/mask viewers are empty
assert len(sl._watched_viewers) == 1
assert len(sl._indicator_viewers) == 1
assert len(sl._watched_viewers) == 2 # flux-viewer, uncert-viewer
assert len(sl._indicator_viewers) == 1 # spectrum-viewer

# test setting a static 2d image to the "watched" flux viewer to make sure it disconnects
mm = app.get_tray_item_from_name('cubeviz-moment-maps')
mm.add_to_viewer_selected = 'flux-viewer'
with pytest.warns(UserWarning, match='No observer defined on WCS'):
mm.vue_calculate_moment()

assert len(sl._watched_viewers) == 1
assert len(sl._watched_viewers) == 2
assert len(sl._indicator_viewers) == 1

# test in conjunction with as_steps
Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/cubeviz/plugins/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def test_fits_image_hdu_parse_from_file(tmpdir, image_cube_hdu_obj, cubeviz_help
unc_viewer.on_mouse_or_key_event({'event': 'mousemove', 'domain': {'x': -1, 'y': 0}})
assert unc_viewer.label_mouseover.pixel == 'x=-1.0 y=00.0'
assert unc_viewer.label_mouseover.value == '' # Out of bounds
assert unc_viewer.label_mouseover.world_ra_deg == '205.4441642302'
assert unc_viewer.label_mouseover.world_dec_deg == '26.9996148973'
assert unc_viewer.label_mouseover.world_ra_deg == '205.4433848390'
assert unc_viewer.label_mouseover.world_dec_deg == '26.9996149270'


@pytest.mark.filterwarnings('ignore')
Expand Down

0 comments on commit 1d30ceb

Please sign in to comment.