@@ -310,37 +310,6 @@ def test_partial_match_values(self):
310310 self .assertEqual (condition [1 ], 2 )
311311 self .assertEqual (condition [2 ], (2 , )) # index of value + 1
312312
313- def test_backward_compat_match_values (self ):
314- iris = Table ("iris" )
315- domain = iris .domain
316- class_var = domain .class_var
317- self .widget = self .widget_with_context (
318- domain , [[class_var .name , 1 , 2 , (1 , 2 )]])
319-
320- new_class_var = DiscreteVariable (class_var .name , class_var .values [1 :])
321- new_domain = Domain (domain .attributes , new_class_var )
322- non0 = iris .Y != 0
323- iris2 = Table .from_numpy (new_domain , iris .X [non0 ], iris .Y [non0 ] - 1 )
324- self .send_signal (self .widget .Inputs .data , iris2 )
325- condition = self .widget .conditions [0 ]
326- self .assertIs (condition [0 ], new_class_var )
327- self .assertEqual (condition [1 ], 2 )
328- self .assertEqual (condition [2 ], (1 , 2 )) # index of value + 1
329-
330- # reset to [0] if out of range
331- self .widget = self .widget_with_context (
332- domain , [[class_var .name , 1 , 2 , (1 , 3 )]])
333-
334- new_class_var = DiscreteVariable (class_var .name , class_var .values [1 :])
335- new_domain = Domain (domain .attributes , new_class_var )
336- non0 = iris .Y != 0
337- iris2 = Table .from_numpy (new_domain , iris .X [non0 ], iris .Y [non0 ] - 1 )
338- self .send_signal (self .widget .Inputs .data , iris2 )
339- condition = self .widget .conditions [0 ]
340- self .assertIs (condition [0 ], new_class_var )
341- self .assertEqual (condition [1 ], 2 )
342- self .assertEqual (condition [2 ], (0 , )) # index of value + 1
343-
344313 @override_locale (QLocale .C )
345314 def test_partial_matches_with_missing_vars (self ):
346315 iris = Table ("iris" )
@@ -532,43 +501,15 @@ def test_report(self, _):
532501 self .enterFilter (zoo .domain [1 ], "is one of" )
533502 self .widget .send_report () # don't crash
534503
535- # Uncomment this on 2022/2/2
536- #
537- # def test_migration_to_version_1(self):
538- # iris = Table("iris")
539- #
540- # ch = SelectRowsContextHandler()
541- # context = ch.new_context(iris.domain, *ch.encode_domain(iris.domain))
542- # context.values = dict(conditions=[["petal length", 2, (5.2,)]])
543- # settings = dict(context_settings=[context])
544- # widget = self.create_widget(OWSelectRows, settings)
545- # self.assertEqual(widget.conditions, [])
546-
547- @override_locale (QLocale .C )
548- def test_support_old_settings (self ):
504+ def test_migration_to_version_1 (self ):
549505 iris = Table ("iris" )
550- self .widget = self .widget_with_context (
551- iris .domain , [["sepal length" , 2 , ("5.2" ,)]])
552- self .send_signal (self .widget .Inputs .data , iris )
553- condition = self .widget .conditions [0 ]
554- self .assertEqual (condition [0 ], iris .domain ["sepal length" ])
555- self .assertEqual (condition [1 ], 2 )
556- self .assertTrue (condition [2 ][0 ].startswith ("5.2" ))
557-
558- def test_end_support_for_version_1 (self ):
559- if time .gmtime () >= (2022 , 2 , 2 ):
560- self .fail ("""
561- Happy 22/2/2!
562-
563- Now remove support for version==None settings in
564- SelectRowsContextHandler.decode_setting and SelectRowsContextHandler.match,
565- and uncomment OWSelectRows.migrate.
566-
567- In tests, uncomment test_migration_to_version_1,
568- and remove test_support_old_settings and this test.
569506
570- Basically, revert this commit.
571- """ )
507+ ch = SelectRowsContextHandler ()
508+ context = ch .new_context (iris .domain , * ch .encode_domain (iris .domain ))
509+ context .values = dict (conditions = [["petal length" , 2 , (5.2 ,)]])
510+ settings = dict (context_settings = [context ])
511+ widget = self .create_widget (OWSelectRows , settings )
512+ self .assertEqual (widget .conditions , [])
572513
573514 def test_purge_discretized (self ):
574515 housing = Table ("housing" )
@@ -577,7 +518,9 @@ def test_purge_discretized(self):
577518 discretize_class = True , method = method )
578519 domain = discretizer (housing )
579520 data = housing .transform (domain )
580- widget = self .widget_with_context (domain , [["MEDV" , 101 , 2 , (2 , 3 )]])
521+ widget = self .widget_with_context (
522+ domain , [["MEDV" , 101 , 2 , domain .class_var .values [1 :]]]
523+ )
581524 widget .purge_classes = True
582525 self .send_signal (widget .Inputs .data , data )
583526 out = self .get_output (widget .Outputs .matching_data )
0 commit comments