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

Skip to content

Commit c06f278

Browse files
committed
Inherit some docstrings in backend code.
1 parent 8d62769 commit c06f278

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
@@ -2155,7 +2155,8 @@ def new_timer(self, *args, **kwargs):
21552155
return TimerBase(*args, **kwargs)
21562156

21572157
def flush_events(self):
2158-
"""Flush the GUI events for the figure.
2158+
"""
2159+
Flush the GUI events for the figure.
21592160
21602161
Interactive backends need to reimplement this method.
21612162
"""

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
@@ -446,11 +446,7 @@ def unselect(self):
446446
self.IsSelected = False
447447

448448
def set_foreground(self, fg, isRGBA=None):
449-
"""
450-
Set the foreground color. fg can be a matlab format string, a
451-
html hex color string, an rgb unit tuple, or a float between 0
452-
and 1. In the latter case, grayscale is used.
453-
"""
449+
# docstring inherited
454450
# Implementation note: wxPython has a separate concept of pen and
455451
# brush - the brush fills any outline trace left by the pen.
456452
# Here we set both to the same colour - if a figure is not to be
@@ -465,9 +461,7 @@ def set_foreground(self, fg, isRGBA=None):
465461
self.unselect()
466462

467463
def set_linewidth(self, w):
468-
"""
469-
Set the line width.
470-
"""
464+
# docstring inherited
471465
w = float(w)
472466
DEBUG_MSG("set_linewidth()", 1, self)
473467
self.select()
@@ -482,9 +476,7 @@ def set_linewidth(self, w):
482476
self.unselect()
483477

484478
def set_capstyle(self, cs):
485-
"""
486-
Set the capstyle as a string in ('butt', 'round', 'projecting')
487-
"""
479+
# docstring inherited
488480
DEBUG_MSG("set_capstyle()", 1, self)
489481
self.select()
490482
GraphicsContextBase.set_capstyle(self, cs)
@@ -493,9 +485,7 @@ def set_capstyle(self, cs):
493485
self.unselect()
494486

495487
def set_joinstyle(self, js):
496-
"""
497-
Set the join style to be one of ('miter', 'round', 'bevel')
498-
"""
488+
# docstring inherited
499489
DEBUG_MSG("set_joinstyle()", 1, self)
500490
self.select()
501491
GraphicsContextBase.set_joinstyle(self, js)
@@ -662,9 +652,7 @@ def Copy_to_Clipboard(self, event=None):
662652
wx.TheClipboard.Flush()
663653

664654
def draw_idle(self):
665-
"""
666-
Delay rendering until the GUI is idle.
667-
"""
655+
# docstring inherited
668656
DEBUG_MSG("draw_idle()", 1, self)
669657
self._isDrawn = False # Force redraw
670658
# Triggering a paint event is all that is needed to defer drawing
@@ -673,59 +661,28 @@ def draw_idle(self):
673661
self.Refresh(eraseBackground=False)
674662

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

693667
def flush_events(self):
668+
# docstring inherited
694669
wx.Yield()
695670

696671
def start_event_loop(self, timeout=0):
697-
"""
698-
Start an event loop. This is used to start a blocking event
699-
loop so that interactive functions, such as ginput and
700-
waitforbuttonpress, can wait for events. This should not be
701-
confused with the main GUI event loop, which is always running
702-
and has nothing to do with this.
703-
704-
This call blocks until a callback function triggers
705-
stop_event_loop() or *timeout* is reached. If *timeout* is
706-
<=0, never timeout.
707-
708-
Raises RuntimeError if event loop is already running.
709-
"""
672+
# docstring inherited
710673
if hasattr(self, '_event_loop'):
711674
raise RuntimeError("Event loop already running")
712675
timer = wx.Timer(self, id=wx.ID_ANY)
713676
if timeout > 0:
714677
timer.Start(timeout * 1000, oneShot=True)
715678
self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId())
716-
717679
# Event loop handler for start/stop event loop
718680
self._event_loop = wx.GUIEventLoop()
719681
self._event_loop.Run()
720682
timer.Stop()
721683

722684
def stop_event_loop(self, event=None):
723-
"""
724-
Stop an event loop. This is used to stop a blocking event
725-
loop so that interactive functions, such as ginput and
726-
waitforbuttonpress, can wait for events.
727-
728-
"""
685+
# docstring inherited
729686
if hasattr(self, '_event_loop'):
730687
if self._event_loop.IsRunning():
731688
self._event_loop.Exit()
@@ -785,6 +742,7 @@ def gui_repaint(self, drawDC=None, origin='WX'):
785742
}
786743

787744
def print_figure(self, filename, *args, **kwargs):
745+
# docstring inherited
788746
super().print_figure(filename, *args, **kwargs)
789747
# Restore the current view; this is needed because the artist contains
790748
# methods rely on particular attributes of the rendered figure for

0 commit comments

Comments
 (0)