From b2b6d33c5b586627234c399a7520f0ea22f7e0ed Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 1 Nov 2017 12:26:44 -0400 Subject: [PATCH] Merge pull request #1471 from astrofrog/fix-update-viewers-numerical Fix updating of viewers when numerical values are changed --- CHANGES.md | 3 +++ glue/viewers/common/qt/data_viewer_with_state.py | 2 +- glue/viewers/matplotlib/qt/tests/test_data_viewer.py | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index c141850bb..a4c0b23ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,9 @@ v0.12.2 (unreleased) v0.12.1 (2017-10-30) -------------------- +* Fix a bug that caused the 1D and 2D viewers to not update correctly + when the numerical values in data were changed. [#1471] + * Fix a bug that caused glue to crash when adding components to a dataset after closing a viewer that had that data. [#1460, #1464] diff --git a/glue/viewers/common/qt/data_viewer_with_state.py b/glue/viewers/common/qt/data_viewer_with_state.py index 315a487b9..ea2acc511 100644 --- a/glue/viewers/common/qt/data_viewer_with_state.py +++ b/glue/viewers/common/qt/data_viewer_with_state.py @@ -191,7 +191,7 @@ def register_to_hub(self, hub): filter=self._has_data_or_subset) hub.subscribe(self, msg.NumericalDataChangedMessage, - handler=self._update_subset, + handler=self._update_data, filter=self._has_data_or_subset) hub.subscribe(self, msg.DataCollectionDeleteMessage, diff --git a/glue/viewers/matplotlib/qt/tests/test_data_viewer.py b/glue/viewers/matplotlib/qt/tests/test_data_viewer.py index f742a1af6..7cc2dc8be 100644 --- a/glue/viewers/matplotlib/qt/tests/test_data_viewer.py +++ b/glue/viewers/matplotlib/qt/tests/test_data_viewer.py @@ -525,3 +525,15 @@ def test_apply_roi_undo(self): assert self.data.subsets[0].subset_state.lo == lo2 assert self.data.subsets[0].subset_state.hi == hi2 + + def test_numerical_data_changed(self): + self.init_draw_count() + self.init_subset() + assert self.draw_count == 0 + self.viewer.add_data(self.data) + assert self.draw_count == 1 + data = Data() + for cid in self.data.visible_components: + data.add_component(self.data[cid] * 2, cid.label) + self.data.update_values_from_data(data) + assert self.draw_count == 2