Repository: biolab/orange3

Issue:
Nomogram does not work when recieved textual data from Logistic Regression
<!-- 
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?**
Courpus>Text Preprocessing >Bag of words ->Logistic Regression ->Nomogram
the nomogram windows is empty only for textual data.
Previously it works not it is not





**How can we reproduce the problem?** 
Courpus>Text Preprocessing >Bag of words ->Logistic Regression ->Nomogram
the nomogram windows is empty only for textual data.
Previously it works not it is not





**What's your environment?**
windows 
orange 3.33 and 3.34 has this bug, Not only for me, also my students has a same problem



Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/ownomogram.py b/Orange/widgets/visualize/ownomogram.py
--- a/Orange/widgets/visualize/ownomogram.py
+++ b/Orange/widgets/visualize/ownomogram.py
@@ -18,7 +18,8 @@
 from AnyQt.QtCore import Qt, QRectF, QSize, QPropertyAnimation, QObject, \
     pyqtProperty
 
-from Orange.data import Table, Domain, DiscreteVariable, ContinuousVariable
+from Orange.data import Table, Domain, DiscreteVariable, ContinuousVariable, \
+    Variable
 from Orange.statistics.util import nanmin, nanmax, nanmean, unique
 from Orange.classification import Model
 from Orange.classification.naive_bayes import NaiveBayesModel
@@ -1311,7 +1312,10 @@ def reconstruct_domain(classifier: Model, preprocessed: Domain) -> Domain:
         attrs = OrderedDict()
         for attr in preprocessed.attributes:
             cv = attr._compute_value.variable._compute_value
-            var = cv.variable if cv else original[attr.name]
+            if cv and isinstance(getattr(cv, "variable", None), Variable):
+                var = cv.variable
+            else:
+                var = original[attr.name]
             var = original[var.name] if var.name in original else attr
             if var in attrs:    # the reason for OrderedDict
                 continue


Test patch:
diff --git a/Orange/widgets/visualize/tests/test_ownomogram.py b/Orange/widgets/visualize/tests/test_ownomogram.py
--- a/Orange/widgets/visualize/tests/test_ownomogram.py
+++ b/Orange/widgets/visualize/tests/test_ownomogram.py
@@ -339,6 +339,19 @@ def test_missing_class_value(self):
         self.assertEqual(target_cb.currentIndex(), 2)
         self.assertEqual(target_cb.count(), 3)
 
+    def test_compute_value(self):
+        class ComputeValue:
+            def __call__(self, table):
+                return table.get_column(0)
+
+        iris = Table("iris")
+        attrs = list(iris.domain.attributes)
+        attrs[0] = ContinuousVariable(attrs[0].name, 1, ComputeValue())
+        domain = Domain(attrs, iris.domain.class_vars)
+        data = iris.transform(domain)
+        lr = LogisticRegressionLearner()(data)
+        self.send_signal(self.widget.Inputs.classifier, lr)
+
 
 if __name__ == "__main__":
     unittest.main()