Skip to content

Commit

Permalink
Merge pull request biolab#2901 from pavlin-policar/kmeans-threading
Browse files Browse the repository at this point in the history
OWKMeans: Perform clustering in worker threads
  • Loading branch information
ajdapretnar authored Feb 23, 2018
2 parents 2d36c57 + ee4816f commit 8002eb2
Show file tree
Hide file tree
Showing 3 changed files with 373 additions and 160 deletions.
36 changes: 35 additions & 1 deletion Orange/widgets/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,41 @@ def send_signal(self, input, value, *args, widget=None, wait=-1):
spy = QSignalSpy(widget.blockingStateChanged)
self.assertTrue(spy.wait(timeout=wait))

def wait_until_stop_blocking(self, widget=None, wait=1000):
"""Wait until the widget stops blocking i.e. finishes computation.
Parameters
----------
widget : Optional[OWWidget]
widget to send signal to. If not set, self.widget is used
wait : int
The amount of time to wait for the widget to complete.
"""
if widget is None:
widget = self.widget

if widget.isBlocking():
spy = QSignalSpy(widget.blockingStateChanged)
self.assertTrue(spy.wait(timeout=wait))

def commit_and_wait(self, widget=None, wait=1000):
"""Unconditinal commit and wait to stop blocking if needed.
Parameters
----------
widget : Optional[OWWidget]
widget to send signal to. If not set, self.widget is used
wait : int
The amount of time to wait for the widget to complete.
"""
if widget is None:
widget = self.widget

widget.unconditional_commit()
self.wait_until_stop_blocking(widget=widget, wait=wait)

def get_output(self, output, widget=None, wait=5000):
"""Return the last output that has been sent from the widget.
Expand Down Expand Up @@ -274,7 +309,6 @@ def get_output(self, output, widget=None, wait=5000):
"widget {} has no output {}".format(widget.name, output)
return self.signal_manager.outputs.get((widget, output), None)


@contextmanager
def modifiers(self, modifiers):
"""
Expand Down
Loading

0 comments on commit 8002eb2

Please sign in to comment.