Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use super() more in backends #18190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 3 examples/user_interfaces/embedding_in_wx2_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

class CanvasFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1,
'CanvasFrame', size=(550, 350))
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/user_interfaces/embedding_in_wx3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class PlotPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
super().__init__(parent, -1)

self.fig = Figure((5, 4), 75)
self.canvas = FigureCanvas(self, -1, self.fig)
Expand Down
5 changes: 2 additions & 3 deletions 5 examples/user_interfaces/embedding_in_wx4_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MyNavigationToolbar(NavigationToolbar):
"""Extend the default wx toolbar with your own event handlers."""

def __init__(self, canvas):
NavigationToolbar.__init__(self, canvas)
super().__init__(canvas)
# We use a stock wx bitmap, but you could also use your own image file.
bmp = wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR)
tool = self.AddTool(wx.ID_ANY, 'Click me', bmp,
Expand All @@ -41,8 +41,7 @@ def _on_custom(self, event):

class CanvasFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1,
'CanvasFrame', size=(550, 350))
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

self.figure = Figure(figsize=(5, 4), dpi=100)
self.axes = self.figure.add_subplot(111)
Expand Down
4 changes: 2 additions & 2 deletions 4 examples/user_interfaces/embedding_in_wx5_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class Plot(wx.Panel):
def __init__(self, parent, id=-1, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, id=id, **kwargs)
super().__init__(parent, id=id, **kwargs)
self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
self.canvas = FigureCanvas(self, -1, self.figure)
self.toolbar = NavigationToolbar(self.canvas)
Expand All @@ -31,7 +31,7 @@ def __init__(self, parent, id=-1, dpi=None, **kwargs):

class PlotNotebook(wx.Panel):
def __init__(self, parent, id=-1):
wx.Panel.__init__(self, parent, id=id)
super().__init__(parent, id=id)
self.nb = aui.AuiNotebook(self)
sizer = wx.BoxSizer()
sizer.Add(self.nb, 1, wx.EXPAND)
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/user_interfaces/fourier_demo_wx_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def setKnob(self, value):

class FourierDemoFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
panel = wx.Panel(self)

# create the GUI elements
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/user_interfaces/mathtext_wx_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def mathtext_to_wxbitmap(s):

class CanvasFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
super().__init__(parent, -1, title, size=(550, 350))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/user_interfaces/wxcursor_demo_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class CanvasFrame(wx.Frame):
def __init__(self, ):
wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
Expand Down
24 changes: 12 additions & 12 deletions 24 lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ToolToggleBase(ToolBase):

def __init__(self, *args, **kwargs):
self._toggled = kwargs.pop('toggled', self.default_toggled)
ToolBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def trigger(self, sender, event, data=None):
"""Calls `enable` or `disable` based on `toggled` value."""
Expand Down Expand Up @@ -235,7 +235,7 @@ def set_figure(self, figure):
# if no figure the internal state is not changed
# we change it here so next call to trigger will change it back
self._toggled = False
ToolBase.set_figure(self, figure)
super().set_figure(figure)
if toggled:
if figure:
self.trigger(self, None)
Expand All @@ -253,7 +253,7 @@ class SetCursorBase(ToolBase):
`set_cursor` when a tool gets triggered.
"""
def __init__(self, *args, **kwargs):
ToolBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self._id_drag = None
self._cursor = None
self._default_cursor = cursors.POINTER
Expand All @@ -268,7 +268,7 @@ def __init__(self, *args, **kwargs):
def set_figure(self, figure):
if self._id_drag:
self.canvas.mpl_disconnect(self._id_drag)
ToolBase.set_figure(self, figure)
super().set_figure(figure)
if figure:
self._id_drag = self.canvas.mpl_connect(
'motion_notify_event', self._set_cursor_cbk)
Expand Down Expand Up @@ -324,12 +324,12 @@ class ToolCursorPosition(ToolBase):
"""
def __init__(self, *args, **kwargs):
self._id_drag = None
ToolBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def set_figure(self, figure):
if self._id_drag:
self.canvas.mpl_disconnect(self._id_drag)
ToolBase.set_figure(self, figure)
super().set_figure(figure)
if figure:
self._id_drag = self.canvas.mpl_connect(
'motion_notify_event', self.send_message)
Expand Down Expand Up @@ -473,7 +473,7 @@ class AxisScaleBase(ToolToggleBase):
def trigger(self, sender, event, data=None):
if event.inaxes is None:
return
ToolToggleBase.trigger(self, sender, event, data)
super().trigger(sender, event, data)

def enable(self, event):
self.set_scale(event.inaxes, 'log')
Expand Down Expand Up @@ -522,7 +522,7 @@ def __init__(self, *args, **kwargs):
self.views = WeakKeyDictionary()
self.positions = WeakKeyDictionary()
self.home_views = WeakKeyDictionary()
ToolBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def add_figure(self, figure):
"""Add the current figure to the stack of views and positions."""
Expand Down Expand Up @@ -719,7 +719,7 @@ class SaveFigureBase(ToolBase):
class ZoomPanBase(ToolToggleBase):
"""Base class for `ToolZoom` and `ToolPan`."""
def __init__(self, *args):
ToolToggleBase.__init__(self, *args)
super().__init__(*args)
self._button_pressed = None
self._xypress = None
self._idPress = None
Expand Down Expand Up @@ -749,7 +749,7 @@ def disable(self, event):

def trigger(self, sender, event, data=None):
self.toolmanager.get_tool(_views_positions).add_figure(self.figure)
ToolToggleBase.trigger(self, sender, event, data)
super().trigger(sender, event, data)

def scroll_zoom(self, event):
# https://gist.github.com/tacaswell/3144287
Expand Down Expand Up @@ -790,7 +790,7 @@ class ToolZoom(ZoomPanBase):
radio_group = 'default'

def __init__(self, *args):
ZoomPanBase.__init__(self, *args)
super().__init__(*args)
self._ids_zoom = []

def _cancel_action(self):
Expand Down Expand Up @@ -916,7 +916,7 @@ class ToolPan(ZoomPanBase):
radio_group = 'default'

def __init__(self, *args):
ZoomPanBase.__init__(self, *args)
super().__init__(*args)
self._id_drag = None

def _cancel_action(self):
Expand Down
20 changes: 10 additions & 10 deletions 20 lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TimerTk(TimerBase):

def __init__(self, parent, *args, **kwargs):
self._timer = None
TimerBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.parent = parent

def _timer_start(self):
Expand All @@ -90,7 +90,7 @@ def _timer_stop(self):
self._timer = None

def _on_timer(self):
TimerBase._on_timer(self)
super()._on_timer()
# Tk after() is only a single shot, so we need to add code here to
# reset the timer if we're not operating in single shot mode. However,
# if _timer is None, this means that _timer_stop has been called; so
Expand Down Expand Up @@ -263,13 +263,13 @@ def motion_notify_event(self, event):
x = event.x
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y
FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
super().motion_notify_event(x, y, guiEvent=event)

def enter_notify_event(self, event):
x = event.x
# flipy so y=0 is bottom of canvas
y = self.figure.bbox.height - event.y
FigureCanvasBase.enter_notify_event(self, guiEvent=event, xy=(x, y))
super().enter_notify_event(guiEvent=event, xy=(x, y))

def button_press_event(self, event, dblclick=False):
x = event.x
Expand All @@ -284,8 +284,8 @@ def button_press_event(self, event, dblclick=False):
elif num == 3:
num = 2

FigureCanvasBase.button_press_event(
self, x, y, num, dblclick=dblclick, guiEvent=event)
super().button_press_event(x, y, num,
dblclick=dblclick, guiEvent=event)

def button_dblclick_event(self, event):
self.button_press_event(event, dblclick=True)
Expand All @@ -304,14 +304,14 @@ def button_release_event(self, event):
elif num == 3:
num = 2

FigureCanvasBase.button_release_event(self, x, y, num, guiEvent=event)
super().button_release_event(x, y, num, guiEvent=event)

def scroll_event(self, event):
x = event.x
y = self.figure.bbox.height - event.y
num = getattr(event, 'num', None)
step = 1 if num == 4 else -1 if num == 5 else 0
FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=event)
super().scroll_event(x, y, step, guiEvent=event)

def scroll_event_windows(self, event):
"""MouseWheel event processor"""
Expand Down Expand Up @@ -399,7 +399,7 @@ class FigureManagerTk(FigureManagerBase):
"""

def __init__(self, canvas, num, window):
FigureManagerBase.__init__(self, canvas, num)
super().__init__(canvas, num)
self.window = window
self.window.withdraw()
self.set_window_title("Figure %d" % num)
Expand Down Expand Up @@ -804,7 +804,7 @@ def trigger(self, *args):

class ConfigureSubplotsTk(backend_tools.ConfigureSubplotsBase):
def __init__(self, *args, **kwargs):
backend_tools.ConfigureSubplotsBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.window = None

def trigger(self, *args):
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class RendererAgg(RendererBase):
lock = threading.RLock()

def __init__(self, width, height, dpi):
RendererBase.__init__(self)
super().__init__()

self.dpi = dpi
self.width = width
Expand Down
8 changes: 4 additions & 4 deletions 8 lib/matplotlib/backends/backend_cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(self, dpi):
self.gc = GraphicsContextCairo(renderer=self)
self.text_ctx = cairo.Context(
cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1))
RendererBase.__init__(self)
super().__init__()

@cbook.deprecated("3.4")
@property
Expand Down Expand Up @@ -338,14 +338,14 @@ class GraphicsContextCairo(GraphicsContextBase):
}

def __init__(self, renderer):
GraphicsContextBase.__init__(self)
super().__init__()
self.renderer = renderer

def restore(self):
self.ctx.restore()

def set_alpha(self, alpha):
GraphicsContextBase.set_alpha(self, alpha)
super().set_alpha(alpha)
_alpha = self.get_alpha()
rgb = self._rgb
if self.get_forced_alpha():
Expand Down Expand Up @@ -391,7 +391,7 @@ def set_dashes(self, offset, dashes):
offset)

def set_foreground(self, fg, isRGBA=None):
GraphicsContextBase.set_foreground(self, fg, isRGBA)
super().set_foreground(fg, isRGBA)
if len(self._rgb) == 3:
self.ctx.set_source_rgb(*self._rgb)
else:
Expand Down
6 changes: 3 additions & 3 deletions 6 lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TimerGTK3(TimerBase):

def __init__(self, *args, **kwargs):
self._timer = None
TimerBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def _timer_start(self):
# Need to stop it, otherwise we potentially leak a timer id that will
Expand All @@ -74,7 +74,7 @@ def _timer_set_interval(self):
self._timer_start()

def _on_timer(self):
TimerBase._on_timer(self)
super()._on_timer()

# Gtk timeout_add() requires that the callback returns True if it
# is to be called again.
Expand Down Expand Up @@ -369,7 +369,7 @@ class FigureManagerGTK3(FigureManagerBase):

"""
def __init__(self, canvas, num):
FigureManagerBase.__init__(self, canvas, num)
super().__init__(canvas, num)

self.window = Gtk.Window()
self.window.set_wmclass("matplotlib", "Matplotlib")
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FigureManagerNbAgg(FigureManagerWebAgg):

def __init__(self, canvas, num):
self._shown = False
FigureManagerWebAgg.__init__(self, canvas, num)
super().__init__(canvas, num)

def display_js(self):
# XXX How to do this just once? It has to deal with multiple
Expand Down
4 changes: 2 additions & 2 deletions 4 lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ def new_gc(self):
class GraphicsContextPdf(GraphicsContextBase):

def __init__(self, file):
GraphicsContextBase.__init__(self)
super().__init__()
self._fillcolor = (0.0, 0.0, 0.0)
self._effective_alphas = (1.0, 1.0)
self.file = file
Expand Down Expand Up @@ -2481,7 +2481,7 @@ def copy_properties(self, other):
"""
Copy properties of other into self.
"""
GraphicsContextBase.copy_properties(self, other)
super().copy_properties(other)
fillcolor = getattr(other, '_fillcolor', self._fillcolor)
effective_alphas = getattr(other, '_effective_alphas',
self._effective_alphas)
Expand Down
2 changes: 1 addition & 1 deletion 2 lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def __init__(self, figure, fh, dummy=False):
File handle for the output of the drawing commands.
"""

RendererBase.__init__(self)
super().__init__()
self.dpi = figure.dpi
self.fh = fh
self.figure = figure
Expand Down
6 changes: 2 additions & 4 deletions 6 lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,10 @@ def _is_transparent(rgb_or_rgba):

class GraphicsContextPS(GraphicsContextBase):
def get_capstyle(self):
return {'butt': 0, 'round': 1, 'projecting': 2}[
GraphicsContextBase.get_capstyle(self)]
return {'butt': 0, 'round': 1, 'projecting': 2}[super().get_capstyle()]
timhoffm marked this conversation as resolved.
Show resolved Hide resolved

def get_joinstyle(self):
return {'miter': 0, 'round': 1, 'bevel': 2}[
GraphicsContextBase.get_joinstyle(self)]
return {'miter': 0, 'round': 1, 'bevel': 2}[super().get_joinstyle()]
timhoffm marked this conversation as resolved.
Show resolved Hide resolved


class _Orientation(Enum):
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.