From 12f0b301229199deab5600b4bf64dbaec37f4f6b Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 16 Apr 2024 21:47:26 +0100 Subject: [PATCH 1/2] Increase priority of callback for attribute_display_unit and ensure we don't try and convert None values --- glue/core/state_objects.py | 6 +++++- glue/viewers/image/state.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/glue/core/state_objects.py b/glue/core/state_objects.py index 26f98b28d..d52bf6e41 100644 --- a/glue/core/state_objects.py +++ b/glue/core/state_objects.py @@ -332,7 +332,11 @@ def update_values(self, force=False, use_default_modifiers=False, **properties): self._previous_units = display_units - if set(properties) == {'display_units'}: + if ( + set(properties) == {'display_units'} and + self.lower is not None and + self.upper is not None + ): converter = UnitConverter() diff --git a/glue/viewers/image/state.py b/glue/viewers/image/state.py index e9eac8aaa..a40346893 100644 --- a/glue/viewers/image/state.py +++ b/glue/viewers/image/state.py @@ -536,8 +536,7 @@ def format_unit(unit): ImageLayerState.attribute_display_unit.set_display_func(self, format_unit) - self.add_callback('attribute', self._update_attribute_display_unit_choices) - # self.add_callback('attribute_display_unit', self._convert_attribute_limits_units, echo_old=True) + self.add_callback('attribute', self._update_attribute_display_unit_choices, priority=10000) self._update_attribute_display_unit_choices() From f9241777d7ed4745ea55dfe30dc33bb2e21953d6 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Tue, 16 Apr 2024 22:51:19 +0100 Subject: [PATCH 2/2] Fix code style --- glue/config_gen.py | 0 glue/core/state_objects.py | 6 ++---- glue/main.py | 0 glue/viewers/matplotlib/tests/test_state.py | 0 4 files changed, 2 insertions(+), 4 deletions(-) mode change 100755 => 100644 glue/config_gen.py mode change 100755 => 100644 glue/main.py mode change 100755 => 100644 glue/viewers/matplotlib/tests/test_state.py diff --git a/glue/config_gen.py b/glue/config_gen.py old mode 100755 new mode 100644 diff --git a/glue/core/state_objects.py b/glue/core/state_objects.py index d52bf6e41..6262964ed 100644 --- a/glue/core/state_objects.py +++ b/glue/core/state_objects.py @@ -332,11 +332,9 @@ def update_values(self, force=False, use_default_modifiers=False, **properties): self._previous_units = display_units - if ( - set(properties) == {'display_units'} and + if (set(properties) == {'display_units'} and self.lower is not None and - self.upper is not None - ): + self.upper is not None): converter = UnitConverter() diff --git a/glue/main.py b/glue/main.py old mode 100755 new mode 100644 diff --git a/glue/viewers/matplotlib/tests/test_state.py b/glue/viewers/matplotlib/tests/test_state.py old mode 100755 new mode 100644