DOC: clarify valid inputs and return type of same_color#31904
Conversation
I think it'd be cool if that worked. |
| Must be convertible to an (n, 4) RGBA array, where n is the same for | ||
| *c1* and *c2*. |
There was a problem hiding this comment.
I think the mention of (n, 4) here confuses the point I think you're trying to make w/ this PR that c1 and c2 must have the same number of colors.
There was a problem hiding this comment.
Yeah, I was also trying to say something about the acceptable shape of an array. It can be 1D if an array of strings or 2D if it's RGB(A), but not sure the best way to say that concisely and make it obvious that the second dim is channels. 🫤
There was a problem hiding this comment.
I'm confused b/c this works so I'm not sure what needs to be said about shape/channels:
In [13]: mcolors.same_color([(0,0,.2), (0,0, .2, .1), "green", '#0f0f0f80', ('green', .2)], ["green" for _ in range(5)])
Out[13]: np.False_There was a problem hiding this comment.
The docstring states that you can pass an array. So I passed a (n, m, 3) shaped RGB array. It errored in to_rgba_array. Passing a (n, 3) shaped RGB array does work though.
There was a problem hiding this comment.
I think separating concerns might be clearer here? something like:
*c1* and *c2* must be of the same length. RGB(A) arrays must be of shape (ncolors, 3) or (ncolors, 4).
PR summary
I passed an (n, m, 3) RGB array and a single color string, hoping to get an (n, m) boolean array back.
same_colordoesn't do that.I copied the input type specification from the
to_rbga_arraydocstring.AI Disclosure
I asked CoPilot to check the docstring against Numpydoc style. It modified the whitespace and added the "Returns" section.
PR checklist