@@ -26,6 +26,8 @@ def setUpClass(cls):
2626 cls .signal_data = cls .distances
2727 cls .same_input_output_domain = False
2828
29+ cls .distances_cols = Euclidean (cls .data , axis = 0 )
30+
2931 def setUp (self ):
3032 self .widget = self .create_widget (OWHierarchicalClustering )
3133
@@ -35,6 +37,11 @@ def _select_data(self):
3537 self .widget .dendrogram .set_selected_items ([cluster ])
3638 return [14 , 15 , 32 , 33 ]
3739
40+ def _select_data_columns (self ):
41+ items = self .widget .dendrogram ._items
42+ cluster = items [sorted (list (items .keys ()))[5 ]]
43+ self .widget .dendrogram .set_selected_items ([cluster ])
44+
3845 def _compare_selected_annotated_domains (self , selected , annotated ):
3946 self .assertEqual (annotated .domain .variables ,
4047 selected .domain .variables )
@@ -170,3 +177,17 @@ def test_restore_state(self):
170177 self .send_signal (w .Inputs .distances , self .distances , widget = w )
171178 ids_2 = self .get_output (w .Outputs .selected_data , widget = w ).ids
172179 self .assertSequenceEqual (list (ids_1 ), list (ids_2 ))
180+
181+ def test_column_distances (self ):
182+ self .send_signal (self .widget .Inputs .distances , self .distances_cols )
183+ self ._select_data_columns ()
184+ o = self .get_output (self .widget .Outputs .annotated_data )
185+ annotated = [(a .name , a .attributes ['cluster' ]) for a in o .domain .attributes ]
186+ self .assertEqual (annotated , [('sepal width' , 1 ), ('petal length' , 1 ),
187+ ('sepal length' , 0 ), ('petal width' , 0 )])
188+
189+ self .widget .selection_box .buttons [2 ].click () # top N
190+ o = self .get_output (self .widget .Outputs .annotated_data )
191+ annotated = [(a .name , a .attributes ['cluster' ]) for a in o .domain .attributes ]
192+ self .assertEqual (annotated , [('sepal length' , 1 ), ('petal width' , 2 ),
193+ ('sepal width' , 3 ), ('petal length' , 3 )])
0 commit comments