@@ -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,21 @@ 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+
100+
101+
69102 def test_add_row_with_data (self ):
70103 param = Parameter ("a" , 3 , True , 2 , False , 4 )
71104 self ._widget ._add_row (param )
@@ -282,18 +315,18 @@ def test_parameters_combo(self):
282315 def test_function_combo (self ):
283316 combo = self .widget .controls ._function
284317 model = combo .model ()
285- self .assertEqual (model .rowCount (), 44 )
318+ self .assertEqual (model .rowCount (), 46 )
286319 self .assertEqual (combo .currentText (), "Select Function" )
287320
288321 self .send_signal (self .widget .Inputs .data , self .housing )
289- self .assertEqual (model .rowCount (), 44 )
322+ self .assertEqual (model .rowCount (), 46 )
290323 self .assertEqual (combo .currentText (), "Select Function" )
291324 simulate .combobox_activate_index (combo , 1 )
292325 self .assertEqual (self .widget ._OWCurveFit__expression_edit .text (),
293326 "abs()" )
294327
295328 self .send_signal (self .widget .Inputs .data , None )
296- self .assertEqual (model .rowCount (), 44 )
329+ self .assertEqual (model .rowCount (), 46 )
297330 self .assertEqual (combo .currentText (), "Select Function" )
298331
299332 def test_expression (self ):
0 commit comments