@@ -22,11 +22,29 @@ def test_functions(self):
2222 func = getattr (np , f )
2323 if isinstance (func , float ):
2424 pass
25+ elif f in ["any" , "all" ]:
26+ self .assertTrue (func (a ))
2527 elif f in ["arctan2" , "copysign" , "fmod" , "gcd" , "hypot" ,
2628 "isclose" , "ldexp" , "power" , "remainder" ]:
2729 self .assertIsInstance (func (a , 2 ), np .ndarray )
30+ self .assertEqual (func (a , 2 ).shape , (5 ,))
2831 else :
2932 self .assertIsInstance (func (a ), np .ndarray )
33+ self .assertEqual (func (a ).shape , (5 ,))
34+
35+
36+ class TestParameter (unittest .TestCase ):
37+ def test_to_tuple (self ):
38+ args = ("foo" , 2 , True , 10 , False , 50 )
39+ par = Parameter (* args )
40+ self .assertEqual (par .to_tuple (), args )
41+
42+ def test_repr (self ):
43+ args = ("foo" , 2 , True , 10 , False , 50 )
44+ par = Parameter (* args )
45+ str_par = "Parameter(name=foo, initial=2, use_lower=True, " \
46+ "lower=10, use_upper=False, upper=50)"
47+ self .assertEqual (str (par ), str_par )
3048
3149
3250class TestParametersWidget (WidgetTest ):
@@ -66,6 +84,19 @@ def test_add_row(self):
6684 self .assertFalse (data .use_upper )
6785 self .assertEqual (data .upper , 100 )
6886
87+ def test_remove (self ):
88+ n = 5
89+ for _ in range (n ):
90+ self ._widget ._add_row ()
91+ self .assertEqual (len (self ._widget ._ParametersWidget__data ), n )
92+
93+ k = 2
94+ for _ in range (k ):
95+ button = self ._widget ._ParametersWidget__controls [0 ][0 ]
96+ button .click ()
97+
98+ self .assertEqual (len (self ._widget ._ParametersWidget__data ), n - k )
99+
69100 def test_add_row_with_data (self ):
70101 param = Parameter ("a" , 3 , True , 2 , False , 4 )
71102 self ._widget ._add_row (param )
@@ -165,6 +196,13 @@ def test_input_data_learner_adequacy(self): # overwritten
165196 self .wait_until_stop_blocking ()
166197 self .assertFalse (self .widget .Error .data_error .is_shown ())
167198
199+ def test_input_data_missing (self ):
200+ self .assertTrue (self .widget .Warning .data_missing .is_shown ())
201+ self .send_signal (self .widget .Inputs .data , self .housing )
202+ self .assertFalse (self .widget .Warning .data_missing .is_shown ())
203+ self .send_signal (self .widget .Inputs .data , None )
204+ self .assertTrue (self .widget .Warning .data_missing .is_shown ())
205+
168206 def test_input_preprocessor (self ):
169207 self .__init_widget ()
170208 super ().test_input_preprocessor ()
@@ -282,18 +320,18 @@ def test_parameters_combo(self):
282320 def test_function_combo (self ):
283321 combo = self .widget .controls ._function
284322 model = combo .model ()
285- self .assertEqual (model .rowCount (), 44 )
323+ self .assertEqual (model .rowCount (), 46 )
286324 self .assertEqual (combo .currentText (), "Select Function" )
287325
288326 self .send_signal (self .widget .Inputs .data , self .housing )
289- self .assertEqual (model .rowCount (), 44 )
327+ self .assertEqual (model .rowCount (), 46 )
290328 self .assertEqual (combo .currentText (), "Select Function" )
291329 simulate .combobox_activate_index (combo , 1 )
292330 self .assertEqual (self .widget ._OWCurveFit__expression_edit .text (),
293331 "abs()" )
294332
295333 self .send_signal (self .widget .Inputs .data , None )
296- self .assertEqual (model .rowCount (), 44 )
334+ self .assertEqual (model .rowCount (), 46 )
297335 self .assertEqual (combo .currentText (), "Select Function" )
298336
299337 def test_expression (self ):
0 commit comments