Fixed _has_alpha_channel function to work with hex and tuple colors#27463
Fixed _has_alpha_channel function to work with hex and tuple colors#27463raunak-sood2003 wants to merge 1 commit intomatplotlib:mainfrom
Conversation
There was a problem hiding this comment.
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.
timhoffm
left a comment
There was a problem hiding this comment.
@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.
|
I'm closing this in favor or the prior PR #27327. |
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.