Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Update for checking whether colors have an alpha channel#27327
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
I'm not sure how to add the check for whetherc is indicating a color in a color cycle. I think it requires checking whether the first element of the string is Also: I'm not sure why those tests are failing, but it seems like the test server isn't connected to the internet..? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it makes sense to make this more general. Some comments to consider.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/colors.py Outdated
return not isinstance(c, str) and len(c) == 4 | ||
# If c is not a color, it doesn't have an alpha channel | ||
if not is_color_like(c): | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
One should probably check the code if this has already been called. Since this is a private method one can require that it is checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hm, I'm sure I know how to do that or what you mean. Would you explain a little more?
(also, thanks for the comments, as always)
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Looks like the CI failures were largely due to network problems on GHA/Azure so cycling to rerun |
BackgroundI opened this PR because of my work on PR#27304, which I though would benefit from a check on whether the user provided a color with an alpha value to determine how the violinplot function handles alpha values. However, after@story645 explained, the point of allowing alpha to be included in a color was to remove unnecessary arguments, which I agree with, so that sort of makes my work here less relevant (except for the fact that the previous Current use of |
I'm +0.5 on removing Before we can remove It should also be ensured, that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I suggest to take the fixed_has_alpha_channel()
as minimal bugfix and defer the discussion whethergrid.alpha
(the only use of_has_alpha_channel()
) should be deprecated. Also defer the decision on whether we need_has_alpha_channel_array()
.
lib/matplotlib/colors.py Outdated
"""Return whether *c* is a color with an alpha channel.""" | ||
# 4-element sequences are interpreted as r, g, b, a | ||
return not isinstance(c, str) and len(c) == 4 | ||
"""Return whether *c* is a color with an alpha channel""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We should mention that the result is undefined ifc is not a valid color specifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is now mentioned in the docstring and the comment for the final return line.
lib/matplotlib/colors.py Outdated
return False | ||
def _has_alpha_channel_array(cseq): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is not used anywhere right now. Therefore, we don't need it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It is now deprecated (I added the standard _api.deprecated decorator). In addition I added a deprecation file in the doc/ folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Um, you've just introduced this function and immediately deprecated it?!? You should simply not add it to the PR.
@landoskape are you still interested in working on this? |
Ah, yes! Lost track of it but I can continue in early January. Thanks for the reminder. |
See my responses to@timhoffm. I believe this is all that is needed now since you suggested deferring gridalpha discussion to another time? |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/colors.py Outdated
return False | ||
def _has_alpha_channel_array(cseq): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Um, you've just introduced this function and immediately deprecated it?!? You should simply not add it to the PR.
rcomer left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I suggest starting by checking whether we have a valid color withis_color_like
and if not returnFalse
. Then the remaining logic can be confident about howc
is structured.
Uh oh!
There was an error while loading.Please reload this page.
Smart. I incorporated this. |
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry, after going through the logic carefully, I've some additional remarks. (Could/should have been part of the previous review).
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Of course, no worries. In agreement with all and suggestions all accepted. |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
I do not know what the doc failure is about, but it cannot possibly be caused by this change since we are only modifying a private function. |
9bb047d
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@landoskape and congratulations on your first PR merged into Matplotlib! We hope to hear from you again. |
Woohoo! Thanks :) |
Uh oh!
There was an error while loading.Please reload this page.
PR summary
For more explanation see the matplotlib page onspecifying colors.
PR checklist