2020from Orange .widgets import gui
2121from Orange .widgets .settings import Setting , ContextSetting , \
2222 DomainContextHandler
23+ from Orange .widgets .utils import vartype
2324from Orange .widgets .utils .itemmodels import DomainModel
2425from Orange .widgets .utils .signals import Input , Output
2526from Orange .widgets .utils .widgetpreview import WidgetPreview
@@ -196,6 +197,7 @@ class Outputs:
196197
197198 want_control_area = False
198199
200+ settings_version = 2
199201 settingsHandler = DomainContextHandler ()
200202 selection = ContextSetting (())
201203 feature = ContextSetting (None )
@@ -249,7 +251,7 @@ def _feature_combo_changed(self):
249251 self .apply ()
250252
251253 def _vizrank_selection_changed (self , * args ):
252- self .selection = args
254+ self .selection = [( var . name , vartype ( var )) for var in args ]
253255 self .commit ()
254256
255257 def _vizrank_stopped (self ):
@@ -265,7 +267,7 @@ def _vizrank_select(self):
265267 # filtered by a feature and therefore selection could not be found
266268 selection_in_model = False
267269 if self .selection :
268- sel_names = sorted (x . name for x in self .selection )
270+ sel_names = sorted (name for name , _ in self .selection )
269271 for i in range (model .rowCount ()):
270272 # pylint: disable=protected-access
271273 names = sorted (x .name for x in model .data (
@@ -339,14 +341,21 @@ def commit(self):
339341
340342 self .Outputs .data .send (self .data )
341343 # data has been imputed; send original attributes
342- self .Outputs .features .send (AttributeList ([ attr . compute_value . variable
343- for attr in self .selection ]))
344+ self .Outputs .features .send (AttributeList (
345+ [ self . data . domain [ name ] for name , _ in self .selection ]))
344346 self .Outputs .correlations .send (corr_table )
345347
346348 def send_report (self ):
347349 self .report_table (CorrelationType .items ()[self .correlation_type ],
348350 self .vizrank .rank_table )
349351
352+ @classmethod
353+ def migrate_context (cls , context , version ):
354+ if version < 2 :
355+ sel = context .values ["selection" ]
356+ context .values ["selection" ] = ([(var .name , vartype (var ))
357+ for var in sel [0 ]], sel [1 ])
358+
350359
351360if __name__ == "__main__" : # pragma: no cover
352361 WidgetPreview (OWCorrelations ).run (Table ("iris" ))
0 commit comments