Make ArrowStyle docstrings numpydoc compatible#8343
Make ArrowStyle docstrings numpydoc compatible#8343QuLogic merged 5 commits intomatplotlib:masterfrom
Conversation
lib/matplotlib/patches.py
Outdated
| length of the arrow head | ||
| Parameters | ||
| ---------- | ||
| head_length : float, optional |
There was a problem hiding this comment.
can you add the default value as well?
head_length : float, optional, default: 0.4
lib/matplotlib/patches.py
Outdated
| class Curve(_Curve): | ||
| """ | ||
| A simple curve without any arrow head. | ||
| """A simple curve without any arrow head. |
There was a problem hiding this comment.
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.
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.
Sorry for that, I should not have mixed tabs and spaces.
lib/matplotlib/patches.py
Outdated
| 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.
This really should be one line. Maybe change to "at both ends" like BracketAB does below.
phobson
left a comment
There was a problem hiding this comment.
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.
For all of these, the numbers need a leading zero before the decimal (e.g., ".2" -> "0.2")
lib/matplotlib/patches.py
Outdated
| length of the arrow head | ||
| Parameters | ||
| ---------- | ||
| head_length : float, optional, default : .4 |
There was a problem hiding this comment.
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.
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.
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.
Should I change the way defaults are shown then?
There was a problem hiding this comment.
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.
This should be indented only 4 more spaces from the previous line.
There was a problem hiding this comment.
Here only or everywhere?
There was a problem hiding this comment.
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.
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.
I think you're right @dstansby .
@patniharshit can you update this docstring to more accurately reflect the call signature?
dstansby
left a comment
There was a problem hiding this comment.
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.
I think you're right @dstansby .
@patniharshit can you update this docstring to more accurately reflect the call signature?
dstansby
left a comment
There was a problem hiding this comment.
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