Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify handling of out-of-bound values Colormap.__call__. #24978

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

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 14, 2023

Mostly, we don't need to manually handle/clip out of bounds float values if we compute the masks early enough (note that these masks are always computed at some point anyways, so there's no cost of doing that a bit earlier).

PR Summary

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this is simpler to follow all of the logic in one spot.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anybody can merge after moving the comment.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 14, 2023

done

edit: Actually, looks like this is legitimately failing test_image, will investigate.
re-edit: Actually, mask_over needed to check xa >= self.N instead of > N-1 as some float values can end up between N-1 and N during multiplication; they will be truncated to N-1 by astype() so they are not "bad". Also took advantage of this to additionally sneak in a slightly simplified handling of mask_bad just below.

@anntzer anntzer marked this pull request as draft January 14, 2023 12:21
Mostly, we don't need to manually handle/clip out of bounds float values
if we compute the masks early enough (note that these masks are always
computed at some point anyways, so there's no cost of doing that a bit
earlier).
@anntzer anntzer marked this pull request as ready for review January 14, 2023 16:40
@ksunden ksunden added this to the v3.8.0 milestone Jan 17, 2023
@ksunden ksunden merged commit f179631 into matplotlib:main Jan 17, 2023
@anntzer anntzer deleted the cm branch January 17, 2023 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants