diff --git a/Orange/widgets/data/owcontinuize.py b/Orange/widgets/data/owcontinuize.py index f8a355741a8..fe36fbdf6af 100644 --- a/Orange/widgets/data/owcontinuize.py +++ b/Orange/widgets/data/owcontinuize.py @@ -733,10 +733,22 @@ def migrate_settings(cls, settings, version): settings["cont_var_hints"] = \ {DefaultKey: settings.pop("continuous_treatment", Normalize.Leave)} + + # DISC OPS: Default=99, Indicators=1, FirstAsBase=2, FrequentAsBase=3, Remove=4, + # RemoveMultinomial=5, ReportError=6, AsOrdinal=7, AsNormalizedOrdinal=8, Leave=9 + + # OLD ORDER: [FirstAsBase, FrequentAsBase, Indicators, RemoveMultinomial, Remove, + # AsOrdinal, AsNormalizedOrdinal] + old_to_new = [2, 3, 1, 5, 4, 7, 8] + settings["disc_var_hints"] = \ {DefaultKey: - settings.pop("multinomial_treatment", Continuize.FirstAsBase)} - class_treatment = settings.pop("class_treatment", Continuize.Leave) + old_to_new[settings.pop("multinomial_treatment", 0)]} + + # OLD ORDER: [Leave, AsOrdinal, AsNormalizedOrdinal, Indicators] + old_to_new = [9, 7, 8, 1] + + class_treatment = old_to_new[settings.pop("class_treatment", 0)] if class_treatment != Continuize.Leave: settings["disc_var_hints"][BackCompatClass] = class_treatment diff --git a/Orange/widgets/data/tests/test_owcontinuize.py b/Orange/widgets/data/tests/test_owcontinuize.py index 8613e60667b..af84bd1d526 100644 --- a/Orange/widgets/data/tests/test_owcontinuize.py +++ b/Orange/widgets/data/tests/test_owcontinuize.py @@ -760,7 +760,7 @@ def test_migrate_settings_to_v3(self): widget = self.create_widget( OWContinuize, - stored_settings=dict(multinomial_treatment=Continuize.Indicators) + stored_settings=dict(multinomial_treatment=2) ) self.assertEqual(widget.disc_var_hints[DefaultKey], Continuize.Indicators) @@ -773,8 +773,8 @@ def test_migrate_settings_to_v3_class_treatment(self): widget = self.create_widget( OWContinuize, - stored_settings=dict(multinomial_treatment=Continuize.Remove, - class_treatment=Continuize.Indicators) + stored_settings=dict(multinomial_treatment=4, + class_treatment=3) ) self.send_signal(widget.Inputs.data, data) self.assertEqual(widget.disc_var_hints["y"], Continuize.Indicators) @@ -782,12 +782,12 @@ def test_migrate_settings_to_v3_class_treatment(self): widget = self.create_widget( OWContinuize, - stored_settings=dict(multinomial_treatment=Continuize.Remove, - class_treatment=Continuize.Leave) + stored_settings=dict(multinomial_treatment=4, + class_treatment=0) ) self.send_signal(widget.Inputs.data, data) self.assertNotIn("y", widget.disc_var_hints) - self.assertEqual(widget.disc_var_hints[DefaultKey], Continuize.Remove) + self.assertEqual(widget.disc_var_hints[DefaultKey], 4) widget = self.create_widget( OWContinuize,