@@ -10,6 +10,7 @@ class TestOWDataSampler(WidgetTest):
1010 def setUpClass (cls ):
1111 super ().setUpClass ()
1212 cls .iris = Table ("iris" )
13+ cls .zoo = Table ("zoo" )
1314
1415 def setUp (self ):
1516 self .widget = self .create_widget (OWDataSampler ) # type: OWDataSampler
@@ -59,3 +60,27 @@ def test_bootstrap(self):
5960 def select_sampling_type (self , sampling_type ):
6061 buttons = self .widget .controls .sampling_type .group .buttons ()
6162 buttons [sampling_type ].click ()
63+
64+ def test_no_intersection_in_outputs (self ):
65+ """ Check whether outputs intersect and whether length of outputs sums
66+ to length of original data """
67+ self .send_signal ("Data" , self .zoo )
68+ w = self .widget
69+ sampling_types = [w .FixedProportion , w .FixedSize , w .CrossValidation ]
70+
71+ for replicable in [True , False ]:
72+ for stratified in [True , False ]:
73+ for sampling_type in sampling_types :
74+ self .widget .cb_seed .setChecked (replicable )
75+ self .widget .cb_stratify .setChecked (stratified )
76+ self .select_sampling_type (sampling_type )
77+ self .widget .commit ()
78+
79+ sample = self .get_output ("Data Sample" )
80+ other = self .get_output ("Remaining Data" )
81+ self .assertEqual (len (self .zoo ), len (sample ) + len (other ))
82+ self .assertNoIntersection (sample , other )
83+
84+ def assertNoIntersection (self , sample , other ):
85+ for inst in sample :
86+ self .assertNotIn (inst , other )
0 commit comments