diff --git a/Orange/widgets/evaluate/owconfusionmatrix.py b/Orange/widgets/evaluate/owconfusionmatrix.py index ac21708be6b..d23592df1a1 100644 --- a/Orange/widgets/evaluate/owconfusionmatrix.py +++ b/Orange/widgets/evaluate/owconfusionmatrix.py @@ -250,7 +250,6 @@ def set_results(self, results): self._init_table(len(class_values)) self.openContext(data.domain.class_var) - print("ZZZ", prev_sel_learner) if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners): self.selected_learner[:] = [0] else: diff --git a/Orange/widgets/evaluate/tests/__init__.py b/Orange/widgets/evaluate/tests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Orange/widgets/evaluate/tests/test_owconfusionmatrix.py b/Orange/widgets/evaluate/tests/test_owconfusionmatrix.py new file mode 100644 index 00000000000..cfe0c79fea4 --- /dev/null +++ b/Orange/widgets/evaluate/tests/test_owconfusionmatrix.py @@ -0,0 +1,41 @@ +# pylint: disable=missing-docstring + +from Orange.data import Table +from Orange.classification import NaiveBayesLearner, TreeLearner +from Orange.evaluation.testing import CrossValidation +from Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix +from Orange.widgets.tests.base import WidgetTest + +class TestOWClassificationTree(WidgetTest): + @classmethod + def setUpClass(cls): + super().setUpClass() + bayes = NaiveBayesLearner() + tree = TreeLearner() + iris = Table("iris") + titanic = Table("titanic") + common = dict(k=3, store_data=True) + cls.results_1_iris = CrossValidation(iris, [bayes], **common) + cls.results_2_iris = CrossValidation(iris, [bayes, tree], **common) + cls.results_2_titanic = CrossValidation(titanic, [bayes, tree], + **common) + + def setUp(self): + self.widget = self.create_widget(OWConfusionMatrix, + stored_settings={"auto_apply": False}) + + def test_selected_learner(self): + """Check learner and model for various values of all parameters + when pruning parameters are not checked + """ + self.widget.set_results(self.results_2_iris) + self.assertEqual(self.widget.selected_learner, [0]) + self.widget.selected_learner[:] = [1] + self.widget.set_results(self.results_2_titanic) + self.widget.selected_learner[:] = [1] + self.widget.set_results(self.results_1_iris) + self.widget.selected_learner[:] = [0] + self.widget.set_results(None) + self.widget.set_results(self.results_1_iris) + self.widget.selected_learner[:] = [0] +