-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fixed colorbar bug when yscaled length is 1 #23984
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
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.
Can you add a test that doesn't work on main, but is fixed by this PR? Probably in |
As there is now a warning, which is clearly better than an error, you will need to take that intro consideration in the test. Something like: with pytest.warns(UserWarning) as record:
ax.contour([[1, 1], [1, 1]])
assert len(record) == 1 should do. Also, please add a comment like: # Smoke test for gh#23817 at the beginning of the test (so that it is clear what is tested as there is "no assert" (the assert above is really not crucial for the test purpose)). Edit: the warning was probably always there, but earlier "hidden" by the error, so the first sentence is not completely correct... |
Thanks for the help! I've added the changes, and I'll circle back later to see if all these tests pass. |
It seems like there is a divide by zero(?) elsewhere in the code now:
here matplotlib/lib/matplotlib/colorbar.py Lines 1223 to 1225 in cb9ae92
One should probably check something there as well? I do not know if the length of |
We could probably just put in a check like this: Another idea: The boundaries are set in _process_values(), here: matplotlib/lib/matplotlib/colorbar.py Lines 1050 to 1055 in 1b3019d
Not sure which section of this function we're setting the boundaries in for this case though. I imagine it would be here: matplotlib/lib/matplotlib/colorbar.py Lines 1056 to 1068 in 1b3019d
I'll try the change that you mentioned for now, though. |
Hi @Andes0113 - is this ready for a second round of reviews? |
@melissawm Think this PR is ready to be closed since there are branching PRs that attempt to do the same thing and are further along in the process. I'd take a look at the more recent related PRs #24656 and #24698 because I've stopped working on this issue. |
Thanks for the update @Andes0113 - hope to see you again around Matplotlib! |
PR Summary
This pull request aims to solve issue #23817 in which an error would be thrown in the event that yscaled's length was 1. To fix this, I added a check to see if yscaled's length was 1, and if so, to set automin and automax to yscaled's only value. I also moved the declaration of automin and automax inside the if statement where extendlength is declared as suggested by @oscargus , since they are unused otherwise.
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).