Open
Description
Bug summary
mcolors.to_rgba_array("none")
returns an empty array while mcolors.to_rgba("none")
and mcolors.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_color
Actual outcome
>>> import matplotlib.colors as mcolors
>>> mcolors.to_rgba("none")
(0.0, 0.0, 0.0, 0.0)
>>> mcolors.to_rgba_array("none")
array([], shape=(0, 4), dtype=float64)
>>> mcolors.to_rgba_array(["none"])
array([[0., 0., 0., 0.]])
>>> mcolors.same_color("none", mcolors.to_rgba("none"))
False
>>> mcolors.same_color(["none"], mcolors.to_rgba("none"))
True
Expected outcome
>>> import matplotlib.colors as mcolors
>>> mcolors.to_rgba("none")
(0.0, 0.0, 0.0, 0.0)
>>> mcolors.to_rgba_array("none")
array([[0., 0., 0., 0.]])
>>> mcolors.to_rgba_array(["none"])
array([[0., 0., 0., 0.]])
>>> mcolors.same_color("none", mcolors.to_rgba("none"))
True
>>> mcolors.same_color(["none"], mcolors.to_rgba("none"))
True
Additional information
I tried the quick fixes of changing the return here to array([[0., 0., 0., 0.]])
and np.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)
Also I realize this could be not worth fixing and a quick fix is to cast none
to a list in same_color