Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: to_rgba_array("none") returns empty array #28475

Open
@story645

Description

@story645

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 usemcolors.same_color

Actual outcome

>>>import matplotlib.colorsas 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.colorsas 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 toarray([[0., 0., 0., 0.]]) andnp.array([to_rgba('none')], float)

ifcbook._str_lower_equal(c,"none"):
returnnp.zeros((0,4),float)

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)
image

colorbar_two_slope
image

Also I realize this could be not worth fixing and a quick fix is to castnone to a list insame_color

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp