8000 Fixed rcParams validation of 'y', '1', '0' · matplotlib/matplotlib@f3764c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3764c5

Browse files
committed
Fixed rcParams validation of 'y', '1', '0'
1 parent 60417e3 commit f3764c5

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -538,24 +538,25 @@ def test_shadow_argument_types():
538538
ax.plot([1, 2, 3], label='test')
539539
shadows = [True, False, 'red', (0.1, 0.2, 0.5), 'tab:cyan', False]
540540

541-
legends = (ax.legend(loc='upper left', shadow=True), # True
542-
ax.legend(loc='upper right', shadow=False), # False
543-
ax.legend(loc='center left', shadow='red'), # Color string
544-
ax.legend(loc='center right', shadow=(0.1, 0.2, 0.5)), # Color tuple
545-
ax.legend(loc='lower left', shadow='tab:cyan') # Color tab
546-
)
547-
for l in legends:
541+
legs = (ax.legend(loc='upper left', shadow=True), # True
542+
ax.legend(loc='upper right', shadow=False), # False
543+
ax.legend(loc='center left', shadow='red'), # string
544+
ax.legend(loc='center right', shadow=(0.1, 0.2, 0.5)), # tuple
545+
ax.legend(loc='lower left', shadow='tab:cyan') # tab
546+
)
547+
for l in legs:
548548
ax.add_artist(l)
549549
ax.legend(loc='lower right') # default
550550

551-
legends = [c for c in ax.get_children() if isinstance(c, mpl.legend.Legend)]
552-
assert len(legends) == len(shadows)
553-
for i in range(len(legends)):
554-
assert legends[i].shadow == shadows[i]
551+
legs = [c for c in ax.get_children() if isinstance(c, mpl.legend.Legend)]
552+
assert len(legs) == len(shadows)
553+
for i in range(len(legs)):
554+
assert legs[i].shadow == shadows[i]
555555

556556
with pytest.raises(ValueError, match="color or bool"):
557557
ax.legend(loc="upper left", shadow="aardvark") # Bad argument
558558

559+
559560
def test_shadow_framealpha():
560561
# Test if framealpha is activated when shadow is True
561562
# and framealpha is not explicitly passed'''

lib/matplotlib/tests/test_rcparams.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,16 @@ def generate_validator_testcases(valid):
355355
((0, 1, 0), (0, 1, 0)), # non-string version
356356
('(0, 1, 0, 1)', (0.0, 1.0, 0.0, 1.0)), # RGBA tuple
357357
((0, 1, 0, 1), (0, 1, 0, 1)), # non-string version
358-
*((_, True) for _ in ('t', 'y', 'yes', 'on', 'true', '1', 1, True)),
359-
*((_, False) for _ in ('f', 'n', 'no', 'off', 'false', '0', 0, False))
358+
*((_, True) for _ in
359+
('t', 'yes', 'on', 'true', 1, True)),
360+
*((_, False) for _ in
361+
('f', 'n', 'no', 'off', 'false', 0, False)),
362+
# These last three are currently individually validated
363+
# both as colors and as bools. `validate_color_or_bool`
364+
# checks for color first, so they won't appear as boolean.
365+
('y', 'y'),
366+
('1', '1'),
367+
('0', '0')
360368
),
361369
'fail': (('tab:veryblue', ValueError), # invalid name
362370
('(0, 1)', ValueError), # tuple with length < 3

0 commit comments

Comments
 (0)
0