-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Replace hardcoded parameter names when creating error bars #23376
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
Use `inspect.signature` to automagically check whether a `kwarg` is a line argument, rather than relying on a hardcoded list.
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
I think that although the idea of the PR is good, it is probably quite hard to get through as there is quite a bit of magic going on with the keyword handling, including aliases. However, it is no way intended to discourage you of doing this, it may be possible for some classes, but be prepared for that it can be quite a bit of hassle, closing in to impossible in some cases. |
@wqian94 thanks for the PR! I'm hesitant whether the automatism of introspection is useful here. A subset of the parameters should be passed on. While I think this proposal would currently work correctly, it's not a-priori correct that we should not pass any Line2D parameters to the caps. e.g.
Therefore, it may well be that future code changes will break the correct working of the introspection mechanism. The effect is a change in the visual output (i.e. some properties are not propagated), but no error, which is hard to detect. |
Since all parameters will be passed to `LineCollection.set()`, we can just use that as the primary filter. If there are other keys that should be excluded, they should be handled separately, such as by overwriting the value, as is done for some keys. Notably, `set()` is a kwarg-based key-value updater that uses the `LineCollection`'s `kwargs` specification to perform the appropriate updates. This change allows for all of the gatekeeping to be centralized.
Sorry, been away for the weekend. I'm working on some changes, but it sounds like there isn't much appetite for this, so maybe I'll just keep it as part of a local build instead. |
@wqian94 Yes, I think just adding |
Sure, I'll submit a separate PR. |
Replaced with PR #23475 |
PR Summary
Use
inspect.signature
to automagically check whether akwarg
is aline argument, rather than relying on a hardcoded list. See issue #23375
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).