Skip to content

Fail early when setting Text color to a non-colorlike. #19571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2021

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 24, 2021

Otherwise, the error is only raised when drawing the artist, which is
always confusing. Also add a general _check_color_like mechanism and
use it for Line2D as well, instead of relying on a slightly strange
if not is_color_like(): check_in_list(get_named_colors_mapping())
call where the check_in_list always fails.

Closes #19569 (well, likely the OP was confused about other stuff, but this should at least bring the error message closer to the relevant place).

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak
Copy link
Member

jklymak commented Feb 24, 2021

but '0.82' is colorlike?

Otherwise, the error is only raised when drawing the artist, which is
always confusing.  Also add a general `_check_color_like` mechanism and
use it for Line2D as well, instead of relying on a slightly strange
`if not is_color_like(): check_in_list(get_named_colors_mapping())`
call where the check_in_list *always* fails.
@anntzer
Copy link
Contributor Author

anntzer commented Feb 24, 2021

Yes...?

@jklymak
Copy link
Member

jklymak commented Feb 24, 2021

Thats what the original bug was failing on, wasn't it?

@anntzer
Copy link
Contributor Author

anntzer commented Feb 24, 2021

Given that the traceback ends with ValueError: Invalid RGBA argument: 'G' I guessed they have a color set to 'G' (instead of 'g') somewhere else, but without a repro it's admittedly hard to say.

@timhoffm timhoffm added this to the v3.4.1 milestone Feb 27, 2021
@timhoffm timhoffm merged commit 69edfa2 into matplotlib:master Feb 27, 2021
@anntzer anntzer deleted the ccl branch February 27, 2021 18:02
@QuLogic
Copy link
Member

QuLogic commented Mar 1, 2021

Don't see why this has to go in v3.4.1.

@meeseeksdev backport to v3.4.x

@QuLogic QuLogic modified the milestones: v3.4.1, v3.4.0 Mar 1, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 1, 2021
tacaswell added a commit that referenced this pull request Mar 2, 2021
…571-on-v3.4.x

Backport PR #19571 on branch v3.4.x (Fail early when setting Text color to a non-colorlike.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ValueError: Invalid RGBA argument: 'G'
4 participants