From 8e9a42ba32f0ab457798e109e6a5dff313bb7174 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 13 Aug 2024 15:18:31 +0100 Subject: [PATCH 1/2] Make contour unit testing a little more extensive by checking result after multiple unit transformations --- glue_jupyter/bqplot/image/tests/test_visual.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glue_jupyter/bqplot/image/tests/test_visual.py b/glue_jupyter/bqplot/image/tests/test_visual.py index 3ef57110..56897fb7 100644 --- a/glue_jupyter/bqplot/image/tests/test_visual.py +++ b/glue_jupyter/bqplot/image/tests/test_visual.py @@ -29,6 +29,8 @@ def test_contour_units( assert_allclose(image.state.layers[0].levels, [0.1, 0.3, 0.5, 0.7, 0.9]) + image.state.layers[0].attribute_display_unit = 'mm' + image.state.layers[0].attribute_display_unit = 'km' image.state.layers[0].attribute_display_unit = 'm' assert_allclose(image.state.layers[0].levels, [100, 300, 500, 700, 900]) From 76691b7ca29c3d7982eb8f1e3249dcbd59378ca1 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 13 Aug 2024 15:23:22 +0100 Subject: [PATCH 2/2] Make sure _previous_attribute is set initially --- glue_jupyter/bqplot/image/state.py | 1 + 1 file changed, 1 insertion(+) diff --git a/glue_jupyter/bqplot/image/state.py b/glue_jupyter/bqplot/image/state.py index f045f4ed..a8142f25 100644 --- a/glue_jupyter/bqplot/image/state.py +++ b/glue_jupyter/bqplot/image/state.py @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs): self.add_callback('level_mode', self._update_levels) self.add_callback('levels', self._update_labels) self.add_callback('attribute_display_unit', self._convert_units_c_limits, echo_old=True) + self._convert_units_c_limits(None, None) self._update_levels()