44
55import numpy as np
66
7- from Orange .data import Table
7+ from Orange .data import Table , Domain
8+ from Orange import distance
89from Orange .widgets .unsupervised .owdistances import OWDistances , METRICS
910from Orange .widgets .tests .base import WidgetTest
1011
@@ -32,8 +33,9 @@ def test_distance_combo(self):
3233 else :
3334 expected = metric (self .iris )
3435
35- np .testing .assert_array_equal (
36- expected , self .get_output (self .widget .Outputs .distances ))
36+ if metric is not distance .Jaccard :
37+ np .testing .assert_array_equal (
38+ expected , self .get_output (self .widget .Outputs .distances ))
3739
3840 def test_error_message (self ):
3941 """Check if error message appears and then disappears when
@@ -46,6 +48,36 @@ def test_error_message(self):
4648 self .send_signal (self .widget .Inputs .data , None )
4749 self .assertFalse (self .widget .Error .no_continuous_features .is_shown ())
4850
51+ def test_jaccard_messages (self ):
52+ for self .widget .metric_idx , (name , _ ) in enumerate (METRICS ):
53+ if name == "Jaccard" :
54+ break
55+ self .send_signal (self .widget .Inputs .data , self .iris )
56+ self .assertTrue (self .widget .Error .no_binary_features .is_shown ())
57+ self .assertFalse (self .widget .Warning .ignoring_nonbinary .is_shown ())
58+
59+ self .send_signal (self .widget .Inputs .data , None )
60+ self .assertFalse (self .widget .Error .no_binary_features .is_shown ())
61+ self .assertFalse (self .widget .Warning .ignoring_nonbinary .is_shown ())
62+
63+ self .send_signal (self .widget .Inputs .data , self .titanic )
64+ self .assertFalse (self .widget .Error .no_binary_features .is_shown ())
65+ self .assertTrue (self .widget .Warning .ignoring_nonbinary .is_shown ())
66+
67+ self .send_signal (self .widget .Inputs .data , None )
68+ self .assertFalse (self .widget .Error .no_binary_features .is_shown ())
69+ self .assertFalse (self .widget .Warning .ignoring_nonbinary .is_shown ())
70+
71+ self .send_signal (self .widget .Inputs .data , self .titanic )
72+ self .assertFalse (self .widget .Error .no_binary_features .is_shown ())
73+ self .assertTrue (self .widget .Warning .ignoring_nonbinary .is_shown ())
74+
75+ dom = self .titanic .domain
76+ dom = Domain (dom .attributes [1 :], dom .class_var )
77+ self .send_signal (self .widget .Inputs .data , self .titanic .transform (dom ))
78+ self .assertFalse (self .widget .Error .no_binary_features .is_shown ())
79+ self .assertFalse (self .widget .Warning .ignoring_nonbinary .is_shown ())
80+
4981 def test_too_big_array (self ):
5082 """
5183 Users sees an error message when calculating too large arrays and Orange
0 commit comments