Skip to content

Commit

Permalink
owtestlearners: Replace use of setBlocking with output invalidation
Browse files Browse the repository at this point in the history
Allow interruption on input change
  • Loading branch information
ales-erjavec committed Oct 11, 2019
1 parent 6ea45b7 commit 35de1f0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Orange/widgets/evaluate/owtestlearners.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def set_learner(self, learner, key):
learner : Optional[Orange.base.Learner]
key : Any
"""
self.cancel()
if key in self.learners and learner is None:
# Removed
self._invalidate([key])
Expand All @@ -327,6 +328,7 @@ def set_train_data(self, data):
----------
data : Optional[Orange.data.Table]
"""
self.cancel()
self.Information.data_sampled.clear()
self.Error.train_data_empty.clear()
self.Error.class_required.clear()
Expand Down Expand Up @@ -390,6 +392,7 @@ def set_test_data(self, data):
----------
data : Optional[Orange.data.Table]
"""
self.cancel()
self.Information.test_data_sampled.clear()
self.Error.test_data_empty.clear()
if data is not None and not data:
Expand Down Expand Up @@ -445,11 +448,13 @@ def set_preprocessor(self, preproc):
"""
Set the input preprocessor to apply on the training data.
"""
self.cancel()
self.preprocessor = preproc
self._invalidate()

def handleNewSignals(self):
"""Reimplemented from OWWidget.handleNewSignals."""
self.cancel()
self._update_class_selection()
self.score_table.update_header(self.scorers)
self.update_stats_model()
Expand Down Expand Up @@ -814,8 +819,9 @@ def progress_callback(finished):
task.progress_changed.connect(self.setProgressValue)
task.watcher.finished.connect(self.__task_complete)

self.Outputs.evaluations_results.invalidate()
self.Outputs.predictions.invalidate()
self.progressBarInit()
self.setBlocking(True)
self.setStatusMessage("Running")

self.__state = State.Running
Expand All @@ -826,7 +832,6 @@ def __task_complete(self, result: 'Future[Results]'):
# handle a completed task
assert self.thread() is QThread.currentThread()
assert self.__task is not None and self.__task.future is result
self.setBlocking(False)
self.progressBarFinished()
self.setStatusMessage("")
assert result.done()
Expand Down Expand Up @@ -878,7 +883,6 @@ def cancel(self):
task.cancel()
task.progress_changed.disconnect(self.setProgressValue)
task.watcher.finished.disconnect(self.__task_complete)
# self.setBlocking(False)
self.progressBarFinished()

def onDeleteWidget(self):
Expand Down

0 comments on commit 35de1f0

Please sign in to comment.