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

Skip to content

Fixed _has_alpha_channel function to work with hex and tuple colors #27463

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

Closed

Conversation

raunak-sood2003
Copy link

@raunak-sood2003 raunak-sood2003 commented Dec 7, 2023

PR summary

This PR fixes bug #27321. The _has_alpha_channel function didn't work for hex strings and tuples because it just checked for decimal strings of length 4 (RGBA). The new implementation cases on the three different possible inputs (decimal, hex, and tuple) and determines if the input is a valid color that has an alpha channel. For checking hex colors, the function checks if all the symbols are hex values (0-9, A-F), and if the string is the correct length. Since hex values can be represented with the prefix "#" or "0x", the input strings have to be of length 9 or 10 (prefix + 4 bytes or 8 hex values for all channels).

PR checklist

Note

This PR doesn't pass the MyPy Stubtest, but passes all of the others. I'm not entirely sure how to get it to pass that, although it doesn't seem like too big of an error.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

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.

@raunak-sood2003 Thank you for your willingness to contribute! As stated the issue has already another pull request. Maybe we've been too terse in communication there, but this means, you should not open a competing PR. In particular, the discussion there suggests that we may want to completely get rid of _has_alpha_channel().

I'm putting this on hold until #27327 is decided. Then, we'll see whether this here is still relevant and we'll either pick up here or close.

@timhoffm
Copy link
Member

timhoffm commented Oct 7, 2024

I'm closing this in favor or the prior PR #27327.

@timhoffm timhoffm closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

2 participants