Fail early when setting Text color to a non-colorlike. by anntzer · Pull Request #19571 · matplotlib/matplotlib · GitHub
Skip to content

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

Merged
timhoffm merged 1 commit into
matplotlib:masterfrom
anntzer:ccl
Feb 27, 2021
Merged

timhoffm merged 1 commit into
matplotlib:masterfrom
anntzer:ccl

Conversation

@anntzer

@anntzer anntzer commented Feb 24, 2021

Copy link
Copy Markdown
Contributor

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

@anntzer anntzer added topic: text API: argument checking Validation of acceptable argument values labels Feb 24, 2021
@jklymak

jklymak commented Feb 24, 2021

Copy link
Copy Markdown
Member

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

anntzer commented Feb 24, 2021

Copy link
Copy Markdown
Contributor Author

Yes...?

@jklymak

jklymak commented Feb 24, 2021

Copy link
Copy Markdown
Member

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

@anntzer

anntzer commented Feb 24, 2021

Copy link
Copy Markdown
Contributor Author

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

QuLogic commented Mar 1, 2021

Copy link
Copy Markdown
Member

@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

Labels

API: argument checking Validation of acceptable argument values topic: text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValueError: Invalid RGBA argument: 'G'

4 participants