-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: to_rgba_array("none") returns empty array #28475
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
Comments
Someone at scipy tracked this down to being an issue w/ eager conversion to color that relies on 'none'/empty array for if statements to preserve the correct alpha values. xref #28710 |
The existing behaviour is clearly deliberate but I agree with @story645 about what I expected to happen. Is it worth adding a boolean parameter so you could choose between the two behaviours? |
I've been thinking of a sort of true constant for none, but flagging would probably do the same trick - what I'm thinking is that it could be really useful to know which parts of the codebase need the empty behavior. |
Uh oh!
There was an error while loading. Please reload this page.
Bug summary
mcolors.to_rgba_array("none")
returns an empty array whilemcolors.to_rgba("none")
andmcolors.to_rgba_array(["none"])
return (0,0,0,0) (which is the documented value of None) and this leads to inconsistencies when trying to use mcolors.same_colorActual outcome
Expected outcome
Additional information
I tried the quick fixes of changing the return here to
array([[0., 0., 0., 0.]])
andnp.array([to_rgba('none')], float)
matplotlib/lib/matplotlib/colors.py
Lines 482 to 483 in d347c32
That yielded a ton of test failures, mostly around colorbars/contours, hatches, and but roughly the diffs all looked something like this:
contourf_extend_patches (actual, expected)

colorbar_two_slope

Also I realize this could be not worth fixing and a quick fix is to cast
none
to a list insame_color
The text was updated successfully, but these errors were encountered: