Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
FIX: ValueError when hexbin is run with empty arrays and log scaling.#23944
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This PR addresses#23922 |
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 uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
lib/matplotlib/colors.py Outdated
self.vmax = A.max() | ||
# Ensure that A has non-zero size to compute min/max. | ||
# Otherwise put in filler values. | ||
if A.size: |
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.
This is hittingalot of use cases as all of the color mappables to through here, would it be possible to do this check inhexbin
instead?
If we do this here, do we want to use the same logic from the auto limit on the Axis to sure min != max (which I forsee causing divide by 0 errors later)?
lib/matplotlib/colors.py Outdated
self.vmax = A.max() | ||
else: | ||
self.vmin = 0.0 | ||
self.vmax = 0.0 |
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.
Setting these values to zero seems almost certainly wrong; the pre-#21989 behavior was (I think?) to set them to np.ma.masked (I think?) which also seems a bit strange but already better.
Please take a look now. I pushed the fix further upstream and also used |
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.
Looks good to me - thanks for the PR!
… empty arrays and log scaling.
Thanks@erykoff and congratulations on your first contribution to Matplotlib. |
…944-on-v3.6.xBackport PR#23944 on branch v3.6.x (FIX: ValueError when hexbin is run with empty arrays and log scaling.)
…matplotlib#23944)* Add test for empty hexbin with log scaling.* Use guarded autoscale_None for use when vmin/vmax are None.* Add additional check when auto vmin/vmax are None.
PR Summary
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).