Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
tacaswell wants to merge1 commit intomatplotlib:mainfromtacaswell:fix/RGBA_nan

Conversation

tacaswell
Copy link
Member

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 withnp.nan our test erroneously passed.

This adds an explict check fornp.nan

PR checklist

@tacaswelltacaswell added this to thev3.9.0 milestoneNov 10, 2023
oscargus
oscargus previously approved these changesNov 10, 2023
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)
):
Copy link
Contributor

@anntzeranntzerNov 10, 2023
edited
Loading

Choose a reason for hiding this comment

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

Rewrite as
if 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?

@rcomer
Copy link
Member

I checked out this branch and found it does not affect the examples in#27301. I think becausenorm isFalse.

Unless I've done something silly, which is always possible...

@oscargusoscargus dismissed theirstale reviewNovember 10, 2023 14:59

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.

@tacaswell
Copy link
MemberAuthor

Closing in favor of#27301

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer left review comments

@oscargusoscargusoscargus left review comments

Assignees
No one assigned
Projects
None yet
Milestone
v3.9.0
Development

Successfully merging this pull request may close these issues.

[Bug]:imshow allows RGB(A) images withnp.nan values to pass
5 participants
@tacaswell@rcomer@anntzer@oscargus@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp