Skip to content

Commit

Permalink
Continuize: Tests and small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Feb 18, 2023
1 parent 22bab8a commit d8c0033
Show file tree
Hide file tree
Showing 2 changed files with 471 additions and 86 deletions.
15 changes: 13 additions & 2 deletions Orange/widgets/data/owcontinuize.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MethodDesc(NamedTuple):

DefaultKey = ""
DefaultId = 99

BackCompatClass = object()

Continuize = SimpleNamespace(
Default=DefaultId,
Expand Down Expand Up @@ -460,7 +460,7 @@ def _on_radio_clicked(self, method_id: int):

@Inputs.data
@check_sql_input
def setData(self, data):
def set_data(self, data):
self.data = data
self._var_cache.clear()
domain = data.domain if data else None
Expand All @@ -473,6 +473,14 @@ def setData(self, data):

def _set_hints(self):
assert self.data

# Backward compatibility for settings < 3
class_treatment = self.disc_var_hints.get(BackCompatClass, None)
if class_treatment is not None \
and self.data.domain.class_var is not None:
self.disc_var_hints[self.data.domain.class_var.name] \
= class_treatment

for hints, model, options in (
(self.cont_var_hints, self.cont_view.model(), ContinuousOptions),
(self.disc_var_hints, self.disc_view.model(), DiscreteOptions)):
Expand Down Expand Up @@ -728,6 +736,9 @@ def migrate_settings(cls, settings, version):
settings["disc_var_hints"] = \
{DefaultKey:
settings.pop("multinomial_treatment", Continuize.FirstAsBase)}
class_treatment = settings.pop("class_treatment", Continuize.Leave)
if class_treatment != Continuize.Leave:
settings["disc_var_hints"][BackCompatClass] = class_treatment


# Backward compatibility for unpickling settings
Expand Down
Loading

0 comments on commit d8c0033

Please sign in to comment.