Skip to content

Commit daceb69

Browse files
committed
Further simplify _preprocess_data.
We don't need to evaluate needs_label at the top, we can just do it when needed. Also rename all_kwargs to args_and_kwargs, as it's really a mapping of all arg names to their values, whether they have been passed positionally or by keyword.
1 parent e445831 commit daceb69

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/matplotlib/__init__.py

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

13841384
bound = new_sig.bind(ax, *args, **kwargs)
1385-
needs_label = (label_namer
1386-
and "label" not in bound.arguments
1387-
and "label" not in bound.kwargs)
13881385
auto_label = (bound.arguments.get(label_namer)
13891386
or bound.kwargs.get(label_namer))
13901387

@@ -1403,10 +1400,10 @@ def inner(ax, *args, data=None, **kwargs):
14031400
new_args = bound.args
14041401
new_kwargs = bound.kwargs
14051402

1406-
if needs_label:
1407-
all_kwargs = {**bound.arguments, **bound.kwargs}
1403+
args_and_kwargs = {**bound.arguments, **bound.kwargs}
1404+
if label_namer and "label" not in args_and_kwargs:
14081405
new_kwargs["label"] = _label_from_arg(
1409-
all_kwargs.get(label_namer), auto_label)
1406+
args_and_kwargs.get(label_namer), auto_label)
14101407

14111408
return func(*new_args, **new_kwargs)
14121409

0 commit comments

Comments
 (0)