Skip to content

Commit 3119631

Browse files
committed
Correlations: Save selection as collection of strings
1 parent 27d1895 commit 3119631

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Orange/widgets/data/owcorrelations.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from Orange.widgets import gui
2020
from Orange.widgets.settings import Setting, ContextSetting, \
2121
DomainContextHandler
22+
from Orange.widgets.utils import vartype
2223
from Orange.widgets.utils.itemmodels import DomainModel
2324
from Orange.widgets.utils.signals import Input, Output
2425
from Orange.widgets.utils.widgetpreview import WidgetPreview
@@ -195,6 +196,7 @@ class Outputs:
195196

196197
want_control_area = False
197198

199+
settings_version = 2
198200
settingsHandler = DomainContextHandler()
199201
selection = ContextSetting(())
200202
feature = ContextSetting(None)
@@ -248,7 +250,7 @@ def _feature_combo_changed(self):
248250
self.apply()
249251

250252
def _vizrank_selection_changed(self, *args):
251-
self.selection = args
253+
self.selection = [(var.name, vartype(var)) for var in args]
252254
self.commit()
253255

254256
def _vizrank_stopped(self):
@@ -260,7 +262,7 @@ def _vizrank_select(self):
260262
return
261263
selection = QItemSelection()
262264
if self.selection:
263-
sel_names = sorted(x.name for x in self.selection)
265+
sel_names = sorted(name for name, _ in self.selection)
264266
for i in range(model.rowCount()):
265267
# pylint: disable=protected-access
266268
names = sorted(x.name for x in model.data(
@@ -333,14 +335,21 @@ def commit(self):
333335

334336
self.Outputs.data.send(self.data)
335337
# data has been imputed; send original attributes
336-
self.Outputs.features.send(AttributeList([attr.compute_value.variable
337-
for attr in self.selection]))
338+
self.Outputs.features.send(AttributeList(
339+
[self.data.domain[name] for name, _ in self.selection]))
338340
self.Outputs.correlations.send(corr_table)
339341

340342
def send_report(self):
341343
self.report_table(CorrelationType.items()[self.correlation_type],
342344
self.vizrank.rank_table)
343345

346+
@classmethod
347+
def migrate_context(cls, context, version):
348+
if version < 2:
349+
sel = context.values["selection"]
350+
context.values["selection"] = ([(var.name, vartype(var))
351+
for var in sel[0]], sel[1])
352+
344353

345354
if __name__ == "__main__": # pragma: no cover
346355
WidgetPreview(OWCorrelations).run(Table("iris"))

0 commit comments

Comments
 (0)