Skip to content

Commit

Permalink
TestOWtSNE: Update
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Dec 18, 2018
1 parent 7bd27f7 commit 2dc706e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Orange/widgets/unsupervised/tests/test_owtsne.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
import numpy as np

from AnyQt.QtTest import QSignalSpy

from Orange.data import DiscreteVariable, ContinuousVariable, Domain, Table
from Orange.preprocess import Preprocess
from Orange.projection.manifold import TSNE
Expand Down Expand Up @@ -39,7 +41,8 @@ def optimize(*_, **__):
owtsne.TSNEModel.transform = transform
owtsne.TSNEModel.optimize = optimize

self.widget = self.create_widget(OWtSNE)
self.widget = self.create_widget(OWtSNE,
stored_settings={"multiscale": False})

self.class_var = DiscreteVariable('Stage name', values=['STG1', 'STG2'])
self.attributes = [ContinuousVariable('GeneName' + str(i)) for i in range(5)]
Expand Down Expand Up @@ -110,7 +113,11 @@ def test_attr_models(self):
self.assertIn(var, controls.attr_shape.model())

def test_output_preprocessor(self):
self.reset_tsne()
self.send_signal(self.widget.Inputs.data, self.data)
if self.widget.isBlocking():
spy = QSignalSpy(self.widget.blockingStateChanged)
self.assertTrue(spy.wait(20000))
pp = self.get_output(self.widget.Outputs.preprocessor)
self.assertIsInstance(pp, Preprocess)
transformed = pp(self.data)
Expand All @@ -123,15 +130,15 @@ def test_output_preprocessor(self):
[m.name for m in output.domain.metas[:2]])

def test_multiscale_changed(self):
self.assertTrue(self.widget.controls.multiscale.isChecked())
self.assertFalse(self.widget.perplexity_spin.isEnabled())
self.widget.controls.multiscale.setChecked(False)
self.assertFalse(self.widget.controls.multiscale.isChecked())
self.assertTrue(self.widget.perplexity_spin.isEnabled())
self.widget.controls.multiscale.setChecked(True)
self.assertFalse(self.widget.perplexity_spin.isEnabled())

settings = self.widget.settingsHandler.pack_data(self.widget)
w = self.create_widget(OWtSNE, stored_settings=settings)
self.assertFalse(w.controls.multiscale.isChecked())
self.assertTrue(w.perplexity_spin.isEnabled())
self.assertTrue(w.controls.multiscale.isChecked())
self.assertFalse(w.perplexity_spin.isEnabled())


if __name__ == '__main__':
Expand Down

0 comments on commit 2dc706e

Please sign in to comment.