diff --git a/Orange/widgets/visualize/owboxplot.py b/Orange/widgets/visualize/owboxplot.py
index 6fa54631256..695f00bbb02 100644
--- a/Orange/widgets/visualize/owboxplot.py
+++ b/Orange/widgets/visualize/owboxplot.py
@@ -483,7 +483,8 @@ def layout_changed(self):
return
if not self.is_continuous:
- return self.display_changed_disc()
+ self.display_changed_disc()
+ return
self.mean_labels = [self.mean_label(stat, attr, lab)
for stat, lab in zip(self.stats, self.label_txts)]
@@ -502,7 +503,8 @@ def display_changed(self):
return
if not self.is_continuous:
- return self.display_changed_disc()
+ self.display_changed_disc()
+ return
self.order = list(range(len(self.stats)))
criterion = self._sorting_criteria_attrs[self.compare]
@@ -578,6 +580,7 @@ def display_changed_disc(self):
self.conts = self.conts[np.sum(np.array(self.conts), axis=1) > 0]
if self.sort_freqs:
+ # pylint: disable=invalid-unary-operand-type
self.order = sorted(self.order, key=(-np.sum(self.conts, axis=1)).__getitem__)
else:
self.boxes = [self.strudel(self.dist)]
@@ -1043,7 +1046,7 @@ def line(y0, y1):
if xs[to] - frm_x > 1.5:
to -= 1
break
- if last_to == to or frm == to:
+ if to in (last_to, frm):
continue
for rowi, used in enumerate(used_to):
if used < frm:
@@ -1059,8 +1062,7 @@ def line(y0, y1):
last_to = to
def get_widget_name_extension(self):
- if self.attribute:
- return self.attribute.name
+ return self.attribute.name if self.attribute else None
def send_report(self):
self.report_plot()
diff --git a/Orange/widgets/visualize/owdistributions.py b/Orange/widgets/visualize/owdistributions.py
index 3a5f2ad9fa3..497a4ac2ef1 100644
--- a/Orange/widgets/visualize/owdistributions.py
+++ b/Orange/widgets/visualize/owdistributions.py
@@ -9,13 +9,13 @@
import collections
from xml.sax.saxutils import escape
+import numpy
+import pyqtgraph as pg
+
from AnyQt.QtWidgets import QSizePolicy, QLabel, QListView, QToolTip
from AnyQt.QtGui import QColor, QPen, QBrush, QPainter, QPicture, QPalette
from AnyQt.QtCore import Qt, QRectF
-import numpy
-import pyqtgraph as pg
-
import Orange.data
from Orange.preprocess import Discretize, EqualWidth
from Orange.statistics import distribution, contingency
@@ -201,7 +201,7 @@ def __init__(self):
callback=self._on_set_smoothing, createLabel=False)
self.l_smoothing_r = gui.widgetLabel(box2, "Precise")
- self.cb_disc_cont = gui.checkBox(
+ gui.checkBox(
gui.indentedBox(box, sep=4),
self, "disc_cont", "Bin numeric variables",
callback=self._on_groupvar_idx_changed,
@@ -209,18 +209,18 @@ def __init__(self):
box = gui.vBox(self.controlArea, "Group by")
self.icons = gui.attributeIconDict
- self.groupvarview = gui.comboBox(
+ gui.comboBox(
box, self, "groupvar_idx",
callback=self._on_groupvar_idx_changed,
valueType=str, contentsLength=12)
box2 = gui.indentedBox(box, sep=4)
- self.cb_rel_freq = gui.checkBox(
+ gui.checkBox(
box2, self, "relative_freq", "Show relative frequencies",
callback=self._on_relative_freq_changed,
tooltip="Normalize probabilities so that probabilities "
"for each group-by value sum to 1.")
gui.separator(box2)
- self.cb_prob = gui.comboBox(
+ gui.comboBox(
box2, self, "show_prob", label="Show probabilities:",
orientation=Qt.Horizontal,
callback=self._on_relative_freq_changed,
@@ -289,13 +289,14 @@ def set_data(self, data):
self.varmodel[:] = list(domain.variables) + \
[meta for meta in domain.metas
if meta.is_continuous or meta.is_discrete]
- self.groupvarview.clear()
+ groupvarview = self.controls.groupvar_idx
+ groupvarview.clear()
self.groupvarmodel = \
["(None)"] + [var for var in domain.variables if var.is_discrete] + \
[meta for meta in domain.metas if meta.is_discrete]
- self.groupvarview.addItem("(None)")
+ groupvarview.addItem("(None)")
for var in self.groupvarmodel[1:]:
- self.groupvarview.addItem(self.icons[var], var.name)
+ groupvarview.addItem(self.icons[var], var.name)
if domain.has_discrete_class:
self.groupvar_idx = \
self.groupvarmodel[1:].index(domain.class_var) + 1
@@ -316,17 +317,18 @@ def clear(self):
self.groupvar_idx = 0
self._legend.clear()
self._legend.hide()
- self.groupvarview.clear()
- self.cb_prob.clear()
+ self.controls.groupvar_idx.clear()
+ self.controls.show_prob.clear()
def _setup_smoothing(self):
if not self.disc_cont and self.var and self.var.is_continuous:
- self.cb_disc_cont.setText("Bin numeric variables")
+ self.controls.disc_cont.setText("Bin numeric variables")
self.l_smoothing_l.setText("Smooth")
self.l_smoothing_r.setText("Precise")
else:
- self.cb_disc_cont.setText("Bin numeric variables into {} bins".
- format(self.bins[self.smoothing_index]))
+ self.controls.disc_cont.setText(
+ "Bin numeric variables into {} bins".
+ format(self.bins[self.smoothing_index]))
self.l_smoothing_l.setText(" " + str(self.bins[0]))
self.l_smoothing_r.setText(" " + str(self.bins[-1]))
@@ -346,10 +348,11 @@ def _setup(self):
self.var = self.varmodel[varidx]
if self.groupvar_idx > 0:
self.cvar = self.groupvarmodel[self.groupvar_idx]
- self.cb_prob.clear()
- self.cb_prob.addItem("(None)")
- self.cb_prob.addItems(self.cvar.values)
- self.cb_prob.addItem("(All)")
+ prob = self.controls.show_prob
+ prob.clear()
+ prob.addItem("(None)")
+ prob.addItems(self.cvar.values)
+ prob.addItem("(All)")
self.show_prob = min(max(self.show_prob, 0),
len(self.cvar.values) + 1)
data = self.data
@@ -617,9 +620,9 @@ def set_left_axis_name(self):
leftaxis.resizeEvent()
def enable_disable_rel_freq(self):
- self.cb_prob.setDisabled(self.var is None or self.cvar is None)
- self.cb_rel_freq.setDisabled(
- self.var is None or self.cvar is None)
+ disable = self.var is None or self.cvar is None
+ self.controls.show_prob.setDisabled(disable)
+ self.controls.relative_freq.setDisabled(disable)
def _on_variable_idx_changed(self):
self.variable_idx = selected_index(self.varview)
@@ -638,6 +641,7 @@ def onDeleteWidget(self):
def get_widget_name_extension(self):
if self.variable_idx >= 0:
return self.varmodel[self.variable_idx]
+ return None
def send_report(self):
self.plotview.scene().setSceneRect(self.plotview.sceneRect())
@@ -648,7 +652,7 @@ def send_report(self):
self.varmodel[self.variable_idx])
if self.groupvar_idx:
group_var = self.groupvarmodel[self.groupvar_idx]
- prob = self.cb_prob
+ prob = self.controls.show_prob
indiv_probs = 0 < prob.currentIndex() < prob.count() - 1
if not indiv_probs or self.relative_freq:
text += " grouped by '{}'".format(group_var)
@@ -773,7 +777,7 @@ def weighted_std(a, axis=None, weights=None, ddof=0):
return numpy.sqrt(mean_sq_diff)
-def weighted_quantiles(a, prob=[0.25, 0.5, 0.75], alphap=0.4, betap=0.4,
+def weighted_quantiles(a, prob=(0.25, 0.5, 0.75), alphap=0.4, betap=0.4,
axis=None, weights=None):
a = numpy.asarray(a)
prob = numpy.asarray(prob)
diff --git a/Orange/widgets/visualize/owheatmap.py b/Orange/widgets/visualize/owheatmap.py
index 4676f15d2c7..862bde7635b 100644
--- a/Orange/widgets/visualize/owheatmap.py
+++ b/Orange/widgets/visualize/owheatmap.py
@@ -289,7 +289,7 @@ def gamma_fun(x, gamma):
)
-class RowPart(RowPart):
+class RowPart(RowPart): # pylint: disable=function-redefined
"""
A row group
@@ -336,7 +336,7 @@ def cluster_ord(self):
)
-class ColumnPart(ColumnPart):
+class ColumnPart(ColumnPart): # pylint: disable=function-redefined
"""
A column group
@@ -450,7 +450,7 @@ def __init__(self):
super().__init__()
# set default settings
- self.SpaceX = 10
+ self.space_x = 10
self.colorSettings = None
self.selectedSchemaIndex = 0
@@ -943,7 +943,7 @@ def setup_scene(self, parts, data):
widget.layoutDidActivate.connect(self.__update_selection_geometry)
grid = QGraphicsGridLayout()
- grid.setSpacing(self.SpaceX)
+ grid.setSpacing(self.space_x)
self.heatmap_scene.addItem(widget)
N, M = len(parts.rows), len(parts.columns)
@@ -1250,14 +1250,6 @@ def offset(hm):
annot[1].setContentsMargins(left_offset, top, right, bottom)
def __update_clustering_enable_state(self, data):
- def enable(item, state):
- """Set QStandardItem's enabled state to `state`."""
- flags = item.flags()
- if state:
- item.setFlags(flags | Qt.ItemIsEnabled)
- else:
- item.setFlags(flags & ~Qt.ItemIsEnabled)
-
if data is not None:
N = len(data)
M = len(data.domain.attributes)
@@ -1333,7 +1325,7 @@ def update_grid_spacing(self):
"""
if self.scene.widget:
layout = self.scene.widget.layout()
- layout.setSpacing(self.SpaceX)
+ layout.setSpacing(self.space_x)
self.__fixup_grid_layout()
def update_lowslider(self):
@@ -1870,7 +1862,6 @@ def select_from_dendrogram(self, dendrogram, key):
append = (key & Qt.ControlModifier)
self.selection_manager.selection_add(
start, end, heatmap, clear=clear, remove=remove, append=append)
- return
def mousePressEvent(self, event):
pos = event.scenePos()
@@ -1895,7 +1886,6 @@ def mouseReleaseEvent(self, event):
pos = event.scenePos()
heatmap = self.heatmap_at_pos(pos)
if heatmap and event.button() == Qt.LeftButton and self.__selecting:
- row, _ = heatmap.cell_at(heatmap.mapFromScene(pos))
self.selection_manager.selection_finish(heatmap, event)
if event.button() == Qt.LeftButton and self.__selecting:
@@ -1956,7 +1946,7 @@ def setText(self, text):
class GraphicsSimpleTextList(QGraphicsWidget):
"""A simple text list widget."""
- def __init__(self, labels=[], orientation=Qt.Vertical, parent=None):
+ def __init__(self, labels=(), orientation=Qt.Vertical, parent=None):
super().__init__(parent)
self.label_items = []
self.orientation = orientation
@@ -2310,22 +2300,6 @@ def combined_to_ranges(self, comb_ranges):
def update_selection_rects(self):
""" Update the selection rects.
"""
- def continuous_ranges(selections):
- """ Group continuous ranges
- """
- selections = iter(selections)
- start = end = next(selections)
- try:
- while True:
- new_end = next(selections)
- if new_end > end + 1:
- yield start, end
- start = end = new_end
- else:
- end = new_end
- except StopIteration:
- yield start, end
-
def group_selections(selections):
"""Group selections along with heatmaps.
"""
@@ -2385,7 +2359,7 @@ def generate(sep, ellidetemplate, values):
yield i, itertools.islice(parts, i + 1), length, ellide
best = None
- for i, parts, length, ellide in generate(sep, ellidetemplate, values):
+ for _, parts, length, ellide in generate(sep, ellidetemplate, values):
if length > maxlen:
if best is None:
best = sep.join(parts) + ellide
@@ -2393,8 +2367,7 @@ def generate(sep, ellidetemplate, values):
fulllen = length + len(ellide)
if fulllen < maxlen or best is None:
best = sep.join(parts) + ellide
- else:
- return best
+ return best
if __name__ == "__main__": # pragma: no cover
diff --git a/Orange/widgets/visualize/owlinearprojection.py b/Orange/widgets/visualize/owlinearprojection.py
index 244d5d789dc..996cd5acb25 100644
--- a/Orange/widgets/visualize/owlinearprojection.py
+++ b/Orange/widgets/visualize/owlinearprojection.py
@@ -130,6 +130,7 @@ def compute_score(self, state):
n_neighbors = min(self.minK, len(ec) - 1)
knn = NearestNeighbors(n_neighbors=n_neighbors).fit(ec)
ind = knn.kneighbors(return_distance=False)
+ # pylint: disable=invalid-unary-operand-type
if self.attr_color.is_discrete:
return -np.sum(y[ind] == y.reshape(-1, 1)) / n_neighbors / len(y)
return -r2_score(y, np.mean(y[ind], axis=1)) * (len(y) / len(data))
diff --git a/Orange/widgets/visualize/ownomogram.py b/Orange/widgets/visualize/ownomogram.py
index e942a6d5191..c974bbb881d 100644
--- a/Orange/widgets/visualize/ownomogram.py
+++ b/Orange/widgets/visualize/ownomogram.py
@@ -231,6 +231,7 @@ def _get_tooltip_labels_with_percentages(self):
for i, val in enumerate(self.tooltip_values):
if val > self.value:
break
+ # pylint: disable=undefined-loop-variable
diff = self.tooltip_values[i] - self.tooltip_values[i - 1]
p1 = 0 if diff < 1e-6 else (-self.value + self.tooltip_values[i]) / diff
return [(self.tooltip_labels[i - 1].replace("<", "<"), abs(p1)),
@@ -1007,6 +1008,7 @@ def key(x):
def create_footer_nomogram(self, probs_text, d, minimums,
max_width, name_offset):
+ # pylint: disable=invalid-unary-operand-type
eps, d_ = 0.05, 1
k = - np.log(self.p / (1 - self.p)) if self.p is not None else - self.b0
min_sum = k[self.target_class_index] - np.log((1 - eps) / eps)
@@ -1014,7 +1016,7 @@ def create_footer_nomogram(self, probs_text, d, minimums,
if self.align == OWNomogram.ALIGN_LEFT:
max_sum = max_sum - sum(minimums)
min_sum = min_sum - sum(minimums)
- for i in range(len(k)):
+ for i in range(len(k)): # pylint: disable=consider-using-enumerate
k[i] = k[i] - sum([min(q) for q in [p[i] for p in self.points]])
if self.scale == OWNomogram.POINT_SCALE:
min_sum *= d
@@ -1080,13 +1082,13 @@ def set_feature_marker_values(self):
marker_values = self.scale_marker_values(self.feature_marker_values)
invisible_sum = 0
- for i in range(len(marker_values)):
+ for i, marker in enumerate(marker_values):
try:
item = self.feature_items[i]
except KeyError:
- invisible_sum += marker_values[i]
+ invisible_sum += marker
else:
- item.dot.move_to_val(marker_values[i])
+ item.dot.move_to_val(marker)
item.dot.probs_dot.move_to_sum(invisible_sum)
@@ -1171,6 +1173,7 @@ def get_ruler_values(start, stop, max_width, round_to_nearest=True):
def get_points_from_coeffs(current_value, coefficients, possible_values):
if np.isnan(possible_values).any():
return 0
+ # pylint: disable=undefined-loop-variable
indices = np.argsort(possible_values)
sorted_values = possible_values[indices]
sorted_coefficients = coefficients[indices]
diff --git a/Orange/widgets/visualize/owpythagorastree.py b/Orange/widgets/visualize/owpythagorastree.py
index 60ae444ec83..f648c482ff4 100644
--- a/Orange/widgets/visualize/owpythagorastree.py
+++ b/Orange/widgets/visualize/owpythagorastree.py
@@ -403,12 +403,10 @@ class TreeGraphicsView(
):
"""QGraphicsView that contains all functionality we will use to display
tree."""
- pass
class TreeGraphicsScene(UpdateItemsOnSelectGraphicsScene):
"""QGraphicsScene that the tree uses."""
- pass
if __name__ == "__main__": # pragma: no cover
diff --git a/Orange/widgets/visualize/owpythagoreanforest.py b/Orange/widgets/visualize/owpythagoreanforest.py
index 6a879a216e1..3cfe7d041d0 100644
--- a/Orange/widgets/visualize/owpythagoreanforest.py
+++ b/Orange/widgets/visualize/owpythagoreanforest.py
@@ -35,7 +35,7 @@ def __init__(self, *args, **kwargs):
def data(self, index, role=Qt.DisplayRole):
# type: (QModelIndex, Qt.QDisplayRole) -> Any
if not index.isValid():
- return
+ return None
idx = index.row()
@@ -103,7 +103,8 @@ def paint(self, painter, option, index):
# type: (QPainter, QStyleOptionViewItem, QModelIndex) -> None
scene = index.data(Qt.DisplayRole) # type: Optional[QGraphicsScene]
if scene is None:
- return super().paint(painter, option, index)
+ super().paint(painter, option, index)
+ return
painter.save()
rect = QRectF(QPointF(option.rect.topLeft()), QSizeF(option.rect.size()))
diff --git a/Orange/widgets/visualize/owruleviewer.py b/Orange/widgets/visualize/owruleviewer.py
index 22bce806600..5de31818df6 100644
--- a/Orange/widgets/visualize/owruleviewer.py
+++ b/Orange/widgets/visualize/owruleviewer.py
@@ -39,6 +39,8 @@ class Outputs:
want_control_area = False
def __init__(self):
+ super().__init__()
+
self.data = None
self.classifier = None
self.selected = None
@@ -202,6 +204,7 @@ def headerData(self, section, orientation, role=Qt.DisplayRole):
headers = self._headers.get(orientation)
return (headers[section] if headers and section < len(headers)
else str(section))
+ return None
def set_horizontal_header_labels(self, labels):
self._headers[Qt.Horizontal] = labels
@@ -234,7 +237,7 @@ def set_compact_view(self, compact_view):
def data(self, index, role=Qt.DisplayRole):
if self._domain is None or not index.isValid():
- return
+ return None
def _display_role():
if column == 0:
@@ -273,11 +276,13 @@ def _display_role():
if column == 6:
return rule.length
+ return None
+
def _tooltip_role():
if column == 0:
return _display_role().replace(" AND ", " AND\n")
if column == 1:
- return
+ return None
if column == 3:
# list of int, float
curr_class_dist = _display_role()
diff --git a/Orange/widgets/visualize/owscatterplot.py b/Orange/widgets/visualize/owscatterplot.py
index 5ce6189d407..9f4fe00582d 100644
--- a/Orange/widgets/visualize/owscatterplot.py
+++ b/Orange/widgets/visualize/owscatterplot.py
@@ -60,6 +60,7 @@ def iterate_states(self, initial_state):
yield from super().iterate_states(initial_state)
def compute_score(self, state):
+ # pylint: disable=invalid-unary-operand-type
attrs = [self.attrs[i] for i in state]
data = self.master.data
data = data.transform(Domain(attrs, self.attr_color))
diff --git a/Orange/widgets/visualize/owsieve.py b/Orange/widgets/visualize/owsieve.py
index acd61cc556c..2f609319875 100644
--- a/Orange/widgets/visualize/owsieve.py
+++ b/Orange/widgets/visualize/owsieve.py
@@ -39,6 +39,7 @@ def __init__(self, data, attr1, attr2):
return
self.observed = get_contingency(data, attr1, attr2)
self.n = np.sum(self.observed)
+ # pylint: disable=unexpected-keyword-arg
self.probs_x = self.observed.sum(axis=0) / self.n
self.probs_y = self.observed.sum(axis=1) / self.n
self.expected = np.outer(self.probs_y, self.probs_x) * self.n
@@ -502,6 +503,7 @@ def _oper(attr, txt):
def get_widget_name_extension(self):
if self.data is not None:
return "{} vs {}".format(self.attr_x.name, self.attr_y.name)
+ return None
def send_report(self):
self.report_plot()
diff --git a/Orange/widgets/visualize/owsilhouetteplot.py b/Orange/widgets/visualize/owsilhouetteplot.py
index a4bb662403c..06423c2ecca 100644
--- a/Orange/widgets/visualize/owsilhouetteplot.py
+++ b/Orange/widgets/visualize/owsilhouetteplot.py
@@ -366,6 +366,7 @@ def _update_annotations(self):
column, _ = self.data.get_column_view(annot_var)
if self._mask is not None:
assert column.shape == self._mask.shape
+ # pylint: disable=invalid-unary-operand-type
column = column[~self._mask]
self._silplot.setRowNames(
[annot_var.str_val(value) for value in column])
@@ -386,12 +387,14 @@ def commit(self):
indices = self._silplot.selection()
assert (np.diff(indices) > 0).all(), "strictly increasing"
if self._mask is not None:
+ # pylint: disable=invalid-unary-operand-type
indices = np.flatnonzero(~self._mask)[indices]
selectedmask[indices] = True
if self._mask is not None:
scores = np.full(shape=selectedmask.shape,
fill_value=np.nan)
+ # pylint: disable=invalid-unary-operand-type
scores[~self._mask] = self._silhouette
else:
scores = self._silhouette
diff --git a/Orange/widgets/visualize/owtreeviewer.py b/Orange/widgets/visualize/owtreeviewer.py
index d190fa5f0ae..c175437e7f2 100644
--- a/Orange/widgets/visualize/owtreeviewer.py
+++ b/Orange/widgets/visualize/owtreeviewer.py
@@ -358,28 +358,26 @@ def update_node_info_cls(self, node):
else:
modus = np.argmax(distr)
tabs = distr[modus]
- text = self.domain.class_vars[0].values[int(modus)] + "
"
+ text = f"{self.domain.class_vars[0].values[int(modus)]}
"
if tabs > 0.999:
- text += "100%, {}/{}".format(total, total)
+ text += f"100%, {total}/{total}"
else:
- text += "{:2.1f}%, {}/{}".format(100 * tabs,
- int(total * tabs), total)
+ text += f"{100 * tabs:2.1f}%, {int(total * tabs)}/{total}"
text = self._update_node_info_attr_name(node, text)
- node.setHtml('
' - '{}
'. - format(text)) + node.setHtml( + f'{text}
') def update_node_info_reg(self, node): """Update the printed contents of the node for regression trees""" node_inst = node.node_inst mean, var = self.tree_adapter.get_distribution(node_inst)[0] insts = self.tree_adapter.num_samples(node_inst) - text = "{:.1f} ± {:.1f}{}
'. - format(text)) + node.setHtml( + f'{text}
') def toggle_node_color_cls(self): """Update the node color for classification trees""" diff --git a/Orange/widgets/visualize/owtreeviewer2d.py b/Orange/widgets/visualize/owtreeviewer2d.py index 042b9c175a9..b7ec156877c 100644 --- a/Orange/widgets/visualize/owtreeviewer2d.py +++ b/Orange/widgets/visualize/owtreeviewer2d.py @@ -218,9 +218,6 @@ def paint(self, painter, option, widget=0): def boundingRect(self): return super().boundingRect().adjusted(-5, -5, 5, 5) - def mousePressEvent(self, event): - return super().mousePressEvent(event) - class GraphicsEdge(QGraphicsLineItem, GraphEdge): def __init__(self, *args, **kwargs): diff --git a/Orange/widgets/visualize/owvenndiagram.py b/Orange/widgets/visualize/owvenndiagram.py index 13fa2d6966c..12789ba3dd2 100644 --- a/Orange/widgets/visualize/owvenndiagram.py +++ b/Orange/widgets/visualize/owvenndiagram.py @@ -53,6 +53,9 @@ class Outputs: selected_data = Output("Selected Data", Orange.data.Table, default=True) annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table) + inputhints: dict + selection: list + # Selected disjoint subset indices selection = settings.Setting([]) #: Stored input set hints @@ -402,7 +405,7 @@ def _createDiagram(self): vennitems = [] colors = colorpalette.ColorPaletteHSV(n) - for i, (key, item) in enumerate(self.itemsets.items()): + for i, (_, item) in enumerate(self.itemsets.items()): count = len(set(item.items)) count_all = len(item.items) if count != count_all: @@ -541,6 +544,8 @@ def match(val): names = uniquify(names) for i, (key, input) in enumerate(self.data.items()): + # cell vars are in functions that are only used in the loop + # pylint: disable=cell-var-from-loop if not len(input.table): continue if self.useidentifiers: @@ -1019,7 +1024,7 @@ def __init__(self, parent=None, text="", informativeText=""): class VennIntersectionArea(QGraphicsPathItem): def __init__(self, parent=None, text=""): - super(QGraphicsPathItem, self).__init__(parent) + super().__init__(parent) self.setAcceptHoverEvents(True) self.setPen(QPen(Qt.NoPen)) @@ -1035,9 +1040,6 @@ def setText(self, text): self._text = text self.text.setPlainText(text) - def text(self): - return self._text - def setTextAnchor(self, pos): if self._anchor != pos: self._anchor = pos @@ -1242,9 +1244,9 @@ def vennareas(self): return list(self._vennareas) def setFont(self, font): - if self._font != font: + if font != self.font(): self.prepareGeometryChange() - self._font = font + super().setFont(font) for item in self.items(): item.setFont(font) @@ -1331,10 +1333,6 @@ def setGeometry(self, geometry): super(VennDiagram, self).setGeometry(geometry) self._updateLayout() - def paint(self, painter, option, w): - super(VennDiagram, self).paint(painter, option, w) -# painter.drawRect(self.boundingRect()) - def _on_editingStarted(self): item = self.sender() index = self._textitems.index(item) @@ -1490,6 +1488,7 @@ def subset_anchors(shapes): assert all(anchors[1:]) return anchors[1:] + return None def bit_rot_left(x, y, bits=32): @@ -1619,7 +1618,7 @@ def venn_intersection(paths, key): def append_column(data, where, variable, column): - X, Y, M, W = data.X, data.Y, data.metas, data.W + X, Y, M = data.X, data.Y, data.metas domain = data.domain attr = domain.attributes class_vars = domain.class_vars diff --git a/Orange/widgets/visualize/tests/test_owdistributions.py b/Orange/widgets/visualize/tests/test_owdistributions.py index 522d14f6c46..f80b2003585 100644 --- a/Orange/widgets/visualize/tests/test_owdistributions.py +++ b/Orange/widgets/visualize/tests/test_owdistributions.py @@ -31,18 +31,19 @@ def test_metas(self): self.assertIn(meta, self.widget.groupvarmodel) # select meta attribute - self.widget.cb_disc_cont.setChecked(True) + self.widget.controls.disc_cont.setChecked(True) self.widget.variable_idx = 2 self.widget._setup() def test_remove_data(self): """Check widget when data is removed""" + prob = self.widget.controls.show_prob self.send_signal(self.widget.Inputs.data, self.iris) - self.assertEqual(self.widget.cb_prob.count(), 5) - self.assertEqual(self.widget.groupvarview.count(), 2) + self.assertEqual(prob.count(), 5) + self.assertEqual(self.widget.controls.groupvar_idx.count(), 2) self.send_signal(self.widget.Inputs.data, None) - self.assertEqual(self.widget.cb_prob.count(), 0) - self.assertEqual(self.widget.groupvarview.count(), 0) + self.assertEqual(prob.count(), 0) + self.assertEqual(self.widget.controls.groupvar_idx.count(), 0) def test_discretize_meta(self): """The widget discretizes continuous meta attributes""" @@ -75,11 +76,12 @@ def test_no_distributions(self): GH-2383 GH-2428 """ + cb = self.widget.controls.relative_freq self.send_signal(self.widget.Inputs.data, None) - self.widget.cb_rel_freq.click() + cb.click() self.send_signal(self.widget.Inputs.data, self.data) - self.widget.cb_rel_freq.setChecked(False) - self.widget.cb_rel_freq.click() + cb.setChecked(False) + cb.click() self.send_signal(self.widget.Inputs.data, None) - self.widget.cb_rel_freq.setChecked(True) - self.widget.cb_rel_freq.click() + cb.setChecked(True) + cb.click() diff --git a/Orange/widgets/visualize/tests/test_owmosaic.py b/Orange/widgets/visualize/tests/test_owmosaic.py index ddf1347d204..964cb3d7185 100644 --- a/Orange/widgets/visualize/tests/test_owmosaic.py +++ b/Orange/widgets/visualize/tests/test_owmosaic.py @@ -1,5 +1,4 @@ -# Test methods with long descriptive names can omit docstrings -# pylint: disable=missing-docstring +# pylint: disable=missing-docstring,protected-access import time import unittest from unittest.mock import patch @@ -154,7 +153,6 @@ def tearDown(self): def test_count(self): """MosaicVizrank correctly computes the number of combinations""" - widget = self.widget vizrank = self.vizrank data = self.iris diff --git a/Orange/widgets/visualize/tests/test_owpythagoreanforest.py b/Orange/widgets/visualize/tests/test_owpythagoreanforest.py index 7d0d15c883b..49ac389e16d 100644 --- a/Orange/widgets/visualize/tests/test_owpythagoreanforest.py +++ b/Orange/widgets/visualize/tests/test_owpythagoreanforest.py @@ -1,3 +1,5 @@ +# pylint: disable=missing-docstring,protected-access + from unittest.mock import Mock from AnyQt.QtCore import Qt diff --git a/Orange/widgets/visualize/tests/test_owruleviewer.py b/Orange/widgets/visualize/tests/test_owruleviewer.py index 865cb0a623a..4778f773513 100644 --- a/Orange/widgets/visualize/tests/test_owruleviewer.py +++ b/Orange/widgets/visualize/tests/test_owruleviewer.py @@ -1,5 +1,4 @@ -# Test methods with long descriptive names can omit docstrings -# pylint: disable=missing-docstring +# pylint: disable=missing-docstring,protected-access from AnyQt.QtCore import Qt from AnyQt.QtWidgets import QApplication diff --git a/Orange/widgets/visualize/tests/test_owsilhouetteplot.py b/Orange/widgets/visualize/tests/test_owsilhouetteplot.py index 925630c3386..c06c4b07af4 100644 --- a/Orange/widgets/visualize/tests/test_owsilhouetteplot.py +++ b/Orange/widgets/visualize/tests/test_owsilhouetteplot.py @@ -132,9 +132,7 @@ def test_memory_error(self): self.send_signal(self.widget.Inputs.data, data) self.assertFalse(self.widget.Error.memory_error.is_shown()) self.assertFalse(self.widget.Error.value_error.is_shown()) - with unittest.mock.patch( - "numpy.asarray", - side_effect=side_effect): + with unittest.mock.patch("numpy.asarray", side_effect=side_effect): self.widget._matrix = None self.widget.data = data self.widget._effective_data = data diff --git a/Orange/widgets/visualize/tests/test_owvenndiagram.py b/Orange/widgets/visualize/tests/test_owvenndiagram.py index 8a08b0f7e93..cd7d7aeb734 100644 --- a/Orange/widgets/visualize/tests/test_owvenndiagram.py +++ b/Orange/widgets/visualize/tests/test_owvenndiagram.py @@ -67,6 +67,7 @@ def test_venn_diagram(self): cv = np.random.randint(len(class_var.values), size=(3, len(sources))) tables = [] + # pylint: disable=consider-using-enumerate for i in range(len(sources)): temp_table = Table.from_table(table.domain, table, [0 + i, 1 + i, 2 + i])