Skip to content
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

Add test similar to lcviz #2747

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Changes from all commits
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
44 changes: 44 additions & 0 deletions jdaviz/configs/specviz/tests/test_viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,47 @@ def test_spectrum_viewer_axis_labels(specviz_helper, input_unit, y_axis_label):
label = specviz_helper.app.get_viewer_by_id('specviz-0').figure.axes[1].label

assert (y_axis_label in label)


class TestResetLimitsTwoTests:
"""See https://github.com/spacetelescope/lcviz/pull/93"""

def test_reset_limits_01(self, specviz_helper, spectrum1d):
"""This should run first."""
specviz_helper.load_data(spectrum1d)
sv = specviz_helper.app.get_viewer("spectrum-viewer")

orig_xlims = (sv.state.x_min, sv.state.x_max)
orig_ylims = (sv.state.y_min, sv.state.y_max)
# set xmin and ymin to midpoints
new_xmin = (sv.state.x_min + sv.state.x_max) * 0.5
new_ymin = (sv.state.y_min + sv.state.y_max) * 0.5
sv.state.x_min = new_xmin
sv.state.y_min = new_ymin

sv.state._reset_x_limits()
assert sv.state.x_min == orig_xlims[0]
assert sv.state.y_min == new_ymin

sv.state._reset_y_limits()
assert sv.state.y_min == orig_ylims[0]

def test_reset_limits_02(self, specviz_helper, spectrum1d_nm):
"""This should run second and see if first polutes it."""
specviz_helper.load_data(spectrum1d_nm)
sv = specviz_helper.app.get_viewer("spectrum-viewer")

orig_xlims = (sv.state.x_min, sv.state.x_max)
orig_ylims = (sv.state.y_min, sv.state.y_max)
# set xmin and ymin to midpoints
new_xmin = (sv.state.x_min + sv.state.x_max) * 0.5
new_ymin = (sv.state.y_min + sv.state.y_max) * 0.5
sv.state.x_min = new_xmin
sv.state.y_min = new_ymin

sv.state._reset_x_limits()
assert sv.state.x_min == orig_xlims[0]
assert sv.state.y_min == new_ymin

sv.state._reset_y_limits()
assert sv.state.y_min == orig_ylims[0]