From ad9447871153ec87a3f5809127d7d3535f70c555 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 7 Feb 2023 10:22:07 +0000 Subject: [PATCH 1/2] Don't set scale limits if glue state limits are None, to avoid unecessary updates --- glue_jupyter/bqplot/common/viewer.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/glue_jupyter/bqplot/common/viewer.py b/glue_jupyter/bqplot/common/viewer.py index 9befa3fc..836489d0 100644 --- a/glue_jupyter/bqplot/common/viewer.py +++ b/glue_jupyter/bqplot/common/viewer.py @@ -114,13 +114,15 @@ def _update_bqplot_limits(self, *args): # doesn't change this - at the end of the day, the two scales are # separate widgets so will result in two updates. - with self.scale_x.hold_sync(): - self.scale_x.min = float_or_none(self.state.x_min) - self.scale_x.max = float_or_none(self.state.x_max) + if self.state.x_min is not None and self.state.x_max is not None: + with self.scale_x.hold_sync(): + self.scale_x.min = float_or_none(self.state.x_min) + self.scale_x.max = float_or_none(self.state.x_max) - with self.scale_y.hold_sync(): - self.scale_y.min = float_or_none(self.state.y_min) - self.scale_y.max = float_or_none(self.state.y_max) + if self.state.y_min is not None and self.state.y_max is not None: + with self.scale_y.hold_sync(): + self.scale_y.min = float_or_none(self.state.y_min) + self.scale_y.max = float_or_none(self.state.y_max) self._last_limits = (self.state.x_min, self.state.x_max, self.state.y_min, self.state.y_max) From 9697545694f60e14bd9f2287ee1b9794fe9e95a9 Mon Sep 17 00:00:00 2001 From: Derek Homeier Date: Tue, 7 Feb 2023 13:22:47 +0100 Subject: [PATCH 2/2] Simplify conversion Co-authored-by: Thomas Robitaille --- glue_jupyter/bqplot/common/viewer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glue_jupyter/bqplot/common/viewer.py b/glue_jupyter/bqplot/common/viewer.py index 836489d0..1af906df 100644 --- a/glue_jupyter/bqplot/common/viewer.py +++ b/glue_jupyter/bqplot/common/viewer.py @@ -10,7 +10,7 @@ from ...view import IPyWidgetView from ...link import on_change -from ...utils import float_or_none, debounced, get_ioloop +from ...utils import debounced, get_ioloop from .tools import ROIClickAndDrag __all__ = ['BqplotBaseView'] @@ -116,13 +116,13 @@ def _update_bqplot_limits(self, *args): if self.state.x_min is not None and self.state.x_max is not None: with self.scale_x.hold_sync(): - self.scale_x.min = float_or_none(self.state.x_min) - self.scale_x.max = float_or_none(self.state.x_max) + self.scale_x.min = float(self.state.x_min) + self.scale_x.max = float(self.state.x_max) if self.state.y_min is not None and self.state.y_max is not None: with self.scale_y.hold_sync(): - self.scale_y.min = float_or_none(self.state.y_min) - self.scale_y.max = float_or_none(self.state.y_max) + self.scale_y.min = float(self.state.y_min) + self.scale_y.max = float(self.state.y_max) self._last_limits = (self.state.x_min, self.state.x_max, self.state.y_min, self.state.y_max)