From 6b9b705869ec4c9bf6c582a060bd63530e715b1e Mon Sep 17 00:00:00 2001 From: Vesna Tanko Date: Mon, 3 Dec 2018 11:27:20 +0100 Subject: [PATCH] OWDataProjectionWidget: Consider tables with nan-s equal --- Orange/widgets/tests/base.py | 5 +++-- Orange/widgets/visualize/utils/widget.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Orange/widgets/tests/base.py b/Orange/widgets/tests/base.py index fab6e0fe98a..85e812d6024 100644 --- a/Orange/widgets/tests/base.py +++ b/Orange/widgets/tests/base.py @@ -896,9 +896,10 @@ def test_none_data(self): def test_plot_once(self, timeout=DEFAULT_TIMEOUT): """Test if data is plotted only once but committed on every input change""" + table = Table("heart_disease") self.widget.setup_plot = Mock() self.widget.commit = Mock() - self.send_signal(self.widget.Inputs.data, self.data) + self.send_signal(self.widget.Inputs.data, table) self.widget.setup_plot.assert_called_once() self.widget.commit.assert_called_once() @@ -907,7 +908,7 @@ def test_plot_once(self, timeout=DEFAULT_TIMEOUT): self.assertTrue(spy.wait(timeout)) self.widget.commit.reset_mock() - self.send_signal(self.widget.Inputs.data_subset, self.data[::10]) + self.send_signal(self.widget.Inputs.data_subset, table[::10]) self.widget.setup_plot.assert_called_once() self.widget.commit.assert_called_once() diff --git a/Orange/widgets/visualize/utils/widget.py b/Orange/widgets/visualize/utils/widget.py index 866a0ddc6c5..6362cad4cea 100644 --- a/Orange/widgets/visualize/utils/widget.py +++ b/Orange/widgets/visualize/utils/widget.py @@ -420,9 +420,11 @@ def set_data(self, data): if not same_domain: self.init_attr_values() self.openContext(self.data) - self.__invalidated = not (data_existed and self.data is not None and - np.array_equal(effective_data.X, - self.effective_data.X)) + self.__invalidated = not ( + data_existed and self.data is not None and + effective_data.X.shape == self.effective_data.X.shape and + np.allclose(effective_data.X, + self.effective_data.X, equal_nan=True)) if self.__invalidated: self.clear() self.cb_class_density.setEnabled(self.can_draw_density())