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

Skip to content

Commit f3862ef

Browse files
authored
Merge pull request #16485 from anntzer/vcfpc
Simplify validate_color_for_prop_cycle.
2 parents 8135aad + c5c0f49 commit f3862ef

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,9 @@ deprecation warning.
100100

101101
Previously setting the *ecolor* would turn off automatic color cycling for the plot, leading to the
102102
the lines and markers defaulting to whatever the first color in the color cycle was in the case of
103-
multiple plot calls.
103+
multiple plot calls.
104+
105+
`.rcsetup.validate_color_for_prop_cycle` now always raises TypeError for bytes input
106+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107+
It previously raised `TypeError`, **except** when the input was of the form
108+
``b"C[number]"`` in which case it raised a ValueError.

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,9 @@ def validate_color_or_auto(s):
321321

322322

323323
def validate_color_for_prop_cycle(s):
324-
# Special-case the N-th color cycle syntax, this obviously can not
325-
# go in the color cycle.
326-
if isinstance(s, bytes):
327-
match = re.match(b'^C[0-9]$', s)
328-
if match is not None:
329-
raise ValueError('Can not put cycle reference ({cn!r}) in '
330-
'prop_cycler'.format(cn=s))
331-
elif isinstance(s, str):
332-
match = re.match('^C[0-9]$', s)
333-
if match is not None:
334-
raise ValueError('Can not put cycle reference ({cn!r}) in '
335-
'prop_cycler'.format(cn=s))
324+
# N-th color cycle syntax can't go into the color cycle.
325+
if isinstance(s, str) and re.match("^C[0-9]$", s):
326+
raise ValueError(f"Cannot put cycle reference ({s!r}) in prop_cycler")
336327
return validate_color(s)
337328

338329

0 commit comments

Comments
 (0)