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: also exclude np.nan in RGB(A) in color mapping#27303
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
if norm and (xx.max() > 1 or xx.min() < 0): | ||
if norm and ( | ||
np.any(np.isnan(xx)) or (xx.max() > 1 or xx.min() < 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.
Rewrite asif not (xx.min() >= 0 and xx.max() <= 1)
(with a comment explaining that this form also excludes nans) and no extra nan checking to save a tiny bit of performance?
I checked out this branch and found it does not affect the examples in#27301. I think because Unless I've done something silly, which is always possible... |
As there were doubts about how to handle it (and now if it actually works), it is probably better that I do not approve (only) based on seemingly sensible code.
Closing in favor of#27301 |
closes#27301
PR summary
The docstring says "values must be on [0, 1] gamut" as is our standard encoding for float RGB(A) arrays. We check that the min and max are not outside of this range, but due to the way comparisons work with
np.nan
our test erroneously passed.This adds an explict check for
np.nan
PR checklist