8000 Write all ACCEPTS markers in docstrings as comments. by timhoffm · Pull Request #15074 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Write all ACCEPTS markers in docstrings as comments. #15074

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 1 commit into from
Aug 19, 2019
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 8000
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that's the reason. Don't know about the actual history.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems true, given the note on set_boxstyle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would skip the discouragement here, unless you want to put the same in set_xlim and friends...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

(*path*, *transform*) is also accepted as a single positional
parameter.

.. ACCEPTS: Patch or (Path, Transform) or None
"""
from matplotlib.patches import Patch, Rectangle

Expand Down
16 changes: 8 additions & 8 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3103,19 +3103,19 @@ 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.

The left and right xlims may also be passed as the tuple
(*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.

Expand Down Expand Up @@ -3487,19 +3487,19 @@ 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.

The bottom and top ylims may also be passed as the tuple
(*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.

Expand Down
15 changes: 10 additions & 5 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
53 changes: 36 additions & 17 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -2403,34 +2408,48 @@ 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()

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):
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/spines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
0