From 366805d2f0cc8239471979c827acfbe865f7a0bb Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 18 Aug 2019 01:38:25 +0200 Subject: [PATCH] Write all ACCEPTS markers in docstrings as comments. --- lib/matplotlib/artist.py | 36 ++++++++++++++---------- lib/matplotlib/axes/_base.py | 16 +++++------ lib/matplotlib/cm.py | 15 ++++++---- lib/matplotlib/patches.py | 53 ++++++++++++++++++++++++------------ lib/matplotlib/spines.py | 8 +++--- 5 files changed, 79 insertions(+), 49 deletions(-) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index b86888918f52..20e2a5601017 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -660,11 +660,9 @@ def set_sketch_params(self, scale=None, length=None, randomness=None): The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is `None`, or not provided, no sketch filter will be provided. - length : float, optional The length of the wiggle along the line, in pixels (default 128.0) - randomness : float, optional The scale factor by which the length is shrunken or expanded (default 16.0) @@ -732,20 +730,28 @@ def set_clip_box(self, clipbox): def set_clip_path(self, path, transform=None): """ - Set the artist's clip path, which may be: - - - a :class:`~matplotlib.patches.Patch` (or subclass) instance; or - - a :class:`~matplotlib.path.Path` instance, in which case a - :class:`~matplotlib.transforms.Transform` instance, which will be - applied to the path before using it for clipping, must be provided; - or - - ``None``, to remove a previously set clipping path. + Set the artist's clip path. - For efficiency, if the path happens to be an axis-aligned rectangle, - this method will set the clipping box to the corresponding rectangle - and set the clipping path to ``None``. - - ACCEPTS: [(`~matplotlib.path.Path`, `.Transform`) | `.Patch` | None] + Parameters + ---------- + path : `.Patch` or `.Path` or `.TransformedPath` or None + The clip path. If given a `.Path`, *transform* must be provided as + well. If *None*, a previously set clip path is removed. + transform : `~matplotlib.transforms.Transform`, optional + Only used if *path* is a `.Path`, in which case the given `.Path` + is converted to a `.TransformedPath` using *transform*. + + Notes + ----- + For efficiency, if *path* is a `.Rectangle` this method will set the + clipping box to the corresponding rectangle and set the clipping path + to ``None``. + + For technical reasons (support of ``setp``), a tuple + (*path*, *transform*) is also accepted as a single positional + parameter. + + .. ACCEPTS: Patch or (Path, Transform) or None """ from matplotlib.patches import Patch, Rectangle diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 117adc9d0c1b..b99100ecaf62 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -3103,11 +3103,9 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, """ Set the x-axis view limits. - .. ACCEPTS: (left: float, right: float) - Parameters ---------- - left : scalar, optional + left : float, optional The left xlim in data coordinates. Passing *None* leaves the limit unchanged. @@ -3115,7 +3113,9 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, (*left*, *right*) as the first positional argument (or as the *left* keyword argument). - right : scalar, optional + .. ACCEPTS: (bottom: float, top: float) + + right : float, optional The right xlim in data coordinates. Passing *None* leaves the limit unchanged. @@ -3487,11 +3487,9 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, """ Set the y-axis view limits. - .. ACCEPTS: (bottom: float, top: float) - Parameters ---------- - bottom : scalar, optional + bottom : float, optional The bottom ylim in data coordinates. Passing *None* leaves the limit unchanged. @@ -3499,7 +3497,9 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, (*bottom*, *top*) as the first positional argument (or as the *bottom* keyword argument). - top : scalar, optional + .. ACCEPTS: (bottom: float, top: float) + + top : float, optional The top ylim in data coordinates. Passing *None* leaves the limit unchanged. diff --git a/lib/matplotlib/cm.py b/lib/matplotlib/cm.py index 2543de2bdc8f..b72224587208 100644 --- a/lib/matplotlib/cm.py +++ b/lib/matplotlib/cm.py @@ -269,12 +269,17 @@ def get_clim(self): def set_clim(self, vmin=None, vmax=None): """ - set the norm limits for image scaling; if *vmin* is a length2 - sequence, interpret it as ``(vmin, vmax)`` which is used to - support setp + Set the norm limits for image scaling. - ACCEPTS: a length 2 sequence of floats; may be overridden in methods - that have ``vmin`` and ``vmax`` kwargs. + Parameters + ---------- + vmin, vmax : float + The limits. + + The limits may also be passed as a tuple (*vmin*, *vmax*) as a + single positional argument. + + .. ACCEPTS: (vmin: float, vmax: float) """ if vmax is None: try: diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 21fbca494ccd..5e56c8737f76 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -791,22 +791,27 @@ def set_xy(self, xy): self.stale = True def set_width(self, w): - "Set the width of the rectangle." + """Set the width of the rectangle.""" self._width = w self._update_x1() self.stale = True def set_height(self, h): - "Set the height of the rectangle." + """Set the height of the rectangle.""" self._height = h self._update_y1() self.stale = True def set_bounds(self, *args): """ - Set the bounds of the rectangle. + Set the bounds of the rectangle as *left*, *bottom*, *width*, *height*. + + The values may be passed as separate parameters or as a tuple:: + + set_bounds(left, bottom, width, height) + set_bounds((left, bottom, width, height)) - ACCEPTS: (left, bottom, width, height) + .. ACCEPTS: (left, bottom, width, height) """ if len(args) == 1: l, b, w, h = args[0] @@ -2403,26 +2408,40 @@ def __init__(self, xy, width, height, self.stale = True @docstring.dedent_interpd - def set_boxstyle(self, boxstyle=None, **kw): + def set_boxstyle(self, boxstyle=None, **kwargs): """ Set the box style. - *boxstyle* can be a string with boxstyle name with optional - comma-separated attributes. Alternatively, the attrs can - be provided as keywords:: + Most box styles can be further configured using attributes. + Attributes from the previous box style are not reused. - set_boxstyle("round,pad=0.2") - set_boxstyle("round", pad=0.2) + Without argument (or with ``boxstyle=None``), the available box styles + are returned as a human-readable string. - Old attrs simply are forgotten. + Parameters + ---------- + boxstyle : str + The name of the box style. Optionally, followed by a comma and a + comma-separated list of attributes. The attributes may + alternatively be passed separately as keyword arguments. - Without argument (or with *boxstyle* = None), it returns - available box styles. + The following box styles are available: - The following boxstyles are available: - %(AvailableBoxstyles)s + %(AvailableBoxstyles)s + + .. ACCEPTS: %(ListBoxstyles)s + + **kwargs + Additional attributes for the box style. See the table above for + supported parameters. + + Examples + -------- + :: + + set_boxstyle("round,pad=0.2") + set_boxstyle("round", pad=0.2) - ACCEPTS: %(ListBoxstyles)s """ if boxstyle is None: return BoxStyle.pprint_styles() @@ -2430,7 +2449,7 @@ def set_boxstyle(self, boxstyle=None, **kw): if isinstance(boxstyle, BoxStyle._Base) or callable(boxstyle): self._bbox_transmuter = boxstyle else: - self._bbox_transmuter = BoxStyle(boxstyle, **kw) + self._bbox_transmuter = BoxStyle(boxstyle, **kwargs) self.stale = True def set_mutation_scale(self, scale): diff --git a/lib/matplotlib/spines.py b/lib/matplotlib/spines.py index 23b9402fc93a..b7cea32784c3 100644 --- a/lib/matplotlib/spines.py +++ b/lib/matplotlib/spines.py @@ -538,17 +538,17 @@ def set_bounds(self, low=None, high=None): """ Set the spine bounds. - .. ACCEPTS: (low: float, high: float) - Parameters ---------- - low : scalar, optional + low : float or None, optional The lower spine bound. Passing *None* leaves the limit unchanged. The bounds may also be passed as the tuple (*low*, *high*) as the first positional argument. - high : scalar, optional + .. ACCEPTS: (low: float, high: float) + + high : float or None, optional The higher spine bound. Passing *None* leaves the limit unchanged. """ if self.spine_type == 'circle':