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

Skip to content

Commit daab0fc

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR #16613: Fix edge-case in preprocess_data, if label_namer is optional and unset.
1 parent 5411431 commit daab0fc

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/matplotlib/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,9 +1543,6 @@ def inner(ax, *args, data=None, **kwargs):
15431543
return func(ax, *map(sanitize_sequence, args), **kwargs)
15441544

15451545
bound = new_sig.bind(ax, *args, **kwargs)
1546-
needs_label = (label_namer
1547-
and "label" not in bound.arguments
1548-
and "label" not in bound.kwargs)
15491546
auto_label = (bound.arguments.get(label_namer)
15501547
or bound.kwargs.get(label_namer))
15511548

@@ -1564,12 +1561,10 @@ def inner(ax, *args, data=None, **kwargs):
15641561
new_args = bound.args
15651562
new_kwargs = bound.kwargs
15661563

1567-
if needs_label:
1568-
all_kwargs = {**bound.arguments, **bound.kwargs}
1569-
# label_namer will be in all_kwargs as we asserted above that
1570-
# `label_namer is None or label_namer in arg_names`.
1564+
args_and_kwargs = {**bound.arguments, **bound.kwargs}
1565+
if label_namer and "label" not in args_and_kwargs:
15711566
new_kwargs["label"] = _label_from_arg(
1572-
all_kwargs[label_namer], auto_label)
1567+
args_and_kwargs.get(label_namer), auto_label)
15731568

15741569
return func(*new_args, **new_kwargs)
15751570

0 commit comments

Comments
 (0)