Skip to content

Conversation

rcomer
Copy link
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
@@ -435,7 +435,7 @@ def to_rgba_array(c, alpha=None):
(n, 4) array of RGBA colors, where each channel (red, green, blue,
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
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
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