-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) \ | ||
-> (float, float) | ||
""" | ||
self._offset = xy | ||
self.stale = True | ||
|
@@ -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 | ||
|
||
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the extra "the" wasn't really necessary here. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.