Skip to content

Commit

Permalink
Correlations: Save selection as collection of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Feb 18, 2019
1 parent c41be63 commit c0cb43e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Orange/widgets/data/owcorrelations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from Orange.widgets import gui
from Orange.widgets.settings import Setting, ContextSetting, \
DomainContextHandler
from Orange.widgets.utils import vartype
from Orange.widgets.utils.itemmodels import DomainModel
from Orange.widgets.utils.signals import Input, Output
from Orange.widgets.utils.widgetpreview import WidgetPreview
Expand Down Expand Up @@ -195,6 +196,7 @@ class Outputs:

want_control_area = False

settings_version = 2
settingsHandler = DomainContextHandler()
selection = ContextSetting(())
feature = ContextSetting(None)
Expand Down Expand Up @@ -248,7 +250,7 @@ def _feature_combo_changed(self):
self.apply()

def _vizrank_selection_changed(self, *args):
self.selection = args
self.selection = [(var.name, vartype(var)) for var in args]
self.commit()

def _vizrank_stopped(self):
Expand All @@ -260,7 +262,7 @@ def _vizrank_select(self):
return
selection = QItemSelection()
if self.selection:
sel_names = sorted(x.name for x in self.selection)
sel_names = sorted(name for name, _ in self.selection)
for i in range(model.rowCount()):
# pylint: disable=protected-access
names = sorted(x.name for x in model.data(
Expand Down Expand Up @@ -333,14 +335,21 @@ def commit(self):

self.Outputs.data.send(self.data)
# data has been imputed; send original attributes
self.Outputs.features.send(AttributeList([attr.compute_value.variable
for attr in self.selection]))
self.Outputs.features.send(AttributeList(
[self.data.domain[name] for name, _ in self.selection]))
self.Outputs.correlations.send(corr_table)

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

@classmethod
def migrate_context(cls, context, version):
if version < 2:
sel = context.values["selection"]
context.values["selection"] = ([(var.name, vartype(var))
for var in sel[0]], sel[1])


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

0 comments on commit c0cb43e

Please sign in to comment.