X Tutup
Skip to content

FIX 2-tuple of colors in to_rgba_array#26952

Merged
timhoffm merged 1 commit intomatplotlib:mainfrom
rcomer:rgba-2tuple
Sep 29, 2023
Merged

FIX 2-tuple of colors in to_rgba_array#26952
timhoffm merged 1 commit intomatplotlib:mainfrom
rcomer:rgba-2tuple

Conversation

@rcomer
Copy link
Copy Markdown
Member

@rcomer rcomer commented Sep 28, 2023

PR summary

Fixes #26949. We just shouldn't assume that a 2-tuple passed to to_rgba_array is a single (color, alpha) pair.

PR checklist

@rcomer rcomer added the PR: bugfix Pull requests that fix identified bugs label Sep 28, 2023
alpha) can assume values between 0 and 1.
"""
if isinstance(c, tuple) and len(c) == 2:
if isinstance(c, tuple) and len(c) == 2 and isinstance(c[1], (int, float)):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have Real here, I think:

Suggested change
if isinstance(c, tuple) and len(c) == 2 and isinstance(c[1], (int, float)):
if isinstance(c, tuple) and len(c) == 2 and isinstance(c[1], Real):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! I think I knew that in the past but then forgot...

Done.

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

Labels

PR: bugfix Pull requests that fix identified bugs topic: color/color & colormaps

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: colors.LinearSegmentedColormap.from_list does not take two tuples in 3.8.0

4 participants

X Tutup