File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Orange/widgets/unsupervised Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ def __launch_tasks(self, ks):
316316 self ._compute_clustering ,
317317 data = self .data ,
318318 k = k ,
319- init = ['random' , ' k-means++' ][self .smart_init ],
319+ init = ['k-means++' , 'random ' ][self .smart_init ],
320320 n_init = self .n_init ,
321321 max_iter = self .max_iterations ,
322322 silhouette = True ,
Original file line number Diff line number Diff line change @@ -411,6 +411,21 @@ def test_do_not_recluster_on_same_data(self):
411411 self .commit_and_wait ()
412412 self .assertEqual (call_count + 1 , commit .call_count )
413413
414+ def test_correct_smart_init (self ):
415+ # due to a bug where wrong init was passed to _compute_clustering
416+ self .send_signal (self .widget .Inputs .data , self .iris [::10 ], wait = 5000 )
417+ self .widget .smart_init = 0
418+ with patch .object (self .widget , "_compute_clustering" ,
419+ wraps = self .widget ._compute_clustering ) as compute :
420+ self .commit_and_wait ()
421+ self .assertEqual (compute .call_args [1 ]['init' ], "k-means++" )
422+ self .widget .invalidate () # reset caches
423+ self .widget .smart_init = 1
424+ with patch .object (self .widget , "_compute_clustering" ,
425+ wraps = self .widget ._compute_clustering ) as compute :
426+ self .commit_and_wait ()
427+ self .assertEqual (compute .call_args [1 ]['init' ], "random" )
428+
414429
415430if __name__ == "__main__" :
416431 unittest .main ()
You can’t perform that action at this time.
0 commit comments