Skip to content

Commit

Permalink
Fix setting migration
Browse files Browse the repository at this point in the history
  • Loading branch information
markotoplak committed Mar 24, 2023
1 parent 5e5bef3 commit aea2291
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 14 additions & 2 deletions Orange/widgets/data/owcontinuize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions Orange/widgets/data/tests/test_owcontinuize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -773,21 +773,21 @@ 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)
self.assertEqual(widget.disc_var_hints[DefaultKey], Continuize.Remove)

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,
Expand Down

0 comments on commit aea2291

Please sign in to comment.