Repository: biolab/orange3

Issue:
LDA not working in Linear Projection widget ?
LDA crashes with a python error in 3.28 (Windows) : "_y should be a 1d array, got an array of shape (150,0) instead_".

![image](https://user-images.githubusercontent.com/22688234/112451502-de861d80-8d55-11eb-8c19-3898acec9b5b.png)
![image](https://user-images.githubusercontent.com/22688234/112451563-f067c080-8d55-11eb-8f59-eb6fce85c6e9.png)

Using iris dataset, target defined as "iris". The classes are properly recognized.

In the Linear Analysis Widget, I can do a PCA or a circular projection but get an empty window and an error message with LDA :

![image](https://user-images.githubusercontent.com/22688234/112451721-1ab97e00-8d56-11eb-9a24-21e371ea869c.png)
![image](https://user-images.githubusercontent.com/22688234/112451701-168d6080-8d56-11eb-8232-4f752baa72ee.png)

Unless I've done something wrong (what ?), this looks like a bug in the widget.


Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owlinearprojection.py b/Orange/widgets/visualize/owlinearprojection.py
--- 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/utils/widget.py b/Orange/widgets/visualize/utils/widget.py
--- 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()


Test patch:
diff --git a/Orange/widgets/visualize/tests/test_owlinearprojection.py b/Orange/widgets/visualize/tests/test_owlinearprojection.py
--- 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)