Skip to content

Commit ec907c7

Browse files
committed
owpca: Use migrate_settings to fixup invalid variance_covered
`variance_covered` was persisted as a NaN value (gh-1897), causing a TypeError in the widget's `__init__`.
1 parent c0b5deb commit ec907c7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Orange/widgets/unsupervised/owpca.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numbers
2+
13
from AnyQt.QtWidgets import QFormLayout, QLineEdit
24
from AnyQt.QtGui import QColor
35
from AnyQt.QtCore import Qt, QTimer
@@ -409,6 +411,20 @@ def send_report(self):
409411
))
410412
self.report_plot()
411413

414+
@classmethod
415+
def migrate_settings(cls, settings, version):
416+
if "variance_covered" in settings:
417+
# Due to the error in gh-1896 the variance_covered was persisted
418+
# as a NaN value, causing a TypeError in the widgets `__init__`.
419+
vc = settings["variance_covered"]
420+
if isinstance(vc, numbers.Real):
421+
if numpy.isfinite(vc):
422+
vc = int(vc)
423+
else:
424+
vc = 100
425+
settings["variance_covered"] = vc
426+
427+
412428
def main():
413429
import gc
414430
from AnyQt.QtWidgets import QApplication

0 commit comments

Comments
 (0)