|
20 | 20 | from Orange.statistics.distribution import get_distribution, get_distributions |
21 | 21 | from Orange.widgets import gui, settings |
22 | 22 | from Orange.widgets.settings import ( |
23 | | - Setting, DomainContextHandler, ContextSetting, SettingProvider) |
| 23 | + Setting, DomainContextHandler, ContextSetting) |
24 | 24 | from Orange.widgets.utils import to_html, get_variable_values_sorted |
25 | 25 | from Orange.widgets.utils.annotated_data import (create_annotated_table, |
26 | 26 | ANNOTATED_DATA_SIGNAL_NAME) |
@@ -52,14 +52,24 @@ def __init__(self, parent, data, attr_color, attr_range_index): |
52 | 52 | ["a single variable", "two variables", "three variables", |
53 | 53 | "four variables", "at most two variables", |
54 | 54 | "at most three variables", "at most four variables"]) |
55 | | - item0 = combo.model().item(0) |
56 | | - enabled = Qt.ItemIsSelectable | Qt.ItemIsEnabled |
| 55 | + |
| 56 | + def disable_item(i): |
| 57 | + enabled = Qt.ItemIsSelectable | Qt.ItemIsEnabled |
| 58 | + item = combo.model().item(i) |
| 59 | + item.setFlags(item.flags() & ~enabled) |
| 60 | + if self.attr_range_index == i: |
| 61 | + # select one attribute less, or a pair instead of a single |
| 62 | + self.attr_range_index = i - 1 if i else 1 |
| 63 | + |
57 | 64 | if self.attr_color is None: |
58 | | - item0.setFlags(item0.flags() & ~enabled) |
59 | | - else: |
60 | | - item0.setFlags(item0.flags() | enabled) |
| 65 | + disable_item(0) # can't do a single attribute with Pearson |
| 66 | + if len(data.domain.attributes) < 4: |
| 67 | + disable_item(3) # four attributes |
| 68 | + if len(data.domain.attributes) < 3: |
| 69 | + disable_item(2) # three attributes |
| 70 | + |
61 | 71 | combo.activated.connect(self.on_attrs_changed) |
62 | | - combo.setCurrentIndex(attr_range_index) |
| 72 | + combo.setCurrentIndex(self.attr_range_index) |
63 | 73 | box.layout().addWidget(label) |
64 | 74 | box.layout().addWidget(combo) |
65 | 75 | gui.rubber(box) |
@@ -227,7 +237,6 @@ class Outputs: |
227 | 237 | annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Table) |
228 | 238 |
|
229 | 239 | settingsHandler = DomainContextHandler() |
230 | | - vizrank = SettingProvider(MosaicVizRank) |
231 | 240 | settings_version = 2 |
232 | 241 | use_boxes = Setting(True) |
233 | 242 | variable1: Variable = ContextSetting(None) |
@@ -394,8 +403,8 @@ def set_data(self, data): |
394 | 403 | self.openContext(self.data) |
395 | 404 |
|
396 | 405 | def init_vizrank(self): |
397 | | - if self.data is not None and len(self.data) > 1 \ |
398 | | - and len(self.data.domain.attributes) >= 1: |
| 406 | + if self.discrete_data is not None and len(self.discrete_data) > 1 \ |
| 407 | + and len(self.discrete_data.domain.attributes) >= 2: |
399 | 408 | attr_range_index = self.vizrank_attr_range_index |
400 | 409 | if self.variable_color is None: |
401 | 410 | if attr_range_index == 0: |
|
0 commit comments