-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make ArrowStyle docstrings numpydoc compatible #8343
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
Conversation
lib/matplotlib/patches.py
Outdated
length of the arrow head | ||
Parameters | ||
---------- | ||
head_length : float, optional |
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.
can you add the default value as well?
head_length : float, optional, default: 0.4
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.
Added
lib/matplotlib/patches.py
Outdated
@@ -3407,8 +3407,7 @@ def transmute(self, path, mutation_size, linewidth): | |||
return _path, _fillable | |||
|
|||
class Curve(_Curve): | |||
""" | |||
A simple curve without any arrow head. | |||
"""A simple curve without any arrow head. |
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.
Are all these single-line changes really necessary? Personally, I don't think they look very good like this.
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.
Yes they don't look good at all. But I think somewhere I saw that for single line docstring.
lib/matplotlib/patches.py
Outdated
Parameters | ||
---------- | ||
head_length : float, optional | ||
Length of the arrow head |
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.
4-space indent, please.
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.
Sorry for that, I should not have mixed tabs and spaces.
lib/matplotlib/patches.py
Outdated
@@ -3520,18 +3524,19 @@ def __init__(self, head_length=.4, head_width=.2): | |||
_style_list["-|>"] = CurveFilledB | |||
|
|||
class CurveFilledAB(_Curve): | |||
""" | |||
An arrow with filled triangle heads both at the begin and the end | |||
"""An arrow with filled triangle heads both at the begin and the end |
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 really should be one line. Maybe change to "at both ends" like BracketAB
does below.
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.
Thanks for tackling this, just some minor comments and discussion
lib/matplotlib/patches.py
Outdated
|
||
*head_width* | ||
width of the arrow head | ||
head_width : float, optional, default : .2 |
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.
For all of these, the numbers need a leading zero before the decimal (e.g., ".2" -> "0.2")
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.
Done.
lib/matplotlib/patches.py
Outdated
length of the arrow head | ||
Parameters | ||
---------- | ||
head_length : float, optional, default : .4 |
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.
cc @NelleV
I don't we should have two colons in the same sentence. It looks weird to me (but it's not a deal breaker). I think this should read:
headhead_length : float, optional (default is 0.4)
The other question is if these parameters are actually optional. What I mean by that is if you said head_length=None
, would this still work by falling back to the default value? If not, then the parameter isn't actually, optional, just named.
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.
Optional does not imply that passing None
does the default; it implies that not passing it uses the default.
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.
You are correct. From the numpydoc spec:
If it is not necessary to specify a keyword argument, use optional:
x : int, optional
Optional keyword parameters have default values, which are displayed as part of the function signature. They can also be detailed in the description:
Description of parameter `x` (the default is -1, which implies summation
over all axes).
(though I wish the meaning of "optional" in this context was a little more precise.
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.
Should I change the way defaults are shown then?
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.
That would be my preference, but I'm not going to hold up this PR for that.
lib/matplotlib/patches.py
Outdated
Parameters | ||
---------- | ||
head_length : float, optional, default : .4 | ||
Length of the arrow head |
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 should be indented only 4 more spaces from the previous line.
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.
Here only or everywhere?
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.
everywhere. Should like:
...
Parameters
----------
head_length : float, optional, default : 0.4
Length of the arrow head
...
lib/matplotlib/patches.py
Outdated
|
||
*lengthA* | ||
length of the bracket | ||
lengthA : int |
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'm slightly confused, __init__
just above this docstring doesn't take a lengthA
or lengthB
argument, is the docstring just wrong here at the moment?
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 think you're right @dstansby .
@patniharshit can you update this docstring to more accurately reflect the call signature?
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.
Thanks for doing this! Looks good apart from my one comment (which may just be me being confused), will leave it to reviewer 2 to decide what to do about that.
lib/matplotlib/patches.py
Outdated
|
||
*lengthA* | ||
length of the bracket | ||
lengthA : int |
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 think you're right @dstansby .
@patniharshit can you update this docstring to more accurately reflect the call signature?
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.
Thanks a lot for this, and sorry for the many comments! Looks 👍 now
Happy to contribute :) |
Make ArrowStyle docstrings numpydoc compatible
Backported to |
refs #8342