Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify validate_color_for_prop_cycle. #16485

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
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion doc/api/next_api_changes/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,9 @@ deprecation warning.

Previously setting the *ecolor* would turn off automatic color cycling for the plot, leading to the
the lines and markers defaulting to whatever the first color in the color cycle was in the case of
multiple plot calls.
multiple plot calls.

`.rcsetup.validate_color_for_prop_cycle` now always raises TypeError for bytes input
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It previously raised `TypeError`, **except** when the input was of the form
``b"C[number]"`` in which case it raised a ValueError.
15 changes: 3 additions & 12 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,9 @@ def validate_color_or_auto(s):


def validate_color_for_prop_cycle(s):
# Special-case the N-th color cycle syntax, this obviously can not
# go in the color cycle.
if isinstance(s, bytes):
match = re.match(b'^C[0-9]$', s)
if match is not None:
raise ValueError('Can not put cycle reference ({cn!r}) in '
'prop_cycler'.format(cn=s))
elif isinstance(s, str):
match = re.match('^C[0-9]$', s)
if match is not None:
raise ValueError('Can not put cycle reference ({cn!r}) in '
'prop_cycler'.format(cn=s))
# N-th color cycle syntax can't go into the color cycle.
if isinstance(s, str) and re.match("^C[0-9]$", s):
raise ValueError(f"Cannot put cycle reference ({s!r}) in prop_cycler")
return validate_color(s)


Expand Down