Skip to content

Commit

Permalink
test coverage (and fix) resetting x/y limits in scatter viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Aug 23, 2023
1 parent 62aa77b commit 601eaaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lcviz/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _reset_att_limits(self, ax):
setattr(self, f'{ax}_min', ax_min)
setattr(self, f'{ax}_max', ax_max)

def _reset_x_limit(self, *event):
def _reset_x_limits(self, *event):
self._reset_att_limits('x')

def _reset_y_limits(self, *event):
Expand Down
19 changes: 19 additions & 0 deletions lcviz/tests/test_viewers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

def test_reset_limits(helper, light_curve_like_kepler_quarter):
helper.load_data(light_curve_like_kepler_quarter)
tv = helper.app.get_viewer(helper._default_time_viewer_reference_name)

orig_xlims = (tv.state.x_min, tv.state.x_max)
orig_ylims = (tv.state.y_min, tv.state.y_max)
# set xmin and ymin to midpoints
new_xmin = (tv.state.x_min + tv.state.x_max) / 2
new_ymin = (tv.state.y_min + tv.state.y_max) / 2
tv.state.x_min = new_xmin
tv.state.y_min = new_ymin

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

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

0 comments on commit 601eaaf

Please sign in to comment.