diff --git a/Orange/widgets/model/owlogisticregression.py b/Orange/widgets/model/owlogisticregression.py index 63c401b779..95db40a620 100644 --- a/Orange/widgets/model/owlogisticregression.py +++ b/Orange/widgets/model/owlogisticregression.py @@ -49,7 +49,7 @@ class Outputs(OWBaseLearner.Outputs): max_iter = 10000 penalty_types = ("Lasso (L1)", "Ridge (L2)", "None") - penalty_types_short = ["l1", "l2", "none"] + penalty_types_short = ["l1", "l2", None] class Warning(OWBaseLearner.Warning): class_weights_used = Msg("Weighting by class may decrease performance.") @@ -86,7 +86,7 @@ def add_main_layout(self): def set_c(self): self.strength_C = self.C_s[self.C_index] penalty = self.penalty_types_short[self.penalty_type] - enable_c = penalty != "none" + enable_c = penalty is not None self.c_box.setEnabled(enable_c) if enable_c: fmt = "C={}" if self.strength_C >= 1 else "C={:.3f}" @@ -110,7 +110,7 @@ def create_learner(self): self.Warning.class_weights_used() else: class_weight = None - if penalty == "none": + if penalty is None: C = 1.0 else: C = self.strength_C diff --git a/Orange/widgets/model/tests/test_owlogisticregression.py b/Orange/widgets/model/tests/test_owlogisticregression.py index c604817e41..47139172f2 100644 --- a/Orange/widgets/model/tests/test_owlogisticregression.py +++ b/Orange/widgets/model/tests/test_owlogisticregression.py @@ -125,10 +125,10 @@ def test_class_weights(self): self.assertTrue(self.widget.Warning.class_weights_used.is_shown()) def test_no_penalty(self): - self.widget.set_penalty("none") + self.widget.set_penalty(None) self.click_apply() lr = self.get_output(self.widget.Outputs.learner) - self.assertEqual(lr.penalty, "none") + self.assertEqual(lr.penalty, None) self.assertEqual(lr.C, 1.0) self.assertEqual(self.widget.c_label.text(), "N/A") self.assertFalse(self.widget.c_slider.isEnabledTo(self.widget))