Skip to content

Commit

Permalink
OWScatterPlotBase: Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Mar 7, 2020
1 parent cfb31d2 commit cdc55a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 7 additions & 6 deletions Orange/widgets/visualize/owscatterplotgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def restoreAnchor(self, anchors):
anchor, parentanchor = anchors
self.anchor(*bound_anchor_pos(anchor, parentanchor))

def paint(self, painter, option, widget=None):
# pylint: disable=arguments-differ
def paint(self, painter, _option, _widget=None):
painter.setPen(self.__pen)
painter.setBrush(self.__brush)
rect = self.contentsRect()
Expand Down Expand Up @@ -619,7 +620,7 @@ def _get_jittering_tooltip(self):
def update_jittering(self):
self.update_tooltip()
x, y = self.get_coordinates()
if x is None or not len(x) or self.scatterplot_item is None:
if x is None or len(x) == 0 or self.scatterplot_item is None:
return
self._update_plot_coordinates(self.scatterplot_item, x, y)
self._update_plot_coordinates(self.scatterplot_item_sel, x, y)
Expand Down Expand Up @@ -834,7 +835,7 @@ def update_coordinates(self):
the complete update by calling `reset_graph` instead of this method.
"""
x, y = self.get_coordinates()
if x is None or not len(x):
if x is None or len(x) == 0:
return
if self.scatterplot_item is None:
if self.sample_indices is None:
Expand Down Expand Up @@ -1053,9 +1054,9 @@ def _get_continuous_colors(self, c_data, subset):
# Reuse pens and brushes with the same colors because PyQtGraph then
# builds smaller pixmap atlas, which makes the drawing faster

def reuse(cache, fn, *args):
def reuse(cache, fun, *args):
if args not in cache:
cache[args] = fn(args)
cache[args] = fun(args)
return cache[args]

def create_pen(col):
Expand Down Expand Up @@ -1113,7 +1114,7 @@ def _get_discrete_colors(self, c_data, subset):

def update_colors(self):
"""
Trigger an update of point sizes
Trigger an update of point colors
The method calls `self.get_colors`, which in turn calls the widget's
`get_color_data` to get the indices in the pallette. `get_colors`
Expand Down
6 changes: 5 additions & 1 deletion Orange/widgets/visualize/tests/test_owscatterplotbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def setUp(self):
# pylint: disable=keyword-arg-before-vararg
def setRange(self, rect=None, *_, **__):
if isinstance(rect, QRectF):
# pylint: disable=attribute-defined-outside-init
self.last_setRange = [[rect.left(), rect.right()],
[rect.top(), rect.bottom()]]

Expand Down Expand Up @@ -308,12 +309,13 @@ def test_sampling_keeps_selection(self):

base = "Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotBase."

@staticmethod
@patch(base + "update_sizes")
@patch(base + "update_colors")
@patch(base + "update_selection_colors")
@patch(base + "update_shapes")
@patch(base + "update_labels")
def test_reset_calls_all_updates_and_update_doesnt(self, *mocks):
def test_reset_calls_all_updates_and_update_doesnt(*mocks):
master = MockWidget()
graph = OWScatterPlotBase(master)
for mock in mocks:
Expand Down Expand Up @@ -443,6 +445,7 @@ def impute_max(size_data):

graph = self.graph

# pylint: disable=attribute-defined-outside-init
self.master.get_size_data = lambda: d
self.master.impute_sizes = impute_max
d = np.arange(10, dtype=float)
Expand Down Expand Up @@ -1162,6 +1165,7 @@ def test_shapes_nan(self):
def impute0(data, _):
data[np.isnan(data)] = 0

# pylint: disable=attribute-defined-outside-init
self.master.impute_shapes = impute0
d = np.arange(10, dtype=float) % 3
d[2] = np.nan
Expand Down

0 comments on commit cdc55a5

Please sign in to comment.