Title: [Bug]: to_rgba_array("none") returns empty array · Issue #28475 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: to_rgba_array("none") returns empty array · Issue #28475 · matplotlib/matplotlib
X Title: [Bug]: to_rgba_array("none") returns empty array · Issue #28475 · matplotlib/matplotlib
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 ...
Open Graph 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 ...
X 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 docum...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28475
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: to_rgba_array(\"none\") returns empty array ","articleBody":"### Bug summary\r\n\r\n`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](https://matplotlib.org/devdocs/api/_as_gen/matplotlib.colors.same_color.html#matplotlib.colors.same_color)\r\n\r\n\r\n### Actual outcome\r\n\r\n```pycon\r\n\u003e\u003e\u003e import matplotlib.colors as mcolors\r\n\u003e\u003e\u003e mcolors.to_rgba(\"none\")\r\n(0.0, 0.0, 0.0, 0.0)\r\n\u003e\u003e\u003e mcolors.to_rgba_array(\"none\") \r\narray([], shape=(0, 4), dtype=float64)\r\n\u003e\u003e\u003e mcolors.to_rgba_array([\"none\"])\r\narray([[0., 0., 0., 0.]])\r\n\u003e\u003e\u003e mcolors.same_color(\"none\", mcolors.to_rgba(\"none\"))\r\nFalse\r\n\u003e\u003e\u003e mcolors.same_color([\"none\"], mcolors.to_rgba(\"none\")) \r\nTrue\r\n```\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\n```pycon\r\n\u003e\u003e\u003e import matplotlib.colors as mcolors\r\n\u003e\u003e\u003e mcolors.to_rgba(\"none\")\r\n(0.0, 0.0, 0.0, 0.0)\r\n\u003e\u003e\u003e mcolors.to_rgba_array(\"none\") \r\narray([[0., 0., 0., 0.]])\r\n\u003e\u003e\u003e mcolors.to_rgba_array([\"none\"])\r\narray([[0., 0., 0., 0.]])\r\n\u003e\u003e\u003e mcolors.same_color(\"none\", mcolors.to_rgba(\"none\"))\r\nTrue\r\n\u003e\u003e\u003e mcolors.same_color([\"none\"], mcolors.to_rgba(\"none\")) \r\nTrue\r\n```\r\n\r\n### Additional information\r\n\r\nI tried the quick fixes of changing the return here to `array([[0., 0., 0., 0.]])` and `np.array([to_rgba('none')], float)`\r\n\r\nhttps://github.com/matplotlib/matplotlib/blob/d347c3227f8de8a99aa327390fee619310452a96/lib/matplotlib/colors.py#L482-L483\r\n\r\nThat yielded a ton of test failures, mostly around colorbars/contours, hatches, and but roughly the diffs all looked something like this:\r\n\r\ncontourf_extend_patches (actual, expected)\r\n\r\n\r\ncolorbar_two_slope\r\n\r\n\r\nAlso I realize this could be not worth fixing and a quick fix is to cast `none` to a list in `same_color`\r\n","author":{"url":"https://github.com/story645","@type":"Person","name":"story645"},"datePublished":"2024-06-27T00:01:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/28475/matplotlib/issues/28475"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f6865ee9-89c3-155c-79ff-894c3b8534c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFBC:2D3512:5B911E:7A0E0F:6A526960 |
| html-safe-nonce | e12d97cab4f934d3cc8353608989f75d512a82cbde6eda74c34f9c5346e9564a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkJDOjJEMzUxMjo1QjkxMUU6N0EwRTBGOjZBNTI2OTYwIiwidmlzaXRvcl9pZCI6IjY0NDE5OTc0MTQ0MTcxOTc0MDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 71d8f12dba86fe604ab8be904857adb733cf833cbc9f7b3230e79459b0371d5f |
| hovercard-subject-tag | issue:2376460636 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/28475/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9e9fbee32244045ec4276ab908d3390988a8b463cd8afce530ef63ee64ebb2b1/matplotlib/matplotlib/issues/28475 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9e9fbee32244045ec4276ab908d3390988a8b463cd8afce530ef63ee64ebb2b1/matplotlib/matplotlib/issues/28475 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | story645 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width