-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use "Return whether ..." docstring for functions returning bool #18707
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
I'm not sure that whether is more clearly defined than the 'true if' construction... |
@story645 is that really "not sure" or carefully expressing that you'd prefer 'true if' over 'whether'? I'm mainly going for uniformity in the docs here. We currently have 92 "Return whether" vs. 20 "Return True if"-variants. Personally, I'd slightly prefer "whether", but that may be a biased non-native speaker opinion. |
lib/matplotlib/axes/_base.py
Outdated
@@ -2277,8 +2277,7 @@ def _process_unit_info(self, datasets=None, kwargs=None, *, convert=True): | |||
|
|||
def in_axes(self, mouseevent): | |||
""" | |||
Return *True* if the given *mouseevent* (in display coords) | |||
is in the Axes | |||
Return whether the given event (in display coords) is in the axes. |
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.
Why change Axes to axes? The former is the class, the latter is some non-specific thing.
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.
If you check the summary lines in https://matplotlib.org/devdocs/api/axes_api.html#module-matplotlib.axes, more often than not we use "axes" and not "Axes". Similar for "figure".
One could argue that there's a slight difference in meaning. "Axes/Figure" gives more weight to the type, and "axes/figure" is just addressing the general concept.
I'm not sure which one is best. The lower case version could be regarded as a bit sloppy. OTOH, the capitalized version seems a bit bulky. Personally, I feel the lower case version to read more smoothly, but of course that's subjective.
I'll revert this for now, to not block the PR. But it might be a good idea to have some rules on this in the docstring guide.
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.
Figure is okay, because there's only figure, but axes is ambiguous as it's a plural of axis. I've always tried to convert to Axes where possible if it seemed to be what was meant.
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.
Fair point. I've taken the discussion to #18726, because this itself PR does not change capitalization anymore.
A really real "not sure". Totally agree w/ you that it should be consistent, just not sure in which direction. I like "if true then" because it's got a clear programming analogue - this is probably really a more complex on how these strings are constructed - like return probabably shouldn't even be in the description- so I won't block this PR. |
I personally prefer |
I think non-native speaker is a + here ('specially since it's different language families) 'cause one of my concerns is clarity. Both constructs are grammatically fine so 🤷♀️ |
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 in favour of this, as it's more in line with Python's duck typing. We may in fact always return True
, but this formulation only states that what we return is 'truthy'.
Travis is fine, but not reporting. |
PR Summary
Large parts of the code base already use that phrase. Let's get the rest of in line.
This is more natural language than "Return True if", and it includes the negative outcome, which the latter technically does not.