Skip to content

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

Merged
merged 5 commits into from
Mar 24, 2017

Conversation

patniharshit
Copy link
Contributor

refs #8342

length of the arrow head
Parameters
----------
head_length : float, optional
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@@ -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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Parameters
----------
head_length : float, optional
Length of the arrow head
Copy link
Member

Choose a reason for hiding this comment

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

4-space indent, please.

Copy link
Contributor Author

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.

@@ -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
Copy link
Member

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.

Copy link
Member

@phobson phobson left a 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


*head_width*
width of the arrow head
head_width : float, optional, default : .2
Copy link
Member

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")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

length of the arrow head
Parameters
----------
head_length : float, optional, default : .4
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

@phobson phobson Mar 21, 2017

Choose a reason for hiding this comment

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

@QuLogic

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Parameters
----------
head_length : float, optional, default : .4
Length of the arrow head
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here only or everywhere?

Copy link
Member

@phobson phobson Mar 21, 2017

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
...


*lengthA*
length of the bracket
lengthA : int
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member

@dstansby dstansby left a 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.

@phobson phobson dismissed their stale review March 22, 2017 14:34

no longer relevant


*lengthA*
length of the bracket
lengthA : int
Copy link
Member

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?

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Mar 23, 2017
Copy link
Member

@dstansby dstansby left a 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

@dstansby dstansby changed the title Make ArrowStyle docstrings numpydoc compatible [MRG+1] Make ArrowStyle docstrings numpydoc compatible Mar 24, 2017
@patniharshit
Copy link
Contributor Author

Happy to contribute :)

@NelleV NelleV changed the title [MRG+1] Make ArrowStyle docstrings numpydoc compatible [MRG+2] Make ArrowStyle docstrings numpydoc compatible Mar 24, 2017
@QuLogic QuLogic changed the title [MRG+2] Make ArrowStyle docstrings numpydoc compatible Make ArrowStyle docstrings numpydoc compatible Mar 24, 2017
@QuLogic QuLogic dismissed their stale review March 24, 2017 19:57

Changes made,

@QuLogic QuLogic merged commit fc547f4 into matplotlib:master Mar 24, 2017
@patniharshit patniharshit deleted the arrowStyleDocstring branch March 24, 2017 19:59
dstansby pushed a commit that referenced this pull request Mar 26, 2017
Make ArrowStyle docstrings numpydoc compatible
@dstansby
Copy link
Member

Backported to 2.0.x via. 36ec04f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants