From 84c3c218734fb1033e1e21b3bfcf2f0ed592aee3 Mon Sep 17 00:00:00 2001 From: Lan Zagar Date: Fri, 4 Feb 2022 17:04:19 +0100 Subject: [PATCH 1/2] owlinearprojection: Add class to effective_data for LDA. --- Orange/widgets/visualize/owlinearprojection.py | 5 ++++- Orange/widgets/visualize/tests/test_owlinearprojection.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/visualize/owlinearprojection.py b/Orange/widgets/visualize/owlinearprojection.py index 48fcdf888af..f1c4f00e8a9 100644 --- a/Orange/widgets/visualize/owlinearprojection.py +++ b/Orange/widgets/visualize/owlinearprojection.py @@ -329,7 +329,10 @@ def effective_variables(self): @property def effective_data(self): - return self.data.transform(Domain(self.effective_variables)) + cvs = None + if self.placement == Placement.LDA: + cvs = self.data.domain.class_vars + return self.data.transform(Domain(self.effective_variables, cvs)) def __vizrank_set_attrs(self, attrs): if not attrs: diff --git a/Orange/widgets/visualize/tests/test_owlinearprojection.py b/Orange/widgets/visualize/tests/test_owlinearprojection.py index d936a3002c0..0c60b3da83a 100644 --- a/Orange/widgets/visualize/tests/test_owlinearprojection.py +++ b/Orange/widgets/visualize/tests/test_owlinearprojection.py @@ -85,6 +85,8 @@ def test_no_data_for_lda(self): self.send_signal(self.widget.Inputs.data, self.data) self.widget.radio_placement.buttons[Placement.LDA].click() self.assertTrue(buttons[Placement.LDA].isEnabled()) + output = self.get_output(self.widget.Outputs.components) + self.assertTrue(output and len(output) == 2) self.send_signal(self.widget.Inputs.data, Table("housing")) self.assertFalse(buttons[Placement.LDA].isEnabled()) self.send_signal(self.widget.Inputs.data, None) From 1bf5e7e34921419241d40fa64ffe86af0ab3e45b Mon Sep 17 00:00:00 2001 From: Lan Zagar Date: Fri, 11 Feb 2022 11:27:22 +0100 Subject: [PATCH 2/2] OWDataProjectionWidget: Check all parts of effective_data for invalidation --- Orange/widgets/visualize/utils/widget.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/visualize/utils/widget.py b/Orange/widgets/visualize/utils/widget.py index 924acc179fc..62ede7c3e9f 100644 --- a/Orange/widgets/visualize/utils/widget.py +++ b/Orange/widgets/visualize/utils/widget.py @@ -455,7 +455,10 @@ def set_data(self, data): self.openContext(self.data) self._invalidated = not ( data_existed and self.data is not None and - array_equal(effective_data.X, self.effective_data.X)) + array_equal(effective_data.X, self.effective_data.X) and + array_equal(effective_data.Y, self.effective_data.Y) and + array_equal(effective_data.metas, self.effective_data.metas) + ) self._domain_invalidated = not ( data_existed and self.data is not None and effective_data.domain.checksum()