1010
1111from Orange .data import (
1212 Table , Variable , ContinuousVariable , StringVariable , DiscreteVariable ,
13- Domain )
13+ Domain , TimeVariable )
1414from Orange .preprocess import discretize
1515from Orange .widgets .data import owselectrows
1616from Orange .widgets .data .owselectrows import (
5959 FilterDiscreteType .IsDefined : [],
6060}
6161
62+ TFValues = {
63+ FilterContinuous .Equal : [QDate (2013 , 5 , 5 )],
64+ FilterContinuous .NotEqual : [QDate (2013 , 5 , 5 )],
65+ FilterContinuous .Less : [QDate (2013 , 5 , 5 )],
66+ FilterContinuous .LessEqual : [QDate (2013 , 5 , 5 )],
67+ FilterContinuous .Greater : [QDate (2013 , 5 , 5 )],
68+ FilterContinuous .GreaterEqual : [QDate (2013 , 5 , 5 )],
69+ FilterContinuous .Between : [QDate (2013 , 5 , 5 ), QDate (2015 , 5 , 5 )],
70+ FilterContinuous .Outside : [QDate (2013 , 5 , 5 ), QDate (2015 , 5 , 5 )],
71+ FilterContinuous .IsDefined : [],
72+ }
73+
6274
6375class TestOWSelectRows (WidgetTest ):
6476 def setUp (self ):
@@ -75,6 +87,17 @@ def test_filter_cont(self):
7587 self .widget .conditions_changed ()
7688 self .widget .unconditional_commit ()
7789
90+ # continuous var in metas
91+ iris = Table .from_table (
92+ Domain ([], metas = [iris .domain .attributes [0 ]]), iris
93+ )
94+ self .widget .set_data (iris )
95+ for i , (op , _ ) in enumerate (OWSelectRows .Operators [ContinuousVariable ]):
96+ self .widget .remove_all ()
97+ self .widget .add_row (iris .domain .metas [0 ], i , CFValues [op ])
98+ self .widget .conditions_changed ()
99+ self .widget .unconditional_commit ()
100+
78101 def test_filter_str (self ):
79102 zoo = Table ("zoo" )[::5 ]
80103 self .widget .auto_commit = False
@@ -96,6 +119,39 @@ def test_filter_disc(self):
96119 self .widget .conditions_changed ()
97120 self .widget .unconditional_commit ()
98121
122+ # discrete var in metas
123+ lenses = Table .from_table (
124+ Domain ([], metas = [lenses .domain .attributes [0 ]]), lenses
125+ )
126+ self .widget .set_data (lenses )
127+ for i , (op , _ ) in enumerate (OWSelectRows .Operators [DiscreteVariable ]):
128+ self .widget .remove_all ()
129+ self .widget .add_row (lenses .domain .metas [0 ], i , DFValues [op ])
130+ self .widget .conditions_changed ()
131+ self .widget .unconditional_commit ()
132+
133+ def test_filter_time (self ):
134+ data = Table (test_filename ("datasets/cyber-security-breaches.tab" ))
135+ self .widget .auto_commit = False
136+ self .widget .set_data (data )
137+
138+ for i , (op , _ ) in enumerate (OWSelectRows .Operators [TimeVariable ]):
139+ self .widget .remove_all ()
140+ self .widget .add_row (data .domain ["breach_start" ], i , TFValues [op ])
141+ self .widget .conditions_changed ()
142+ self .widget .unconditional_commit ()
143+
144+ # time var in metas
145+ data = Table .from_table (
146+ Domain ([], metas = [data .domain ["breach_start" ]]), data
147+ )
148+ self .widget .set_data (data )
149+ for i , (op , _ ) in enumerate (OWSelectRows .Operators [TimeVariable ]):
150+ self .widget .remove_all ()
151+ self .widget .add_row (data .domain .metas [0 ], i , TFValues [op ])
152+ self .widget .conditions_changed ()
153+ self .widget .unconditional_commit ()
154+
99155 @override_locale (QLocale .C ) # Locale with decimal point
100156 def test_continuous_filter_with_c_locale (self ):
101157 iris = Table ("iris" )[:5 ]
0 commit comments