55from Orange .data import Table
66from Orange .widgets .data .owdatasampler import OWDataSampler
77from Orange .widgets .tests .base import WidgetTest
8+ from Orange .widgets .utils .state_summary import format_summary_details
89
910
1011class TestOWDataSampler (WidgetTest ):
@@ -38,7 +39,6 @@ def test_stratified_on_unbalanced_data(self):
3839 self .assertTrue (self .widget .Warning .could_not_stratify .is_shown ())
3940
4041 def test_bootstrap (self ):
41- output_sum = self .widget .info .set_output_summary = Mock ()
4242 self .select_sampling_type (self .widget .Bootstrap )
4343
4444 self .send_signal ("Data" , self .iris )
@@ -59,20 +59,16 @@ def test_bootstrap(self):
5959 # high probability (1-(1/150*2/150*...*150/150) ~= 1-2e-64)
6060 self .assertGreater (len (in_sample ), 0 )
6161 self .assertGreater (len (in_remaining ), 0 )
62- #Check if status bar shows correct number of output data
63- output_sum .assert_called_with (str (len (sample )))
6462
6563 def select_sampling_type (self , sampling_type ):
6664 buttons = self .widget .controls .sampling_type .group .buttons ()
6765 buttons [sampling_type ].click ()
6866
6967 def test_no_intersection_in_outputs (self ):
7068 """ Check whether outputs intersect and whether length of outputs sums
71- to length of original data and
72- if status bar displays correct output for each sampling type"""
69+ to length of original data"""
7370 self .send_signal ("Data" , self .iris )
7471 w = self .widget
75- output_sum = self .widget .info .set_output_summary = Mock ()
7672 sampling_types = [w .FixedProportion , w .FixedSize , w .CrossValidation ]
7773
7874 for replicable in [True , False ]:
@@ -87,7 +83,6 @@ def test_no_intersection_in_outputs(self):
8783 other = self .get_output ("Remaining Data" )
8884 self .assertEqual (len (self .iris ), len (sample ) + len (other ))
8985 self .assertNoIntersection (sample , other )
90- output_sum .assert_called_with (str (len (sample )))
9186
9287 def test_bigger_size_with_replacement (self ):
9388 """Allow bigger output without replacement."""
@@ -126,17 +121,23 @@ def test_shuffling(self):
126121
127122 def test_summary (self ):
128123 """Check if status bar is updated when data is received"""
129- input_sum = self .widget .info .set_input_summary = Mock ()
130124 data = self .iris
125+ input_sum = self .widget .info .set_input_summary = Mock ()
126+ output_sum = self .widget .info .set_output_summary = Mock ()
131127
132- input_sum .reset_mock ()
133- self .send_signal (self .widget .Inputs .data , data [:])
134- input_sum .assert_called_with ("150" )
128+ self .send_signal (self .widget .Inputs .data , data )
129+ input_sum .assert_called_with (len (data ), format_summary_details (data ))
130+ output = self .get_output (self .widget .Outputs .data_sample )
131+ output_sum .assert_called_with (len (output ),
132+ format_summary_details (output ))
135133
136134 input_sum .reset_mock ()
135+ output_sum .reset_mock ()
137136 self .send_signal (self .widget .Inputs .data , None )
138137 input_sum .assert_called_once ()
139138 self .assertEqual (input_sum .call_args [0 ][0 ].brief , "" )
139+ output_sum .assert_called_once ()
140+ self .assertEqual (output_sum .call_args [0 ][0 ].brief , "" )
140141
141142 def set_fixed_sample_size (self , sample_size , with_replacement = False ):
142143 """Set fixed sample size and return the number of gui spin.
0 commit comments