Repository: biolab/orange3

Issue:
Linear Projection: Unique variable names isn't working properly.
**Describe the bug**
In some cases when changing the domain name, the selected data in the linear projection widget doesn't recognize the duplicates in the attribute names. The  `get_unique_names` function from `Orange.data.util ` isn't working properly.

**To Reproduce**
1. Import `iris` dataset
2. Change `petal-width` attribute to `C-y`
3. Use `Linear Projection` widget on the edited dataset and select a subsection of the dataset
4. List the selected subsection in the `Data Table` and we can see that, the duplicates in attribute names aren't detected.

**Orange version:**
3.24.1

**Expected behavior**
The duplicate names in attributes should be detected and properly.

**Screenshots**
<img width="830" alt="Screen Shot 2020-03-06 at 12 10 03" src="https://user-images.githubusercontent.com/33016515/76078916-e84eae80-5fa3-11ea-8966-6e1c84711f74.png">
**Operating system:**
OSX 



Discussion:

Resolving patch:
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
@@ -707,10 +707,18 @@ def _manual_move_finish(self, anchor_idx, x, y):
     def _get_projection_data(self):
         if self.data is None or self.projection is None:
             return None
+        proposed = [a.name for a in self.projection.domain.attributes]
+        names = get_unique_names(self.data.domain, proposed)
+
+        if proposed != names:
+            attributes = tuple([attr.copy(name=name) for name, attr in
+                                zip(names, self.projection.domain.attributes)])
+        else:
+            attributes = self.projection.domain.attributes
         return self.data.transform(
             Domain(self.data.domain.attributes,
                    self.data.domain.class_vars,
-                   self.data.domain.metas + self.projection.domain.attributes))
+                   self.data.domain.metas + attributes))
 
     def commit(self):
         super().commit()


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
@@ -5,7 +5,7 @@
 
 from AnyQt.QtCore import QItemSelectionModel
 
-from Orange.data import Table, Domain, DiscreteVariable
+from Orange.data import Table, Domain, DiscreteVariable, ContinuousVariable
 from Orange.widgets.settings import Context
 from Orange.widgets.tests.base import (
     WidgetTest, WidgetOutputsTestMixin, datasets,
@@ -185,6 +185,17 @@ def test_two_classes_dataset(self):
         self.send_signal(self.widget.Inputs.data, Table("heart_disease"))
         self.assertFalse(self.widget.radio_placement.buttons[1].isEnabled())
 
+    def test_unique_name(self):
+        data = Table("iris")
+        new = ContinuousVariable("C-y")
+        d = Table.from_numpy(Domain(list(data.domain.attributes[:3])+[new],
+                                    class_vars=data.domain.class_vars), data.X,
+                             data.Y)
+        self.send_signal(self.widget.Inputs.data, d)
+        output = self.get_output(self.widget.Outputs.annotated_data)
+        metas = ["C-x (1)", "C-y (1)", "Selected"]
+        self.assertEqual([meta.name for meta in output.domain.metas], metas)
+
 
 class LinProjVizRankTests(WidgetTest):
     """