Repository navigation
Conversation
to_rgba signature and error message to optionally support the argument name Co-authored-by: i-deal <113572023+i-deal@users.noreply.github.com>
|
I am not at all excited about extending the API of and we should not be leaking what is really internal details (helpers that existing to reduce the above boiler plate) into the public API. I am a bit worried that this passed tests as |
FWIW, both matplotlib/lib/matplotlib/patches.py Lines 317 to 341 in e9050e8 The original color is retained as a private attribute, but I think only used when updating alpha. Re the try-except loop: it seems to me that that is basically what |
matplotlib/lib/matplotlib/colors.py Lines 289 to 293 in e9050e8 And trying to pull the carve out of is_color_like broke the tests, so my guess is it's used in the startup stuff.
Yup, and I like it and was just unhappy that lists of colors was using there is also the decorator approach to hide the internal arg (which will also work for all the to_rgba functions) but I'm worried about runtime: def error_msg_parameter_name(f, c, errname=None):
try:
value = f(c)
except ValueError as e:
print(dir(e))
raise ValueError(str(e) +f'{"is not a valid value for " + errname if errname else "."}')
return value |
|
Can we clarify the status of this one? |
|
I've moved to draft. |
|
That's fine, honestly I'd prefer a more consistent approach to validation, probably as part of the rcParams work. |
In #25025 there was opposition to adding a new color checking method for arrays to be consistent with the
_check_color_likechecks, and in the call today there seemed to be consensus for usingto_rgbaas the validator, especially since_check_color_likeis using it under the hood._check_color_likewas used in 5 places, so just swapped out those calls w/ calls toto_rgba. Didn't do anything w/ the return type mostly because I wasn't sure if we wanted class objects to retain the original input.To keep the error messages from
check_color_like, I went with the suggestion in this comment but didn't document it (yet) b/c I'm not sure if this is really a public keyword.Originally posted by @anntzer in #25025 (comment)