-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Question on docstring and signature of Axes.stem() #10151
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
Comments
The actual implementation needs to use Per standard policy I would throw a deprecation warning in 2.2 for unhandled arguments. This way, the next release (which should hopefully be 3 and Py3 only...) can just switch to using normal kw-only arguments. |
I think its OK-ish for "See Also" to link to other documents or packages so long as the docs don't require that See Also... I think of it as a "reference" section. See #4829 for the meaning of the |
@anntzer the positional-or-keyword issue is already present in the current implementation ( @jklymak For now, I've resorted to |
Ah, I see. Unless there's a (likely...) dragon in the rabbit hole, I'm +1 to just move the kwargs into the signature then. |
Note: If we really need this mechanism some time, For the present case, I will revert the docstring signature and try to pursue explicit keywords. |
Ok, found the dragon in the rabbit hole: The issue is having a variable number of positional-only arguments (y or x, y) and some additional arguments that can be positional or keyword (the *fmt args). In particular, simultaneously satisfying the following call patterns is not possible with explicit signatures in Python 2:
Python 3 would be fine with
This makes the *fmts keyword only. The internal logic in the mehod can check if they are set or not, and try to obtain them from *args otherwise. Python 2 requires
Then, I cannot I'm reverting to the generic signature, since we currently cannot do better without breaking the API. |
Closing as "good enough". |
While working on #10148 I've come across https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.stem.html
I have the following questions.
1. Link to MATLAB
"See also" links to the MATLAB documentation. Do we really do this and is it meaningful? IMO the docs should be self-contained. There is no guarantee that the matplotlib and MATLAB APIs are or will stay compatible. I propose to simply remove the link.
2. keyword args
The signature is
stem(*args, **kwargs)
. But it does only consider a limited list of 5 kwargs:Currently, all other arguments are silently ignored.
I propose to explicitly write the allowed arguments in the signature:
stem(*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, label=None)
AFAICS this should still be fully API compatible even with all variants of an injected
data
keyword and the possibility to specify the formats as positional arguments.The question is how to handle other kwargs. Options are:
a) still silently ignore them (no change)
b) raise a TypeError (breaks API compatibility, but would be the standard sane python behavior)
c) issue a warning
I tend to b) in this case.
The text was updated successfully, but these errors were encountered: