Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b9045cd

Browse files
authored
Merge pull request #13357 from anntzer/inherit-docstrings
Inherit some docstrings in backend code.
2 parents 7ca934f + c06f278 commit b9045cd

8 files changed

+28
-110
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,8 @@ def new_timer(self, *args, **kwargs):
21782178
return TimerBase(*args, **kwargs)
21792179

21802180
def flush_events(self):
2181-
"""Flush the GUI events for the figure.
2181+
"""
2182+
Flush the GUI events for the figure.
21822183
21832184
Interactive backends need to reimplement this method.
21842185
"""

lib/matplotlib/backends/_backend_tk.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def _update_pointer_position(self, guiEvent=None):
324324
self.leave_notify_event(guiEvent)
325325

326326
def draw_idle(self):
327-
"""Update the drawing area if idle."""
327+
# docstring inherited
328328
if not self._idle:
329329
return
330330

@@ -462,23 +462,11 @@ def key_release(self, event):
462462
FigureCanvasBase.key_release_event(self, key, guiEvent=event)
463463

464464
def new_timer(self, *args, **kwargs):
465-
"""
466-
Creates a new backend-specific subclass of `.backend_bases.Timer`.
467-
This is useful for getting periodic events through the backend's native
468-
event loop. Implemented only for backends with GUIs.
469-
470-
Other Parameters
471-
----------------
472-
interval : scalar
473-
Timer interval in milliseconds
474-
callbacks : list
475-
Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
476-
will be executed by the timer every *interval*.
477-
478-
"""
465+
# docstring inherited
479466
return TimerTk(self._tkcanvas, *args, **kwargs)
480467

481468
def flush_events(self):
469+
# docstring inherited
482470
self._master.update()
483471

484472

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,12 @@ def on_draw_event(self, widget, ctx):
292292
pass
293293

294294
def draw(self):
295+
# docstring inherited
295296
if self.is_drawable():
296297
self.queue_draw()
297298

298299
def draw_idle(self):
300+
# docstring inherited
299301
if self._idle_draw_id != 0:
300302
return
301303
def idle_draw(*args):
@@ -307,22 +309,11 @@ def idle_draw(*args):
307309
self._idle_draw_id = GLib.idle_add(idle_draw)
308310

309311
def new_timer(self, *args, **kwargs):
310-
"""
311-
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
312-
This is useful for getting periodic events through the backend's native
313-
event loop. Implemented only for backends with GUIs.
314-
315-
Other Parameters
316-
----------------
317-
interval : scalar
318-
Timer interval in milliseconds
319-
callbacks : list
320-
Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
321-
will be executed by the timer every *interval*.
322-
"""
312+
# docstring inherited
323313
return TimerGTK3(*args, **kwargs)
324314

325315
def flush_events(self):
316+
# docstring inherited
326317
Gdk.threads_enter()
327318
while Gtk.events_pending():
328319
Gtk.main_iteration()

lib/matplotlib/backends/backend_macosx.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ def _draw(self):
8282
return renderer
8383

8484
def draw(self):
85+
# docstring inherited
8586
self.invalidate()
8687
self.flush_events()
8788

8889
def draw_idle(self, *args, **kwargs):
90+
# docstring inherited
8991
self.invalidate()
9092

9193
def blit(self, bbox=None):
@@ -102,19 +104,7 @@ def resize(self, width, height):
102104
self.draw_idle()
103105

104106
def new_timer(self, *args, **kwargs):
105-
"""
106-
Creates a new backend-specific subclass of `backend_bases.Timer`.
107-
This is useful for getting periodic events through the backend's native
108-
event loop. Implemented only for backends with GUIs.
109-
110-
Other Parameters
111-
----------------
112-
interval : scalar
113-
Timer interval in milliseconds
114-
callbacks : list
115-
Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
116-
will be executed by the timer every *interval*.
117-
"""
107+
# docstring inherited
118108
return TimerMac(*args, **kwargs)
119109

120110

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def remove_comm(self, comm_id):
144144

145145
class FigureCanvasNbAgg(FigureCanvasWebAggCore):
146146
def new_timer(self, *args, **kwargs):
147+
# docstring inherited
147148
return TimerTornado(*args, **kwargs)
148149

149150

lib/matplotlib/backends/backend_qt5.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -448,28 +448,15 @@ def _get_key(self, event):
448448
return '+'.join(mods + [key])
449449

450450
def new_timer(self, *args, **kwargs):
451-
"""
452-
Creates a new backend-specific subclass of
453-
:class:`backend_bases.Timer`. This is useful for getting
454-
periodic events through the backend's native event
455-
loop. Implemented only for backends with GUIs.
456-
457-
Other Parameters
458-
----------------
459-
interval : scalar
460-
Timer interval in milliseconds
461-
462-
callbacks : list
463-
Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
464-
will be executed by the timer every *interval*.
465-
466-
"""
451+
# docstring inherited
467452
return TimerQT(*args, **kwargs)
468453

469454
def flush_events(self):
455+
# docstring inherited
470456
qApp.processEvents()
471457

472458
def start_event_loop(self, timeout=0):
459+
# docstring inherited
473460
if hasattr(self, "_event_loop") and self._event_loop.isRunning():
474461
raise RuntimeError("Event loop already running")
475462
self._event_loop = event_loop = QtCore.QEventLoop()
@@ -478,6 +465,7 @@ def start_event_loop(self, timeout=0):
478465
event_loop.exec_()
479466

480467
def stop_event_loop(self, event=None):
468+
# docstring inherited
481469
if hasattr(self, "_event_loop"):
482470
self._event_loop.quit()
483471

lib/matplotlib/backends/backend_webagg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def show(self):
5353
show()
5454

5555
def new_timer(self, *args, **kwargs):
56+
# docstring inherited
5657
return TimerTornado(*args, **kwargs)
5758

5859

lib/matplotlib/backends/backend_wx.py

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,7 @@ def unselect(self):
441441
self.IsSelected = False
442442

443443
def set_foreground(self, fg, isRGBA=None):
444-
"""
445-
Set the foreground color. fg can be a matlab format string, a
446-
html hex color string, an rgb unit tuple, or a float between 0
447-
and 1. In the latter case, grayscale is used.
448-
"""
444+
# docstring inherited
449445
# Implementation note: wxPython has a separate concept of pen and
450446
# brush - the brush fills any outline trace left by the pen.
451447
# Here we set both to the same colour - if a figure is not to be
@@ -460,9 +456,7 @@ def set_foreground(self, fg, isRGBA=None):
460456
self.unselect()
461457

462458
def set_linewidth(self, w):
463-
"""
464-
Set the line width.
465-
"""
459+
# docstring inherited
466460
w = float(w)
467461
DEBUG_MSG("set_linewidth()", 1, self)
468462
self.select()
@@ -477,9 +471,7 @@ def set_linewidth(self, w):
477471
self.unselect()
478472

479473
def set_capstyle(self, cs):
480-
"""
481-
Set the capstyle as a string in ('butt', 'round', 'projecting')
482-
"""
474+
# docstring inherited
483475
DEBUG_MSG("set_capstyle()", 1, self)
484476
self.select()
485477
GraphicsContextBase.set_capstyle(self, cs)
@@ -488,9 +480,7 @@ def set_capstyle(self, cs):
488480
self.unselect()
489481

490482
def set_joinstyle(self, js):
491-
"""
492-
Set the join style to be one of ('miter', 'round', 'bevel')
493-
"""
483+
# docstring inherited
494484
DEBUG_MSG("set_joinstyle()", 1, self)
495485
self.select()
496486
GraphicsContextBase.set_joinstyle(self, js)
@@ -657,9 +647,7 @@ def Copy_to_Clipboard(self, event=None):
657647
wx.TheClipboard.Flush()
658648

659649
def draw_idle(self):
660-
"""
661-
Delay rendering until the GUI is idle.
662-
"""
650+
# docstring inherited
663651
DEBUG_MSG("draw_idle()", 1, self)
664652
self._isDrawn = False # Force redraw
665653
# Triggering a paint event is all that is needed to defer drawing
@@ -668,59 +656,28 @@ def draw_idle(self):
668656
self.Refresh(eraseBackground=False)
669657

670658
def new_timer(self, *args, **kwargs):
671-
"""
672-
Creates a new backend-specific subclass of
673-
:class:`backend_bases.Timer`. This is useful for getting periodic
674-
events through the backend's native event loop. Implemented only
675-
for backends with GUIs.
676-
677-
Other Parameters
678-
----------------
679-
interval : scalar
680-
Timer interval in milliseconds
681-
callbacks : list
682-
Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
683-
will be executed by the timer every *interval*.
684-
685-
"""
659+
# docstring inherited
686660
return TimerWx(*args, **kwargs)
687661

688662
def flush_events(self):
663+
# docstring inherited
689664
wx.Yield()
690665

691666
def start_event_loop(self, timeout=0):
692-
"""
693-
Start an event loop. This is used to start a blocking event
694-
loop so that interactive functions, such as ginput and
695-
waitforbuttonpress, can wait for events. This should not be
696-
confused with the main GUI event loop, which is always running
697-
and has nothing to do with this.
698-
699-
This call blocks until a callback function triggers
700-
stop_event_loop() or *timeout* is reached. If *timeout* is
701-
<=0, never timeout.
702-
703-
Raises RuntimeError if event loop is already running.
704-
"""
667+
# docstring inherited
705668
if hasattr(self, '_event_loop'):
706669
raise RuntimeError("Event loop already running")
707670
timer = wx.Timer(self, id=wx.ID_ANY)
708671
if timeout > 0:
709672
timer.Start(timeout * 1000, oneShot=True)
710673
self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId())
711-
712674
# Event loop handler for start/stop event loop
713675
self._event_loop = wx.GUIEventLoop()
714676
self._event_loop.Run()
715677
timer.Stop()
716678

717679
def stop_event_loop(self, event=None):
718-
"""
719-
Stop an event loop. This is used to stop a blocking event
720-
loop so that interactive functions, such as ginput and
721-
waitforbuttonpress, can wait for events.
722-
723-
"""
680+
# docstring inherited
724681
if hasattr(self, '_event_loop'):
725682
if self._event_loop.IsRunning():
726683
self._event_loop.Exit()
@@ -780,6 +737,7 @@ def gui_repaint(self, drawDC=None, origin='WX'):
780737
}
781738

782739
def print_figure(self, filename, *args, **kwargs):
740+
# docstring inherited
783741
super().print_figure(filename, *args, **kwargs)
784742
# Restore the current view; this is needed because the artist contains
785743
# methods rely on particular attributes of the rendered figure for

0 commit comments

Comments
 (0)