Repository: biolab/orange3

Issue:
Continuize ValueError: Need a distribution or data.
Continuize widget is generating an error on a dataset

Steps to reproduce:

1. Open Orange
2. Drag a File widget into the workspace
3. Drag a continuize widget into the workspace
4. Join the "File" with the left side of the continuize widget
5. Double click the File
6. Select the this dataset [7.3 - Linear Regression - House Prices - Training Dataset.xlsx](https://github.com/biolab/orange3/files/4663404/7.3.-.Linear.Regression.-.House.Prices.-.Training.Dataset.xlsx)
7. Change "year_built" column type to "Categorical"
8. Change "last_sold_price" column role to "target"
9. Click Apply
10. Error Appears

**Orange version:**
Orange 3.25

**Expected behavior**
No error should be shown, this behaviour was not seen in version 3.24.1

**Screenshots**
![continuize_error](https://user-images.githubusercontent.com/17454557/82579072-32980280-9b85-11ea-9c35-a0f15ad8c0f1.PNG)


**Operating system:**
Windows





Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owcontinuize.py b/Orange/widgets/data/owcontinuize.py
--- a/Orange/widgets/data/owcontinuize.py
+++ b/Orange/widgets/data/owcontinuize.py
@@ -206,7 +206,7 @@ def one_hot_coding(var):
 
 def continuize_domain(data,
                       multinomial_treatment=Continuize.Indicators,
-                      continuous_treatment=Continuize.Leave,
+                      continuous_treatment=OWContinuize.Normalize.Leave,
                       class_treatment=Continuize.Leave):
     domain = data.domain
     def needs_dist(var, mtreat, ctreat):
@@ -214,7 +214,7 @@ def needs_dist(var, mtreat, ctreat):
         if var.is_discrete:
             return mtreat == Continuize.FrequentAsBase
         elif var.is_continuous:
-            return ctreat != Continuize.Leave
+            return ctreat != OWContinuize.Normalize.Leave
         else:
             raise ValueError
 
@@ -222,7 +222,7 @@ def needs_dist(var, mtreat, ctreat):
     attr_needs_dist = [needs_dist(var, multinomial_treatment,
                                   continuous_treatment)
                        for var in domain.attributes]
-    cls_needs_dist = [needs_dist(var, class_treatment, Continuize.Leave)
+    cls_needs_dist = [needs_dist(var, class_treatment, OWContinuize.Normalize.Leave)
                       for var in domain.class_vars]
 
     columns = [i for i, needs in enumerate(attr_needs_dist + cls_needs_dist)
@@ -242,7 +242,7 @@ def needs_dist(var, mtreat, ctreat):
                 for var, needs_dist in zip(domain.attributes, attr_needs_dist)]
     newclass = [continuize_var(var,
                                next(dist_iter) if needs_dist else None,
-                               class_treatment, Continuize.Remove)
+                               class_treatment, OWContinuize.Normalize.Leave)
                 for var, needs_dist in zip(domain.class_vars, cls_needs_dist)]
 
     newattrs = reduce(list.__iadd__, newattrs, [])
@@ -253,13 +253,13 @@ def needs_dist(var, mtreat, ctreat):
 def continuize_var(var,
                    data_or_dist=None,
                    multinomial_treatment=Continuize.Indicators,
-                   continuous_treatment=Continuize.Leave):
+                   continuous_treatment=OWContinuize.Normalize.Leave):
     def continuize_continuous():
-        dist = _ensure_dist(var, data_or_dist)
+        dist = _ensure_dist(var, data_or_dist) if continuous_treatment != OWContinuize.Normalize.Leave else None
         treatments = [lambda var, _: var,
                       normalize_by_sd, center_to_mean, divide_by_sd,
                       normalize_to_11, normalize_to_01]
-        if dist.shape[1] == 0:
+        if dist is not None and dist.shape[1] == 0:
             return [var]
         new_var = treatments[continuous_treatment](var, dist)
         return [new_var]
@@ -365,7 +365,7 @@ def normalize_by_span(var, dist, zero_based=True):
 class DomainContinuizer(Reprable):
     def __init__(self,
                  multinomial_treatment=Continuize.Indicators,
-                 continuous_treatment=Continuize.Leave,
+                 continuous_treatment=OWContinuize.Normalize.Leave,
                  class_treatment=Continuize.Leave):
         self.multinomial_treatment = multinomial_treatment
         self.continuous_treatment = continuous_treatment


Test patch:
diff --git a/Orange/widgets/data/tests/test_owcontinuize.py b/Orange/widgets/data/tests/test_owcontinuize.py
--- a/Orange/widgets/data/tests/test_owcontinuize.py
+++ b/Orange/widgets/data/tests/test_owcontinuize.py
@@ -62,6 +62,11 @@ def test_summary(self):
         output_sum.assert_called_once()
         self.assertEqual(output_sum.call_args[0][0].brief, "")
 
+    def test_continuous(self):
+        table = Table("housing")
+        self.send_signal(self.widget.Inputs.data, table)
+        self.widget.unconditional_commit()
+
     def test_one_column_equal_values(self):
         """
         No crash on a column with equal values and with selected option