1
1
import unittest
2
2
import numpy as np
3
3
4
+ from AnyQt .QtTest import QSignalSpy
5
+
4
6
from Orange .data import DiscreteVariable , ContinuousVariable , Domain , Table
5
7
from Orange .preprocess import Preprocess
6
8
from Orange .projection .manifold import TSNE
@@ -39,7 +41,8 @@ def optimize(*_, **__):
39
41
owtsne .TSNEModel .transform = transform
40
42
owtsne .TSNEModel .optimize = optimize
41
43
42
- self .widget = self .create_widget (OWtSNE )
44
+ self .widget = self .create_widget (OWtSNE ,
45
+ stored_settings = {"multiscale" : False })
43
46
44
47
self .class_var = DiscreteVariable ('Stage name' , values = ['STG1' , 'STG2' ])
45
48
self .attributes = [ContinuousVariable ('GeneName' + str (i )) for i in range (5 )]
@@ -110,7 +113,11 @@ def test_attr_models(self):
110
113
self .assertIn (var , controls .attr_shape .model ())
111
114
112
115
def test_output_preprocessor (self ):
116
+ self .reset_tsne ()
113
117
self .send_signal (self .widget .Inputs .data , self .data )
118
+ if self .widget .isBlocking ():
119
+ spy = QSignalSpy (self .widget .blockingStateChanged )
120
+ self .assertTrue (spy .wait (20000 ))
114
121
pp = self .get_output (self .widget .Outputs .preprocessor )
115
122
self .assertIsInstance (pp , Preprocess )
116
123
transformed = pp (self .data )
@@ -123,15 +130,15 @@ def test_output_preprocessor(self):
123
130
[m .name for m in output .domain .metas [:2 ]])
124
131
125
132
def test_multiscale_changed (self ):
126
- self .assertTrue (self .widget .controls .multiscale .isChecked ())
127
- self .assertFalse (self .widget .perplexity_spin .isEnabled ())
128
- self .widget .controls .multiscale .setChecked (False )
133
+ self .assertFalse (self .widget .controls .multiscale .isChecked ())
129
134
self .assertTrue (self .widget .perplexity_spin .isEnabled ())
135
+ self .widget .controls .multiscale .setChecked (True )
136
+ self .assertFalse (self .widget .perplexity_spin .isEnabled ())
130
137
131
138
settings = self .widget .settingsHandler .pack_data (self .widget )
132
139
w = self .create_widget (OWtSNE , stored_settings = settings )
133
- self .assertFalse (w .controls .multiscale .isChecked ())
134
- self .assertTrue (w .perplexity_spin .isEnabled ())
140
+ self .assertTrue (w .controls .multiscale .isChecked ())
141
+ self .assertFalse (w .perplexity_spin .isEnabled ())
135
142
136
143
137
144
if __name__ == '__main__' :
0 commit comments