From d2ec951049232bc507a39216a097407024a9f065 Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Mon, 21 Aug 2023 16:26:25 +0200 Subject: [PATCH] owpredictions: Fix an exception when switching regression error ... when there is no model on input only data. --- Orange/widgets/evaluate/owpredictions.py | 4 +++- Orange/widgets/evaluate/tests/test_owpredictions.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/evaluate/owpredictions.py b/Orange/widgets/evaluate/owpredictions.py index 69797905a62..34c41302f9c 100644 --- a/Orange/widgets/evaluate/owpredictions.py +++ b/Orange/widgets/evaluate/owpredictions.py @@ -325,7 +325,9 @@ def _update_control_visibility(self): self.score_opt_box.setVisible(bool(self.class_var)) def _reg_error_changed(self): - self.predictionsview.model().setRegErrorType(self.show_reg_errors) + model = self.predictionsview.model() + if model is not None: + model.setRegErrorType(self.show_reg_errors) self._update_prediction_delegate() def _update_errors_visibility(self): diff --git a/Orange/widgets/evaluate/tests/test_owpredictions.py b/Orange/widgets/evaluate/tests/test_owpredictions.py index a6ab9b15dbd..f48a5eb884b 100644 --- a/Orange/widgets/evaluate/tests/test_owpredictions.py +++ b/Orange/widgets/evaluate/tests/test_owpredictions.py @@ -1157,6 +1157,13 @@ def get_delegate() -> Optional[RegressionErrorDelegate]: self.assertEqual(delegate.span, max(3 / 2, 6 / 11)) self.assertFalse(delegate.centered) + def test_regression_error_no_model(self): + data = self.housing[:5] + self.send_signal(self.widget.Inputs.data, data) + combo = self.widget.controls.show_reg_errors + with excepthook_catch(raise_on_exit=True): + simulate.combobox_activate_index(combo, 1) + def test_report(self): widget = self.widget