-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow bool-like values for sharex/sharey #24362
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 am not super happy with the implementation : _api.check_in_list(["all", "row", "col", "none", 0, 1, False, True] The error message is clearer but with the if conditions above, |
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.
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 I have understood the dev cal discussion from yesterday correctly, the way forward here is not special-handling 0 and 1 but
- remove the
isinstance(sharex, Integral)
check. That warning is not needed anymore because sharex is keyword-only now. - rewrite the code to special-handle str, and bool-ducktype any other value, i.e.
if isinstance(sharex, str): ... else: sharex = "all" if sharex else "none"
Yes very clear, thanks for the feedback ! I will implement it when I have some time. |
I implemented what you suggested, but there are still two points that bother me and to which I did not find an elegant solution (yet):
|
The fundamental issue here is that the logic needs special handling of some of the existing values. Thus, the I'm mostly ok to have the extra values in here. - The alternative would be to expand the semantics of the
Yes. To be clear: Conceptually, we don't accept special values 0, 1 as synonyms to True and False. We only support the concept of duck-typing, which says that you can pass any truthy or falsy values. This is also what happens in most cases automatically when you have conditions like N.b.: For that reason, the check in list message should not list 0, 1 explicitly. |
Thanks you for the feedback ! I better understand the logic. |
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.
Please do not remove the test.
Anyone can dismiss this review.
@vdbma are you still interested in working on this PR? I'm going to push this to 3.8, but if it is done there is no reason it can not be merged for 3.7. |
Yes, very much so ! Sorry for the late contribution. |
As of now the documentation for
Should I change it so that it is explicit that non-str values will be cast to boolean or should it remain an implicit behaviour ? |
Please leave it as is. The primary logic type here is |
Great and no worries! |
This could do with a squash, by you if you're comfortable with it, or at merge time. |
I've squashed during merge. @vdbma thanks, and congratulations on your first contribution to Matplotlib! We hope to see you again. |
Co-authored-by: Marc Van den Bossche <marc.vanden-bossche@univ-grenoble-alpes.fr>
PR Summary
This PR allows to use either 0 or 1 in place of
False
orTrue
insharex
andsharey
options. Fixes #24349.PR Checklist
Tests and Styling
pytest
passes). (everything passes excepttest_font_manager.py::test_get_font_names
, and it would seem that it is because I have custom fonts installed)flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst