@@ -56,3 +56,43 @@ def test_selection_box_output(self):
5656 def test_all_zero_inputs (self ):
5757 d = Orange .misc .DistMatrix (numpy .zeros ((10 , 10 )))
5858 self .widget .set_distances (d )
59+
60+ def test_annotation_settings_retrieval (self ):
61+ """Check whether widget retrieves correct settings for annotation"""
62+ widget = self .widget
63+
64+ dist_names = Orange .misc .DistMatrix (
65+ numpy .zeros ((4 , 4 )), self .data , axis = 0 )
66+ dist_no_names = Orange .misc .DistMatrix (numpy .zeros ((10 , 10 )), axis = 1 )
67+
68+ self .send_signal ("Distances" , self .distances )
69+ # Check that default is set (class variable)
70+ self .assertEqual (widget .annotation , self .data .domain .class_var )
71+
72+ var2 = self .data .domain [2 ]
73+ widget .annotation = var2
74+ # Iris now has var2 as annotation
75+
76+ self .send_signal ("Distances" , dist_no_names )
77+ self .assertEqual (widget .annotation , "Enumeration" ) # Check default
78+ widget .annotation = "None"
79+ # Pure matrix with axis=1 now has None as annotation
80+
81+ self .send_signal ("Distances" , self .distances )
82+ self .assertIs (widget .annotation , var2 )
83+ self .send_signal ("Distances" , dist_no_names )
84+ self .assertEqual (widget .annotation , "None" )
85+
86+ self .send_signal ("Distances" , dist_names )
87+ self .assertEqual (widget .annotation , "Name" ) # Check default
88+ widget .annotation = "Enumeration"
89+ # Pure matrix with axis=1 has Enumerate as annotation
90+
91+ self .send_signal ("Distances" , self .distances )
92+ self .assertIs (widget .annotation , var2 )
93+ self .send_signal ("Distances" , dist_no_names )
94+ self .assertEqual (widget .annotation , "None" )
95+ self .send_signal ("Distances" , dist_names )
96+ self .assertEqual (widget .annotation , "Enumeration" )
97+ self .send_signal ("Distances" , dist_no_names )
98+ self .assertEqual (widget .annotation , "None" )
0 commit comments