From c2fc3dae8baf7166ac5462a1d82ff9300786938e Mon Sep 17 00:00:00 2001 From: janezd Date: Sun, 4 Oct 2020 21:10:09 +0200 Subject: [PATCH] Annotate settings in various widgets --- Orange/widgets/data/owcorrelations.py | 5 ++-- Orange/widgets/data/owcreateclass.py | 7 +++--- Orange/widgets/data/owdatasets.py | 2 +- Orange/widgets/data/owmergedata.py | 13 ++++++++++- Orange/widgets/data/owpaintdata.py | 5 ++-- Orange/widgets/data/owpivot.py | 18 +++++++-------- Orange/widgets/data/owrank.py | 12 +++++----- Orange/widgets/data/owselectcolumns.py | 2 +- Orange/widgets/data/owtable.py | 11 +++++---- Orange/widgets/data/owtranspose.py | 4 ++-- .../data/tests/test_owfeaturestatistics.py | 2 +- Orange/widgets/evaluate/owpredictions.py | 4 ++-- Orange/widgets/evaluate/utils.py | 3 ++- .../widgets/unsupervised/owdistancematrix.py | 23 +++++++++++++++---- Orange/widgets/visualize/owbarplot.py | 12 +++++----- Orange/widgets/visualize/owboxplot.py | 11 +++++---- Orange/widgets/visualize/owdistributions.py | 10 ++++---- Orange/widgets/visualize/owheatmap.py | 6 ++--- .../widgets/visualize/owlinearprojection.py | 12 +++++----- Orange/widgets/visualize/owlineplot.py | 11 +++++---- Orange/widgets/visualize/owscatterplot.py | 4 ++-- Orange/widgets/visualize/utils/widget.py | 6 +++-- 22 files changed, 109 insertions(+), 74 deletions(-) diff --git a/Orange/widgets/data/owcorrelations.py b/Orange/widgets/data/owcorrelations.py index 427d6545e83..9d9a4cde897 100644 --- a/Orange/widgets/data/owcorrelations.py +++ b/Orange/widgets/data/owcorrelations.py @@ -5,6 +5,7 @@ from operator import attrgetter from types import SimpleNamespace from itertools import combinations, groupby, chain +from typing import List import numpy as np from scipy.stats import spearmanr, pearsonr @@ -254,8 +255,8 @@ class Outputs: settings_version = 3 settingsHandler = DomainContextHandler() - selection = ContextSetting([]) - feature = ContextSetting(None) + selection: List[ContinuousVariable] = ContextSetting([]) + feature: ContinuousVariable = ContextSetting(None) correlation_type = Setting(0) class Information(OWWidget.Information): diff --git a/Orange/widgets/data/owcreateclass.py b/Orange/widgets/data/owcreateclass.py index 5d704e0739a..52d976b5e77 100644 --- a/Orange/widgets/data/owcreateclass.py +++ b/Orange/widgets/data/owcreateclass.py @@ -1,13 +1,14 @@ """Widget for creating classes from non-numeric attribute by substrings""" import re from itertools import count +from typing import List, Dict import numpy as np from AnyQt.QtWidgets import QGridLayout, QLabel, QLineEdit, QSizePolicy, QWidget from AnyQt.QtCore import QSize, Qt -from Orange.data import StringVariable, DiscreteVariable, Domain +from Orange.data import StringVariable, DiscreteVariable, Domain, Variable from Orange.data.table import Table from Orange.statistics.util import bincount from Orange.preprocess.transformation import Transformation, Lookup @@ -176,9 +177,9 @@ class Outputs: buttons_area_orientation = Qt.Vertical settingsHandler = DomainContextHandler() - attribute = ContextSetting(None) + attribute: Variable = ContextSetting(None) class_name = ContextSetting("class") - rules = ContextSetting({}) + rules: Dict[str, List[List[str]]] = ContextSetting({}) match_beginning = ContextSetting(False) case_sensitive = ContextSetting(False) diff --git a/Orange/widgets/data/owdatasets.py b/Orange/widgets/data/owdatasets.py index caf3cafb5cd..aac0200851c 100644 --- a/Orange/widgets/data/owdatasets.py +++ b/Orange/widgets/data/owdatasets.py @@ -180,7 +180,7 @@ class Outputs: data = Output("Data", Orange.data.Table) #: Selected dataset id - selected_id = settings.Setting(None) # type: Optional[str] + selected_id: Optional[str] = settings.Setting(None) #: main area splitter state splitter_state = settings.Setting(b'') # type: bytes diff --git a/Orange/widgets/data/owmergedata.py b/Orange/widgets/data/owmergedata.py index 7080dea450b..2204ed9e005 100644 --- a/Orange/widgets/data/owmergedata.py +++ b/Orange/widgets/data/owmergedata.py @@ -1,5 +1,6 @@ from collections import namedtuple from itertools import chain, product +from typing import List, Tuple, Dict import numpy as np @@ -7,6 +8,8 @@ from AnyQt.QtWidgets import ( QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout ) + +from orangewidget.settings import Context from orangewidget.utils.combobox import ComboBoxSearch import Orange @@ -173,12 +176,19 @@ def data(self, index, role=Qt.DisplayRole): return super().data(index, role) +class MergeDataContext(Context): + variables1: Dict[str, int] + variables2: Dict[str, int] + + class MergeDataContextHandler(ContextHandler): # `widget` is used as an argument in most methods # pylint: disable=redefined-outer-name # context handlers override methods using different signatures # pylint: disable=arguments-differ + ContextType = MergeDataContext + def new_context(self, variables1, variables2): context = super().new_context() context.variables1 = variables1 @@ -286,7 +296,8 @@ class Outputs: "merging_types")] settingsHandler = MergeDataContextHandler() - attr_pairs = ContextSetting(None, schema_only=True) + attr_pairs: List[Tuple[Variable, Variable]] \ + = ContextSetting([], schema_only=True) merging = Setting(LeftJoin) auto_apply = Setting(True) settings_version = 2 diff --git a/Orange/widgets/data/owpaintdata.py b/Orange/widgets/data/owpaintdata.py index 5fcdf7fd36c..ae8014040d1 100644 --- a/Orange/widgets/data/owpaintdata.py +++ b/Orange/widgets/data/owpaintdata.py @@ -4,6 +4,7 @@ import itertools from functools import partial, singledispatch from collections import namedtuple +from typing import List import numpy as np @@ -761,8 +762,8 @@ class Outputs: symbol_size = Setting(10) #: current data array (shape=(N, 3)) as presented on the output - data = Setting(None, schema_only=True) - labels = Setting(["C1", "C2"], schema_only=True) + data: List[List[float]] = Setting(None, schema_only=True) + labels: List[str] = Setting(["C1", "C2"], schema_only=True) buttons_area_orientation = Qt.Vertical graph_name = "plot" diff --git a/Orange/widgets/data/owpivot.py b/Orange/widgets/data/owpivot.py index 9b04718d53c..d1ee8bd166a 100644 --- a/Orange/widgets/data/owpivot.py +++ b/Orange/widgets/data/owpivot.py @@ -1,5 +1,6 @@ # pylint: disable=missing-docstring -from typing import Iterable, Set +from enum import IntEnum +from typing import Iterable, Set, Tuple from collections import defaultdict from itertools import product, chain @@ -20,7 +21,6 @@ from Orange.data.filter import FilterContinuous, FilterDiscrete, Values from Orange.statistics.util import (nanmin, nanmax, nanunique, nansum, nanvar, nanmean, nanmedian, nanmode, bincount) -from Orange.util import Enum from Orange.widgets import gui from Orange.widgets.settings import (Setting, ContextSetting, DomainContextHandler) @@ -36,7 +36,7 @@ BorderColorRole = next(gui.OrangeUserRole) -class AggregationFunctionsEnum(Enum): +class AggregationFunctionsEnum(IntEnum): (Count, Count_defined, Sum, Mean, Min, Max, Mode, Median, Var, Majority) = range(10) @@ -45,7 +45,7 @@ def __init__(self, *_, **__): self.func = None @property - def value(self): + def value(self): # pylint: disable=invalid-overridden-method return self._value_ def __call__(self, *args): @@ -748,11 +748,11 @@ class Warning(OWWidget.Warning): too_many_values = Msg("Selected variable has too many values.") settingsHandler = DomainContextHandler() - row_feature = ContextSetting(None) - col_feature = ContextSetting(None) - val_feature = ContextSetting(None) - sel_agg_functions = Setting(set([Pivot.Count])) - selection = Setting(set(), schema_only=True) + row_feature: Variable = ContextSetting(None) + col_feature: DiscreteVariable = ContextSetting(None) + val_feature: Variable = ContextSetting(None) + sel_agg_functions: Set[AggregationFunctionsEnum] = Setting({Pivot.Count}) + selection: Set[Tuple[int, int]] = Setting(set(), schema_only=True) auto_commit = Setting(True) AGGREGATIONS = (Pivot.Count, diff --git a/Orange/widgets/data/owrank.py b/Orange/widgets/data/owrank.py index 640da176c06..1cfd7d411c2 100644 --- a/Orange/widgets/data/owrank.py +++ b/Orange/widgets/data/owrank.py @@ -4,7 +4,7 @@ from functools import partial from itertools import chain from types import SimpleNamespace -from typing import Any, Callable, List, Tuple +from typing import Any, Callable, List, Tuple, Set import numpy as np from AnyQt.QtCore import ( @@ -20,8 +20,8 @@ from scipy.sparse import issparse from Orange.data import ( - ContinuousVariable, DiscreteVariable, Domain, StringVariable, Table -) + Table, Domain, + ContinuousVariable, DiscreteVariable, StringVariable, Variable) from Orange.data.util import get_unique_names_duplicates from Orange.preprocess import score from Orange.widgets import gui, report @@ -269,12 +269,12 @@ class Outputs: nSelected = ContextSetting(5) auto_apply = Setting(True) - sorting = Setting((0, Qt.DescendingOrder)) - selected_methods = Setting(set()) + sorting: Tuple[int, int] = Setting((0, Qt.DescendingOrder)) + selected_methods: Set[str] = Setting(set()) settings_version = 3 settingsHandler = DomainContextHandler() - selected_attrs = ContextSetting([], schema_only=True) + selected_attrs: List[Variable] = ContextSetting([], schema_only=True) selectionMethod = ContextSetting(SelectNBest) class Information(OWWidget.Information): diff --git a/Orange/widgets/data/owselectcolumns.py b/Orange/widgets/data/owselectcolumns.py index 3b1b1f1d108..aea3e611585 100644 --- a/Orange/widgets/data/owselectcolumns.py +++ b/Orange/widgets/data/owselectcolumns.py @@ -166,7 +166,7 @@ class Outputs: want_control_area = True settingsHandler = SelectAttributesDomainContextHandler(first_match=False) - domain_role_hints = ContextSetting({}) + domain_role_hints: Dict[Tuple[str, int], Tuple[str, int]] = ContextSetting({}) use_input_features = Setting(False) ignore_new_features = Setting(False) auto_commit = Setting(True) diff --git a/Orange/widgets/data/owtable.py b/Orange/widgets/data/owtable.py index 7ebaa6da5c3..e7d91745ad3 100644 --- a/Orange/widgets/data/owtable.py +++ b/Orange/widgets/data/owtable.py @@ -6,6 +6,7 @@ from collections import OrderedDict, namedtuple from math import isnan +from typing import List import numpy from scipy.sparse import issparse @@ -177,6 +178,9 @@ class OWDataTable(OWWidget): priority = 50 keywords = [] + buttons_area_orientation = Qt.Vertical + dist_color_RGB = (220, 220, 220, 255) + class Inputs: data = Input("Data", Table, multiple=True) @@ -184,17 +188,14 @@ class Outputs: selected_data = Output("Selected Data", Table, default=True) annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Table) - buttons_area_orientation = Qt.Vertical - show_distributions = Setting(False) - dist_color_RGB = Setting((220, 220, 220, 255)) show_attribute_labels = Setting(True) select_rows = Setting(True) auto_commit = Setting(True) color_by_class = Setting(True) - selected_rows = Setting([], schema_only=True) - selected_cols = Setting([], schema_only=True) + selected_rows: List[int] = Setting([], schema_only=True) + selected_cols: List[int] = Setting([], schema_only=True) settings_version = 2 diff --git a/Orange/widgets/data/owtranspose.py b/Orange/widgets/data/owtranspose.py index cbbb84bd552..81eb7c891d9 100644 --- a/Orange/widgets/data/owtranspose.py +++ b/Orange/widgets/data/owtranspose.py @@ -1,4 +1,4 @@ -from Orange.data import Table, ContinuousVariable, StringVariable +from Orange.data import Table, ContinuousVariable, StringVariable, Variable from Orange.widgets.settings import (Setting, ContextSetting, DomainContextHandler) from Orange.widgets.utils.itemmodels import DomainModel @@ -32,7 +32,7 @@ class Outputs: settingsHandler = DomainContextHandler() feature_type = ContextSetting(GENERIC) feature_name = ContextSetting("") - feature_names_column = ContextSetting(None) + feature_names_column: Variable = ContextSetting(None) auto_apply = Setting(True) class Warning(OWWidget.Warning): diff --git a/Orange/widgets/data/tests/test_owfeaturestatistics.py b/Orange/widgets/data/tests/test_owfeaturestatistics.py index 269a6e543c2..42f3c808d10 100644 --- a/Orange/widgets/data/tests/test_owfeaturestatistics.py +++ b/Orange/widgets/data/tests/test_owfeaturestatistics.py @@ -476,7 +476,7 @@ def test_restores_previous_selection(self): def test_settings_migration_to_ver21(self): settings = { - 'controlAreaVisible': True, 'savedWidgetGeometry': '', + 'controlAreaVisible': True, 'savedWidgetGeometry': None, '__version__': 1, 'context_settings': [ Context( diff --git a/Orange/widgets/evaluate/owpredictions.py b/Orange/widgets/evaluate/owpredictions.py index 483961e7ee7..19394ee3a70 100644 --- a/Orange/widgets/evaluate/owpredictions.py +++ b/Orange/widgets/evaluate/owpredictions.py @@ -73,8 +73,8 @@ class Error(OWWidget.Error): score_table = settings.SettingProvider(ScoreTable) #: List of selected class value indices in the `class_values` list - selected_classes = settings.ContextSetting([]) - selection = settings.Setting([], schema_only=True) + selected_classes: List[int] = settings.ContextSetting([]) + selection: List[int] = settings.Setting([], schema_only=True) def __init__(self): super().__init__() diff --git a/Orange/widgets/evaluate/utils.py b/Orange/widgets/evaluate/utils.py index b22dbfdea23..98372700cf1 100644 --- a/Orange/widgets/evaluate/utils.py +++ b/Orange/widgets/evaluate/utils.py @@ -1,6 +1,7 @@ import warnings from functools import partial from itertools import chain +from typing import Set import numpy as np @@ -131,7 +132,7 @@ def is_bad(x): class ScoreTable(OWComponent, QObject): - shown_scores = \ + shown_scores: Set[str] = \ Setting(set(chain(*BUILTIN_SCORERS_ORDER.values()))) shownScoresChanged = Signal() diff --git a/Orange/widgets/unsupervised/owdistancematrix.py b/Orange/widgets/unsupervised/owdistancematrix.py index 65ce2050f2e..4bfb1c3596e 100644 --- a/Orange/widgets/unsupervised/owdistancematrix.py +++ b/Orange/widgets/unsupervised/owdistancematrix.py @@ -1,5 +1,6 @@ import itertools import math +from typing import List import numpy as np @@ -8,15 +9,18 @@ from AnyQt.QtGui import QColor, QPen, QBrush from AnyQt.QtCore import Qt, QAbstractTableModel, QSize +from orangewidget.settings import Context + from Orange.data import Table, Variable, StringVariable from Orange.misc import DistMatrix -from Orange.widgets import widget, gui + +from Orange.widgets import gui from Orange.widgets.gui import OrangeUserRole from Orange.widgets.settings import Setting, ContextSetting, ContextHandler from Orange.widgets.utils.itemmodels import VariableListModel from Orange.widgets.utils.itemselectionmodel import SymmetricSelectionModel from Orange.widgets.utils.widgetpreview import WidgetPreview -from Orange.widgets.widget import Input, Output +from Orange.widgets.widget import OWWidget, AttributeList, Input, Output class DistanceMatrixModel(QAbstractTableModel): @@ -147,7 +151,16 @@ def sizeHintForColumn(self, column: int) -> int: return hint + 1 if self.showGrid() else hint +class DistanceMatrixContext(Context): + dim: int + annotations: List[str] + annotation: str + selection: List[int] + + class DistanceMatrixContextHandler(ContextHandler): + ContextType = DistanceMatrixContext + @staticmethod def _var_names(annotations): return [a.name if isinstance(a, Variable) else a for a in annotations] @@ -180,7 +193,7 @@ def settings_to_widget(self, widget, *args): widget.tableview.selectionModel().setSelectedItems(context.selection) -class OWDistanceMatrix(widget.OWWidget): +class OWDistanceMatrix(OWWidget): name = "Distance Matrix" description = "View distance matrix." icon = "icons/DistanceMatrix.svg" @@ -197,7 +210,7 @@ class Outputs: settingsHandler = DistanceMatrixContextHandler() auto_commit = Setting(True) annotation_idx = ContextSetting(1) - selection = ContextSetting([]) + selection: List[int] = ContextSetting([]) want_control_area = True want_main_area = False @@ -288,7 +301,7 @@ def _update_labels(self): attr = self.distances.row_items.domain.attributes labels = [str(attr[i]) for i in range(self.distances.shape[0])] elif self.annotation_idx == 2 and \ - isinstance(self.items, widget.AttributeList): + isinstance(self.items, AttributeList): labels = [v.name for v in self.items] elif isinstance(self.items, Table): var = self.annot_combo.model()[self.annotation_idx] diff --git a/Orange/widgets/visualize/owbarplot.py b/Orange/widgets/visualize/owbarplot.py index a5e61a849df..6ee77f3cc43 100644 --- a/Orange/widgets/visualize/owbarplot.py +++ b/Orange/widgets/visualize/owbarplot.py @@ -383,13 +383,13 @@ class Outputs: buttons_area_orientation = Qt.Vertical settingsHandler = DomainContextHandler() - selected_var = ContextSetting(None) - group_var = ContextSetting(None) - annot_var = ContextSetting(None) - color_var = ContextSetting(None) + selected_var: ContinuousVariable = ContextSetting(None) + group_var: DiscreteVariable = ContextSetting(None) + annot_var: Variable = ContextSetting(None) + color_var: DiscreteVariable = ContextSetting(None) auto_commit = Setting(True) - selection = Setting(None, schema_only=True) - visual_settings = Setting({}, schema_only=True) + selection: List[int] = Setting(None, schema_only=True) + visual_settings: Dict[KeyType, ValueType] = Setting({}, schema_only=True) graph = SettingProvider(BarPlotGraph) graph_name = "graph.plotItem" diff --git a/Orange/widgets/visualize/owboxplot.py b/Orange/widgets/visualize/owboxplot.py index c5c3584e64d..c9819a2862b 100644 --- a/Orange/widgets/visualize/owboxplot.py +++ b/Orange/widgets/visualize/owboxplot.py @@ -2,6 +2,8 @@ from collections import namedtuple from itertools import chain, count import numpy as np +import scipy.special +from scipy.stats import f_oneway, chi2_contingency from AnyQt.QtWidgets import ( QGraphicsView, QGraphicsScene, QGraphicsItem, QGraphicsSimpleTextItem, @@ -10,10 +12,9 @@ ) from AnyQt.QtGui import QPen, QColor, QBrush, QPainterPath, QPainter, QFont from AnyQt.QtCore import Qt, QEvent, QRectF, QSize, QSortFilterProxyModel -from orangewidget.utils.listview import ListViewSearch -import scipy.special -from scipy.stats import f_oneway, chi2_contingency +from Orange.data import Variable, DiscreteVariable +from orangewidget.utils.listview import ListViewSearch import Orange.data from Orange.data.filter import FilterDiscrete, FilterContinuous, Values, \ @@ -145,10 +146,10 @@ class Warning(widget.OWWidget.Warning): # variable names! selection = ContextSetting((), schema_only=True) - attribute = ContextSetting(None) + attribute: Variable = ContextSetting(None) order_by_importance = Setting(False) order_grouping_by_importance = Setting(False) - group_var = ContextSetting(None) + group_var: DiscreteVariable = ContextSetting(None) show_annotations = Setting(True) compare = Setting(CompareMeans) stattest = Setting(0) diff --git a/Orange/widgets/visualize/owdistributions.py b/Orange/widgets/visualize/owdistributions.py index 49c6da95088..13c63aca765 100644 --- a/Orange/widgets/visualize/owdistributions.py +++ b/Orange/widgets/visualize/owdistributions.py @@ -1,5 +1,6 @@ from functools import partial, reduce from itertools import count, groupby, repeat +from typing import Set from xml.sax.saxutils import escape import numpy as np @@ -11,7 +12,8 @@ from orangewidget.utils.listview import ListViewSearch import pyqtgraph as pg -from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain +from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain, \ + Variable from Orange.preprocess.discretize import decimal_binnings, time_binnings, \ short_time_units from Orange.statistics import distribution, contingency @@ -270,9 +272,9 @@ class Warning(OWWidget.Warning): ignored_nans = Msg("Data instances with missing values are ignored") settingsHandler = settings.DomainContextHandler() - var = settings.ContextSetting(None) - cvar = settings.ContextSetting(None) - selection = settings.ContextSetting(set(), schema_only=True) + var: Variable = settings.ContextSetting(None) + cvar: DiscreteVariable = settings.ContextSetting(None) + selection: Set[int] = settings.ContextSetting(set(), schema_only=True) # number_of_bins must be a context setting because selection depends on it number_of_bins = settings.ContextSetting(5, schema_only=True) diff --git a/Orange/widgets/visualize/owheatmap.py b/Orange/widgets/visualize/owheatmap.py index c4738209e6f..b66d69eab73 100644 --- a/Orange/widgets/visualize/owheatmap.py +++ b/Orange/widgets/visualize/owheatmap.py @@ -168,13 +168,13 @@ class Outputs: legend: bool = settings.Setting(True) # Annotations #: text row annotation (row names) - annotation_var = settings.ContextSetting(None) + annotation_var: Variable = settings.ContextSetting(None) #: color row annotation - annotation_color_var = settings.ContextSetting(None) + annotation_color_var: Variable = settings.ContextSetting(None) column_annotation_color_key: Optional[Tuple[str, str]] = settings.ContextSetting(None) # Discrete variable used to split that data/heatmaps (vertically) - split_by_var = settings.ContextSetting(None) + split_by_var: DiscreteVariable = settings.ContextSetting(None) # Split heatmap columns by 'key' (horizontal) split_columns_key: Optional[Tuple[str, str]] = settings.ContextSetting(None) # Selected row/column clustering method (name) diff --git a/Orange/widgets/visualize/owlinearprojection.py b/Orange/widgets/visualize/owlinearprojection.py index 3b946afa22c..57631633b5a 100644 --- a/Orange/widgets/visualize/owlinearprojection.py +++ b/Orange/widgets/visualize/owlinearprojection.py @@ -2,9 +2,10 @@ Linear Projection widget ------------------------ """ - +from enum import IntEnum from itertools import islice, permutations, chain from math import factorial +from typing import List import numpy as np @@ -17,11 +18,10 @@ import pyqtgraph as pg -from Orange.data import Table, Domain +from Orange.data import Table, Domain, ContinuousVariable from Orange.preprocess import Normalize from Orange.preprocess.score import ReliefF, RReliefF from Orange.projection import PCA, LDA, LinearProjector -from Orange.util import Enum from Orange.widgets import gui, report from Orange.widgets.gui import OWComponent from Orange.widgets.settings import Setting, ContextSetting, SettingProvider @@ -257,8 +257,8 @@ def update_circle(self): self.circle_item.setPen(pen) -Placement = Enum("Placement", dict(Circular=0, LDA=1, PCA=2), type=int, - qualname="Placement") +Placement = IntEnum("Placement", dict(Circular=0, LDA=1, PCA=2), + qualname="Placement") class OWLinearProjection(OWAnchorProjectionWidget): @@ -276,7 +276,7 @@ class OWLinearProjection(OWAnchorProjectionWidget): settings_version = 6 placement = Setting(Placement.Circular) - selected_vars = ContextSetting([]) + selected_vars: List[ContinuousVariable] = ContextSetting([]) vizrank = SettingProvider(LinearProjectionVizRank) GRAPH_CLASS = OWLinProjGraph graph = SettingProvider(OWLinProjGraph) diff --git a/Orange/widgets/visualize/owlineplot.py b/Orange/widgets/visualize/owlineplot.py index bce51e2b49b..1eb27c56f59 100644 --- a/Orange/widgets/visualize/owlineplot.py +++ b/Orange/widgets/visualize/owlineplot.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Dict from xml.sax.saxutils import escape import numpy as np @@ -13,6 +13,7 @@ from pyqtgraph.graphicsItems.ViewBox import ViewBox from orangewidget.utils.listview import ListViewSearch +from orangewidget.utils import visual_settings_dlg as vissettings from orangewidget.utils.visual_settings_dlg import VisualSettingsDialog from Orange.data import Table, DiscreteVariable @@ -608,15 +609,15 @@ class Outputs: annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Table) settingsHandler = DomainContextHandler() - group_var = ContextSetting(None) + group_var: DiscreteVariable = ContextSetting(None) show_profiles = Setting(False) show_range = Setting(True) show_mean = Setting(True) show_error = Setting(False) auto_commit = Setting(True) - selection = Setting(None, schema_only=True) - visual_settings = Setting({}, schema_only=True) - + selection: List[int] = Setting(None, schema_only=True) + visual_settings: Dict[vissettings.KeyType, vissettings.ValueType] \ + = Setting({}, schema_only=True) graph_name = "graph.plotItem" class Error(OWWidget.Error): diff --git a/Orange/widgets/visualize/owscatterplot.py b/Orange/widgets/visualize/owscatterplot.py index 1aa0dfd292f..cfd6da9aa0b 100644 --- a/Orange/widgets/visualize/owscatterplot.py +++ b/Orange/widgets/visualize/owscatterplot.py @@ -240,8 +240,8 @@ class Outputs(OWDataProjectionWidget.Outputs): settings_version = 4 auto_sample = Setting(True) - attr_x = ContextSetting(None) - attr_y = ContextSetting(None) + attr_x: ContinuousVariable = ContextSetting(None) + attr_y: ContinuousVariable = ContextSetting(None) tooltip_shows_all = Setting(True) GRAPH_CLASS = OWScatterPlotGraph diff --git a/Orange/widgets/visualize/utils/widget.py b/Orange/widgets/visualize/utils/widget.py index 88e9e350c48..f909139b389 100644 --- a/Orange/widgets/visualize/utils/widget.py +++ b/Orange/widgets/visualize/utils/widget.py @@ -1,4 +1,4 @@ -from typing import List, Tuple +from typing import List, Tuple, Dict from xml.sax.saxutils import escape import numpy as np @@ -6,6 +6,7 @@ from AnyQt.QtCore import QSize, Signal, Qt from AnyQt.QtWidgets import QApplication +from orangewidget.utils import visual_settings_dlg as vissettings from orangewidget.utils.visual_settings_dlg import VisualSettingsDialog from Orange.data import ( @@ -385,7 +386,8 @@ class Warning(OWProjectionWidgetBase.Warning): settingsHandler = DomainContextHandler() selection: List[Tuple[int, int]] = Setting(None, schema_only=True) - visual_settings = Setting({}, schema_only=True) + visual_settings: Dict[vissettings.KeyType, vissettings.ValueType] \ + = Setting({}, schema_only=True) auto_commit = Setting(True) GRAPH_CLASS = OWScatterPlotBase