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

Skip to content

Use (float, float) as parameter type for 2D positions in docstrings #12237

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
Sep 24, 2018
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
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ def enter_notify_event(self, guiEvent=None, xy=None):
----------
guiEvent
the native UI event that generated the mpl event
xy : tuple of 2 scalars
xy : (float, float)
the coordinate location of the pointer when the canvas is
entered

Expand Down
41 changes: 30 additions & 11 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,16 @@ def contains(self, mouseevent):

def set_offset(self, xy):
"""
Set the offset
Set the offset.

accepts x, y, tuple, or a callable object.
Parameters
----------
xy : (float, float) or callable
The (x,y) coordinates of the offset in display units.
A callable must have the signature::

def offset(width, height, xdescent, ydescent, renderer) \
Copy link
Member

Choose a reason for hiding this comment

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

I don't get line 191 here... Do you mean it should return (float, float)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the notation for the return type hint.
https://13820-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/api/offsetbox_api.html#matplotlib.offsetbox.OffsetBox.set_offset

We're already using this in other places such as:
https://13820-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/api/_as_gen/matplotlib.artist.Artist.set_contains.html#matplotlib.artist.Artist.set_contains

I've just not annotated the function parameters in this example to keep it more readable, and their types are quite obvious anyway.

-> (float, float)
"""
self._offset = xy
self.stale = True
Expand Down Expand Up @@ -602,9 +609,12 @@ def set_transform(self, t):

def set_offset(self, xy):
"""
set offset of the container.
Set the offset of the container.

Accept : tuple of x,y coordinate in display units.
Parameters
----------
xy : (float, float)
The (x,y) coordinates of the offset in display units.
"""
self._offset = xy

Expand Down Expand Up @@ -773,9 +783,12 @@ def set_transform(self, t):

def set_offset(self, xy):
"""
set offset of the container.
Set the offset of the container.
Copy link
Member

Choose a reason for hiding this comment

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

the extra "the" wasn't really necessary here.

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 think we mostly use the form with the article in the docs. But I don't care too much.


Accept : tuple of x,y coordinates in display units.
Parameters
----------
xy : (float, float)
The (x,y) coordinates of the offset in display units.
"""
self._offset = xy

Expand Down Expand Up @@ -891,9 +904,12 @@ def set_transform(self, t):

def set_offset(self, xy):
"""
set offset of the container.
Set the offset of the container.

Accept : tuple of x,y coordinate in display units.
Parameters
----------
xy : (float, float)
The (x,y) coordinates of the offset in display units.
"""
self._offset = xy

Expand Down Expand Up @@ -1294,9 +1310,12 @@ def get_zoom(self):

# def set_offset(self, xy):
# """
# set offset of the container.

# Accept : tuple of x,y coordinate in display units.
# Set the offset of the container.
#
# Parameters
# ----------
# xy : (float, float)
# The (x,y) coordinates of the offset in display units.
# """
# self._offset = xy

Expand Down
18 changes: 9 additions & 9 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,15 @@ def __init__(self, xy, width, height, angle=0.0, **kwargs):
"""
Parameters
----------
xy: length-2 tuple
xy : (float, float)
The bottom and left rectangle coordinates
width:
width : float
Rectangle width
height:
height : float
Rectangle height
angle: float, optional
angle : float, optional
rotation in degrees anti-clockwise about *xy* (default is 0.0)
fill: bool, optional
fill : bool, optional
Whether to fill the rectangle (default is ``True``)

Notes
Expand Down Expand Up @@ -769,7 +769,7 @@ def set_xy(self, xy):

Parameters
----------
xy : 2-item sequence
xy : (float, float)
"""
self._x0, self._y0 = xy
self._update_x1()
Expand Down Expand Up @@ -1444,11 +1444,11 @@ def __init__(self, xy, width, height, angle=0, **kwargs):
"""
Parameters
----------
xy : tuple of (scalar, scalar)
xy : (float, float)
xy coordinates of ellipse centre.
width : scalar
width : float
Total length (diameter) of horizontal axis.
height : scalar
height : float
Total length (diameter) of vertical axis.
angle : scalar, optional
Rotation in degrees anti-clockwise.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ class _WedgeBbox(mtransforms.Bbox):
Parameters
----------
center : tuple of float
center : (float, float)
Center of the wedge
viewLim : `~matplotlib.transforms.Bbox`
Bbox determining the boundaries of the wedge
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2762,7 +2762,7 @@ class Lasso(AxesWidget):
----------
ax : `~matplotlib.axes.Axes`
The parent axes for the widget.
xy : array
xy : (float, float)
Coordinates of the start of the lasso.
callback : callable
Whenever the lasso is released, the `callback` function is called and
Expand Down