From 59abc4e2881a80229e492c541091cf6ce39bdd83 Mon Sep 17 00:00:00 2001 From: Vesna Tanko Date: Tue, 20 Sep 2016 10:38:49 +0200 Subject: [PATCH] OWBaseLearner: Do not re-fit if name has changed When the name of the learner had been changed, the entire model was re-calculated. --- Orange/widgets/utils/owlearnerwidget.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/utils/owlearnerwidget.py b/Orange/widgets/utils/owlearnerwidget.py index 8b9e5a44af7..02028917b03 100644 --- a/Orange/widgets/utils/owlearnerwidget.py +++ b/Orange/widgets/utils/owlearnerwidget.py @@ -199,6 +199,16 @@ def settings_changed(self, *args, **kwargs): self.Warning.outdated_learner(shown=not self.auto_apply) self.apply() + def _change_name(self, instance, signal_name): + if instance: + instance.name = self.learner_name + if self.auto_apply: + self.send(signal_name, instance) + + def learner_name_changed(self): + self._change_name(self.learner, "Learner") + self._change_name(self.model, self.OUTPUT_MODEL_NAME) + def send_report(self): self.report_items((("Name", self.learner_name),)) @@ -227,7 +237,7 @@ def add_learner_name_widget(self): self.name_line_edit = gui.lineEdit( self.controlArea, self, 'learner_name', box='Name', tooltip='The name will identify this model in other widgets', - orientation=Qt.Horizontal, callback=lambda: self.apply()) + orientation=Qt.Horizontal, callback=self.learner_name_changed) def add_bottom_buttons(self): box = gui.hBox(self.controlArea, True)