Skip to content

Commit

Permalink
Merge pull request #344 from astrofrog/fix-scatter-limits-init
Browse files Browse the repository at this point in the history
Fix initial limits of viewers
  • Loading branch information
astrofrog authored Feb 3, 2023
2 parents 8a32f2e + 77a1682 commit 20fa361
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions glue_jupyter/bqplot/common/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def update_axes(*ignore):
self.state.add_callback('y_min', self._update_bqplot_limits)
self.state.add_callback('y_max', self._update_bqplot_limits)

self._update_bqplot_limits()

on_change([(self.state, 'show_axes')])(self._sync_show_axes)

self.create_layout()
Expand Down
18 changes: 18 additions & 0 deletions glue_jupyter/bqplot/scatter/tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,21 @@ def test_zorder(app, data_volume, dataxz, dataxyz):
vol.state.zorder, xz.state.zorder, xyz.state.zorder = p
it = iter(s.figure.marks)
assert all(layer.scatter in it for layer in s.layers)


def test_limits_init(app, dataxz, dataxyz):

# Regression test for a bug that caused the bqplot limits
# to not match the glue state straight after initialization

s = app.scatter2d(data=dataxyz)

assert s.state.x_min == 0.92
assert s.state.x_max == 3.08
assert s.state.y_min == 1.92
assert s.state.y_max == 4.08

assert s.scale_x.min == 0.92
assert s.scale_x.max == 3.08
assert s.scale_y.min == 1.92
assert s.scale_y.max == 4.08

0 comments on commit 20fa361

Please sign in to comment.