From fb6bc5b2385e63184d5da68143097228524aaeb8 Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Fri, 2 Dec 2016 13:48:04 +0100 Subject: [PATCH] owrank: Add migrate_settings Fix an error when restoring from a workflow that was saved before widget supported ranking features on data with no class. --- Orange/widgets/data/owrank.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Orange/widgets/data/owrank.py b/Orange/widgets/data/owrank.py index d80af86e984..3fddae0149d 100644 --- a/Orange/widgets/data/owrank.py +++ b/Orange/widgets/data/owrank.py @@ -77,6 +77,7 @@ class OWRank(OWWidget): # Header state for discrete/continuous/no_class scores headerState = Setting([None, None, None]) + settings_version = 1 settingsHandler = DomainContextHandler() selected_rows = ContextSetting([]) @@ -688,6 +689,19 @@ def create_scores_table(self, labels): new_table.name = "Feature Scores" return new_table + @classmethod + def migrate_settings(cls, settings, version): + super().migrate_settings(settings, version) + if not version: + # Before fc5caa1e1d716607f1f5c4e0b0be265c23280fa0 + # headerState had length 2 + headerState = settings.get("headerState", None) + if headerState is not None and \ + isinstance(headerState, tuple) and \ + len(headerState) < 3: + headerState = (list(headerState) + [None] * 3)[:3] + settings["headerState"] = headerState + class ScoreValueItem(QStandardItem): """A StandardItem subclass for python objects.