Repository: biolab/orange3

Issue:
Color: Renaming variables is broken
**Describe the bug**
After renaming a variable in the Color widget all its values are unknown/missing (`?`).

**Orange version:**
3.25



Discussion:
I don't think Color should enable renaming variables. I mean... why? We have Edit Domain for that.

Resolving patch:
diff --git a/Orange/widgets/data/owcolor.py b/Orange/widgets/data/owcolor.py
--- a/Orange/widgets/data/owcolor.py
+++ b/Orange/widgets/data/owcolor.py
@@ -7,6 +7,7 @@
 from AnyQt.QtWidgets import QHeaderView, QColorDialog, QTableView, QComboBox
 
 import Orange
+from Orange.preprocess.transformation import Identity
 from Orange.util import color_to_hex
 from Orange.widgets import widget, settings, gui
 from Orange.widgets.gui import HorizontalGridDelegate
@@ -82,7 +83,8 @@ def set_value(self, i, value):
         self.new_values[i] = value
 
     def create_variable(self):
-        new_var = self.var.copy(name=self.name, values=self.values)
+        new_var = self.var.copy(name=self.name, values=self.values,
+                                compute_value=Identity(self.var))
         new_var.colors = np.asarray(self.colors)
         return new_var
 
@@ -114,7 +116,8 @@ def palette_name(self, palette_name):
         self.new_palette_name = palette_name
 
     def create_variable(self):
-        new_var = self.var.copy(name=self.name)
+        new_var = self.var.copy(name=self.name,
+                                compute_value=Identity(self.var))
         new_var.attributes["palette"] = self.palette_name
         return new_var
 


Test patch:
diff --git a/Orange/widgets/data/tests/test_owcolor.py b/Orange/widgets/data/tests/test_owcolor.py
--- a/Orange/widgets/data/tests/test_owcolor.py
+++ b/Orange/widgets/data/tests/test_owcolor.py
@@ -8,6 +8,7 @@
 from AnyQt.QtGui import QBrush
 
 from Orange.data import Table, ContinuousVariable, DiscreteVariable, Domain
+from Orange.preprocess.transformation import Identity
 from Orange.util import color_to_hex
 from Orange.widgets.utils import colorpalettes
 from Orange.widgets.utils.state_summary import format_summary_details
@@ -58,11 +59,15 @@ def test_create_variable(self):
         self.assertEqual(var.name, "z")
         self.assertEqual(var.values, ("a", "d", "c"))
         np.testing.assert_equal(var.colors, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])
+        self.assertIsInstance(var.compute_value, Identity)
+        self.assertIs(var.compute_value.variable, desc.var)
 
         palette = desc.var.attributes["palette"] = object()
         var = desc.create_variable()
         self.assertIs(desc.var.attributes["palette"], palette)
         self.assertFalse(hasattr(var.attributes, "palette"))
+        self.assertIsInstance(var.compute_value, Identity)
+        self.assertIs(var.compute_value.variable, desc.var)
 
 
 class ContAttrDesc(unittest.TestCase):
@@ -89,11 +94,15 @@ def test_create_variable(self):
         self.assertIsInstance(var, ContinuousVariable)
         self.assertEqual(var.name, "z")
         self.assertEqual(var.palette.name, palette_name)
+        self.assertIsInstance(var.compute_value, Identity)
+        self.assertIs(var.compute_value.variable, desc.var)
 
         colors = desc.var.attributes["colors"] = object()
         var = desc.create_variable()
         self.assertIs(desc.var.attributes["colors"], colors)
         self.assertFalse(hasattr(var.attributes, "colors"))
+        self.assertIsInstance(var.compute_value, Identity)
+        self.assertIs(var.compute_value.variable, desc.var)
 
 
 class BaseTestColorTableModel:
@@ -121,7 +130,6 @@ def test_data(self):
         index = self.model.index(2, 0)
         self.assertEqual(data(index, Qt.DisplayRole), self.descs[2].name)
 
-
     def test_set_data(self):
         emit = Mock()
         try: