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 22, 2019
1 parent 39bcd3d commit daa333c
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 @@ -20,6 +20,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 @@ -196,6 +197,7 @@ class Outputs:

want_control_area = False

settings_version = 2
settingsHandler = DomainContextHandler()
selection = ContextSetting(())
feature = ContextSetting(None)
Expand Down Expand Up @@ -249,7 +251,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 @@ -265,7 +267,7 @@ def _vizrank_select(self):
# filtered by a feature and therefore selection could not be found
selection_in_model = False
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 @@ -339,14 +341,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 daa333c

Please sign in to comment.