-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH: Add boolean support for axis() #12359
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
ENH: Add boolean support for axis() #12359
Conversation
Thanks. Now if you test this you would see that it produces an error. the reason is that a boolean cannot be indexed. So you may put everything that comes behind the newly added block into an In addition you need to make sure the correct limits are returned. You could directly copy lines matplotlib/lib/matplotlib/axes/_base.py Lines 1686 to 1688 in e7438c3
To make sure this does what it should, a test would need to be added. Probably inside Finally, the new option would need to be documented. In the docstring of the axis function it needs to mention that it can take a boolean to toggle the axes on or off. |
Oh yes, I think I get the changes now, will complete then over this week! |
Should I use this check? |
Does this look okay? |
A bool has no length. |
Right, I think this should work now. Because I think is always hard to judge on, the usual way we handle this is to create a test for new features. Here it seems a decent way to test is that a figure with an axes and matplotlib/lib/matplotlib/tests/test_axes.py Lines 5742 to 5743 in 46ba49a
Or, you may just check if the figure is created without error and asset the visibility. Finally, the documentation will of course need to be upated to reflect the new arguments. |
I will need a little bit of help with the test, how are the two arguments passed to the function in the examples you showed above This is a basic non-error out test
Can you tell how to use the decorator? |
I would have thought something like this:
|
did you miss a |
nvm, the default is true! |
Sorry, you're right, the last line should not set anything on. I edited that post. |
@ImportanceOfBeingErnest But shouldn't we be testing the True argument also? |
The second last line tests if |
could you help me with the ci tests? |
Thanks for the clarification @timhoffm |
Slightly unsure what the errors are! |
lib/matplotlib/axes/_base.py
Outdated
Optional positional-only argument | ||
|
||
If a bool, | ||
|
||
======== ========================================================== |
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.
A table here seems overkill.
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.
okay, I could remove the table!
Though that was just to preserve the formatting similar to that already on the page!
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'd say,
If a bool, turns axis lines and labels on or off.
Later inside the string table you can also refer to it
Value Description
======== ==========================================================
'on' Turn on axis lines and labels. Same as ``True``.
'off' Turn off axis lines and labels. Same as ``False``.
lib/matplotlib/axes/_base.py
Outdated
@@ -1595,7 +1595,7 @@ def axis(self, *v, **kwargs): | |||
|
|||
Parameters | |||
---------- | |||
v : List[float] or one of the strings listed below. | |||
v : List[float] or bool or one of the strings listed below. | |||
Optional positional-only argument | |||
|
|||
If a list, set the axis data limits. If a string: |
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 a string or a bool
and below in the table
'on' or True
'off' or False
I think this can be merged and closed, right? |
I think the error is unrelated, but someone may recheck. |
@ImportanceOfBeingErnest we have a |
@timhoffm haha thanks for the button, I am guessing I don't need to squash them? 🧀 |
I think you need to fetch upstream first, then run boilerplate.py. Possibly you need to rebase. |
Something went wrong here. You now have 44 commits in your PR. |
Yeah, I am worried now! Have to rebase back |
Hi, Sorry I was not able to get back to this! I think I did an incorrect rebase and these commits showed up. I think I will go pull the latest master and make the changes again |
@abhinuvpitale Let us know if you need help with the rebase (it may be simpler to cherry-pick the commits you want to keep). When you get a local branch you like, you can 'force-push' to this branch on github and this PR will update to reflect those changes ( |
@tacaswell Yeah, could you help me with this rebase? I know which commits to cherry pick, though I am not sure if
|
@abhinuvpitale May I force-push to your branch? |
Yeah sure @tacaswell ! Also please let me know what you did to get it to a clean state.! |
@tacaswell any update? |
Perhaps this should also include np.bool_? |
I've pushed a squashed version of this, and fixed the boilerplate. @abhinuvpitale please fetch before working on this (unless it's already merged.) |
@abhinuvpitale Sorry, I dropped the ball on this. |
Yay! Thanks everyone for fixing #12311! |
Should we backport to 3.1? |
I think that was the original plan, so why not. @meeseeksdev backport to v3.1.x |
…359-on-v3.1.x Backport PR #12359 on branch v3.1.x (ENH: Add boolean support for axis())
PR Summary
Closes #12311
PR Checklist