Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Jul 3, 2020
1 parent a26dba7 commit f2eaf40
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 36 deletions.
1 change: 1 addition & 0 deletions Orange/widgets/evaluate/owcalibrationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ def elided(s):
text += "</tr>"
text += "<table>"
return text
return None

def _update_info(self):
self.info_label.setText(self.get_info_text(short=True))
Expand Down
5 changes: 3 additions & 2 deletions Orange/widgets/visualize/owlinearprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,5 +542,6 @@ def get_components(self, X, Y):


if __name__ == "__main__": # pragma: no cover
data = Table("iris")
WidgetPreview(OWLinearProjection).run(set_data=data, set_subset_data=data[::10])
iris = Table("iris")
WidgetPreview(OWLinearProjection).run(set_data=iris,
set_subset_data=iris[::10])
35 changes: 19 additions & 16 deletions Orange/widgets/visualize/owlineplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, *args, **kwargs):
def set_ticks(self, ticks):
self._ticks = dict(enumerate(ticks, 1)) if ticks else {}

def tickStrings(self, values, scale, spacing):
def tickStrings(self, values, scale, _):
return [self._ticks.get(v * scale, "") for v in values]


Expand Down Expand Up @@ -159,29 +159,29 @@ def add_profiles(self, y):
def remove_profiles(self):
self._profile_items = None

def mouseDragEvent(self, event, axis=None):
def mouseDragEvent(self, ev, axis=None):
if self._graph_state == SELECT and axis is None and self._can_select:
event.accept()
if event.button() == Qt.LeftButton:
self.update_selection_line(event.buttonDownPos(), event.pos())
if event.isFinish():
ev.accept()
if ev.button() == Qt.LeftButton:
self.update_selection_line(ev.buttonDownPos(), ev.pos())
if ev.isFinish():
self.selection_line.hide()
p1 = self.childGroup.mapFromParent(
event.buttonDownPos(event.button()))
p2 = self.childGroup.mapFromParent(event.pos())
ev.buttonDownPos(ev.button()))
p2 = self.childGroup.mapFromParent(ev.pos())
self.selection_changed.emit(self.get_selected(p1, p2))
elif self._graph_state == ZOOMING or self._graph_state == PANNING:
event.ignore()
super().mouseDragEvent(event, axis=axis)
ev.ignore()
super().mouseDragEvent(ev, axis=axis)
else:
event.ignore()
ev.ignore()

def mouseClickEvent(self, event):
if event.button() == Qt.RightButton:
def mouseClickEvent(self, ev):
if ev.button() == Qt.RightButton:
self.autoRange()
self.enableAutoRange()
else:
event.accept()
ev.accept()
self.selection_changed.emit(np.array(False))

def reset(self):
Expand Down Expand Up @@ -627,6 +627,9 @@ def __init__(self, parent=None):
self.subset_indices = None
self.__pending_selection = self.selection
self.graph_variables = []
self.graph = None
self.group_vars = None
self.group_view = None
self.setup_gui()

VisualSettingsDialog(self, LinePlotGraph.initial_settings)
Expand Down Expand Up @@ -946,5 +949,5 @@ def set_visual_settings(self, key, value):


if __name__ == "__main__":
data = Table("brown-selected")
WidgetPreview(OWLinePlot).run(set_data=data, set_subset_data=data[:30])
brown = Table("brown-selected")
WidgetPreview(OWLinePlot).run(set_data=brown, set_subset_data=brown[:30])
3 changes: 1 addition & 2 deletions Orange/widgets/visualize/tests/test_owlineplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ def test_selection_line(self):
self.send_signal(self.widget.Inputs.data, self.data)

# set view-dependent click coordinates
vb = self.widget.graph.view_box
event.buttonDownPos.return_value = QPointF(2.38, 4.84)
event.pos.return_value = QPointF(3.58, 4.76)

self.widget.graph.view_box.mouseDragEvent(event)
line = self.widget.graph.view_box.selection_line
self.assertFalse(line.line().isNull())

# click oon the plot resets selection
# click on the plot resets selection
self.assertEqual(len(self.widget.selection), 55)
self.widget.graph.view_box.mouseClickEvent(event)
self.assertListEqual(self.widget.selection, [])
Expand Down
7 changes: 0 additions & 7 deletions Orange/widgets/visualize/tests/test_owscatterplotbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,13 +1540,6 @@ def test_self_data(this, *_, **_1):
np.testing.assert_equal(x, np.arange(10, 15))
np.testing.assert_equal(y, np.arange(20, 25))

def test_scalable_axis_item(self):
from pyqtgraph import __version__
# When upgraded to 0.11.1 check if resizing AxisItem font size works
# and overwritten functions generateDrawSpecs and _updateMaxTextSize
# in AxisItem (owscatterplotgraph) can be removed.
self.assertLess(__version__, "0.11.1")


if __name__ == "__main__":
import unittest
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/visualize/utils/customizableplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def update_num_legend_font(legend: pg.LegendItem,
**settings: _SettingType):
if not legend:
return
for sample, label in legend.items:
for sample, _ in legend.items:
sample.set_font(Updater.change_font(sample.font, settings))
legend.setGeometry(sample.boundingRect())

Expand Down Expand Up @@ -275,7 +275,7 @@ def update_axis(axis, **settings):

self.update_setters()
self._check_setters()

def update_setters(self):
pass

Expand Down
15 changes: 8 additions & 7 deletions Orange/widgets/visualize/utils/plotutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(self, delegate, parent=None):
super().__init__(parent)
self.delegate = delegate

def eventFilter(self, obj, event):
def eventFilter(self, _, event):
if event.type() == QEvent.GraphicsSceneHelp:
return self.delegate(event)
else:
Expand All @@ -140,10 +140,10 @@ def __init__(self, delegate, delegate2, parent=None):
self.delegate2 = delegate2
super().__init__(delegate, parent=parent)

def eventFilter(self, obj, ev):
if isinstance(ev, QGraphicsSceneMouseEvent):
self.delegate2(ev)
return super().eventFilter(obj, ev)
def eventFilter(self, obj, event):
if isinstance(event, QGraphicsSceneMouseEvent):
self.delegate2(event)
return super().eventFilter(obj, event)


class InteractiveViewBox(pg.ViewBox):
Expand All @@ -154,7 +154,8 @@ def __init__(self, graph, enable_menu=False):
self.setMouseMode(self.PanMode)
self.grabGesture(Qt.PinchGesture)

def _dragtip_pos(self):
@staticmethod
def _dragtip_pos():
return 10, 10

def updateScaleBox(self, p1, p2):
Expand Down Expand Up @@ -259,7 +260,7 @@ def autoRange(self, padding=None, items=None, item=None):
super().autoRange(padding=padding, items=items, item=item)
self.tag_history()

def suggestPadding(self, axis): #no padding so that undo works correcty
def suggestPadding(self, _): # no padding so that undo works correcty
return 0.

def scaleHistory(self, d):
Expand Down

0 comments on commit f2eaf40

Please sign in to comment.