Repository: biolab/orange3

Issue:
Widgets that use DomainContextHandler without settings to match
The following widgets use domain context handlers but provide no settings to match, so they reuse the same context setting, in effect degrading these settings to non-context. Fixes should be trivial.

- Table uses `DomainContextHandler` but has no context settings. I suppose we just remove the handler and nothing will change in the widget's behaviour.
- PCA has a context setting of type bool, but not other context settings, so all context match and the setting behaves as if it was a non-context setting. I believe we intended this setting to be domain-dependent, but this would require a `PerfectDomainContextHandler`. But latter requires a perfect match, so the setting would reset at any small change. I suppose we should remove contexts in this widget, to prevent unexpected behaviour. This also keeps the current behaviour.

The following two are already being fixed:

- Correspondence analysis' context setting is a list of indices. But this widget is being refactored anyway.
- Pythagorean tree and forests are being fixed in #4656.

See also #4664, where the problem should be addressed differently.


Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owtable.py b/Orange/widgets/data/owtable.py
--- a/Orange/widgets/data/owtable.py
+++ b/Orange/widgets/data/owtable.py
@@ -32,7 +32,7 @@
 from Orange.statistics import basic_stats
 
 from Orange.widgets import gui
-from Orange.widgets.settings import Setting, DomainContextHandler
+from Orange.widgets.settings import Setting
 from Orange.widgets.utils.widgetpreview import WidgetPreview
 from Orange.widgets.widget import OWWidget, Input, Output
 from Orange.widgets.utils import datacaching
@@ -425,8 +425,6 @@ class Outputs:
     auto_commit = Setting(True)
 
     color_by_class = Setting(True)
-    settingsHandler = DomainContextHandler(
-        match_values=DomainContextHandler.MATCH_VALUES_ALL)
     selected_rows = Setting([], schema_only=True)
     selected_cols = Setting([], schema_only=True)
 
@@ -493,7 +491,6 @@ def sizeHint():
     @Inputs.data
     def set_dataset(self, data, tid=None):
         """Set the input dataset."""
-        self.closeContext()
         if data is not None:
             datasetname = getattr(data, "name", "Data")
             if tid in self._inputs:
@@ -560,7 +557,6 @@ def update(_):
                 self.set_info(current.input_slot.summary)
 
         self.tabs.tabBar().setVisible(self.tabs.count() > 1)
-        self.openContext(data)
 
         if data and self.__pending_selected_rows is not None:
             self.selected_rows = self.__pending_selected_rows
diff --git a/Orange/widgets/unsupervised/owpca.py b/Orange/widgets/unsupervised/owpca.py
--- a/Orange/widgets/unsupervised/owpca.py
+++ b/Orange/widgets/unsupervised/owpca.py
@@ -35,12 +35,10 @@ class Outputs:
         components = Output("Components", Table)
         pca = Output("PCA", PCA, dynamic=False)
 
-    settingsHandler = settings.DomainContextHandler()
-
     ncomponents = settings.Setting(2)
     variance_covered = settings.Setting(100)
     auto_commit = settings.Setting(True)
-    normalize = settings.ContextSetting(True)
+    normalize = settings.Setting(True)
     maxp = settings.Setting(20)
     axis_labels = settings.Setting(10)
 
@@ -113,7 +111,6 @@ def __init__(self):
 
     @Inputs.data
     def set_data(self, data):
-        self.closeContext()
         self.clear_messages()
         self.clear()
         self.information()
@@ -136,7 +133,6 @@ def set_data(self, data):
                 self.clear_outputs()
                 return
 
-        self.openContext(data)
         self._init_projector()
 
         self.data = data


Test patch: