Skip to content

Commit

Permalink
Dev test fix take two (#8)
Browse files Browse the repository at this point in the history
* Fix failing dev test by using lim_helpers
* Make equivalent change in reset_limits
  • Loading branch information
rosteen authored and kecnry committed Mar 28, 2024
1 parent 368debd commit 374c03d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lcviz/state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from echo import delay_callback
import numpy as np

from glue.viewers.scatter.state import ScatterViewerState
Expand All @@ -24,9 +23,10 @@ def _reset_att_limits(self, ax):
if not np.all(np.isfinite([ax_min, ax_max])): # pragma: no cover
return

with delay_callback(self, f'{ax}_min', f'{ax}_max'):
setattr(self, f'{ax}_min', ax_min)
setattr(self, f'{ax}_max', ax_max)
lim_helper = getattr(self, f'{ax}_lim_helper')
lim_helper.lower = ax_min
lim_helper.upper = ax_max
lim_helper.update_values()

def _reset_x_limits(self, *event):
self._reset_att_limits('x')
Expand All @@ -50,11 +50,15 @@ def reset_limits(self, *event):
y_min = min(y_min, np.nanmin(y_data))
y_max = max(y_max, np.nanmax(y_data))

with delay_callback(self, 'x_min', 'x_max', 'y_min', 'y_max'):
self.x_min = x_min
self.x_max = x_max
self.y_min = y_min
self.y_max = y_max
# We need to adjust the limits in here to avoid triggering all
# the update events then changing the limits again.
self._adjust_limits_aspect()
x_lim_helper = getattr(self, 'x_lim_helper')
x_lim_helper.lower = x_min
x_lim_helper.upper = x_max

y_lim_helper = getattr(self, 'y_lim_helper')
y_lim_helper.lower = y_min
y_lim_helper.upper = y_max

x_lim_helper.update_values()
y_lim_helper.update_values()

self._adjust_limits_aspect()

0 comments on commit 374c03d

Please sign in to comment.