Repository: biolab/orange3

Issue:
Edit Domain: consider bool as bool
<!-- 
Thanks for taking the time to report a bug!
If you're raising an issue about an add-on (i.e., installed via Options > Add-ons), raise an issue in the relevant add-on's issue tracker instead. See: https://github.com/biolab?q=orange3
To fix the bug, we need to be able to reproduce it. Please answer the following questions to the best of your ability.
-->


- [ ] **What's wrong?**
<!-- Be specific, clear, and concise. Include screenshots if relevant. -->
<!-- If you're getting an error message, copy it, and enclose it with three backticks (```). -->
Box Plot doesn't show hidden attributes. But if one changes an attribute from hidden=True to hidden=False in Edit Domain, Box Plot still doesn't show the attribute, even though it was "unhidden".




- [ ] **How can we reproduce the problem?** 
<!-- Upload a zip with the .ows file and data. -->
<!-- Describe the steps (open this widget, click there, then add this...) -->
Corpus - Preprocess Text (output only 5 tokens for ease of debugging) - Bag of Words - Edit Domain (change one attribute's label from hidden=True to hidden=False) - Box Plot.
Box Plot won't show the attribute.




- [ ] **What's your environment?**
<!-- To find your Orange version, see "Help → About → Version" or `Orange.version.full_version` in code -->
- Operating system: macOS
- Orange version: 3.28.dev
- How you installed Orange: git



Discussion:

Resolving patch:
diff --git a/Orange/data/io_base.py b/Orange/data/io_base.py
--- a/Orange/data/io_base.py
+++ b/Orange/data/io_base.py
@@ -61,6 +61,9 @@ def __init__(self, flags):
                         except SyntaxError:
                             # If parsing failed, treat value as string
                             pass
+                    # map True and False to booleans
+                    if v in ("True", "False"):
+                        v = {"True": True, "False": False}[v]
                     self.attributes[k] = v
                 else:
                     setattr(self, flag, True)


Test patch:
diff --git a/Orange/widgets/data/tests/test_oweditdomain.py b/Orange/widgets/data/tests/test_oweditdomain.py
--- a/Orange/widgets/data/tests/test_oweditdomain.py
+++ b/Orange/widgets/data/tests/test_oweditdomain.py
@@ -217,6 +217,30 @@ def test_list_attributes_remain_lists(self):
         t2 = self.get_output(self.widget.Outputs.data)
         self.assertEqual(t2.domain["a"].attributes["list"], [1, 2, 4])
 
+    def test_annotation_bool(self):
+        """Check if bool labels remain bool"""
+        a = ContinuousVariable("a")
+        a.attributes["hidden"] = True
+        d = Domain([a])
+        t = Table.from_domain(d)
+
+        self.send_signal(self.widget.Inputs.data, t)
+
+        assert isinstance(self.widget, OWEditDomain)
+        # select first variable
+        idx = self.widget.domain_view.model().index(0)
+        self.widget.domain_view.setCurrentIndex(idx)
+
+        # change first attribute value
+        editor = self.widget.findChild(ContinuousVariableEditor)
+        assert isinstance(editor, ContinuousVariableEditor)
+        idx = editor.labels_model.index(0, 1)
+        editor.labels_model.setData(idx, "False", Qt.EditRole)
+
+        self.widget.commit()
+        t2 = self.get_output(self.widget.Outputs.data)
+        self.assertFalse(t2.domain["a"].attributes["hidden"])
+
     def test_duplicate_names(self):
         """
         Tests if widget shows error when duplicate name is entered.
@@ -277,8 +301,6 @@ def test_unlink(self):
         self.assertIsNone(out1.compute_value)
         self.assertIsNone(out2.compute_value)
 
-
-
     def test_time_variable_preservation(self):
         """Test if time variables preserve format specific attributes"""
         table = Table(test_filename("datasets/cyber-security-breaches.tab"))