8000 Merge pull request #12969 from anntzer/getsetdefaults · matplotlib/matplotlib@e8be5f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit e8be5f7

Browse files
authored
Merge pull request #12969 from anntzer/getsetdefaults
Clarify the implementation of _process_plot_var_args.
2 parents 8ba0972 + 3a2abb5 commit e8be5f7

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -280,27 +280,15 @@ def _xy_from_xy(self, x, y):
280280
y = y[:, np.newaxis]
281281
return x, y
282282

283-
def _getdefaults(self, ignore, *kwargs):
283+
def _getdefaults(self, ignore, kw):
284284
"""
285-
Only advance the cycler if the cycler has information that
286-
is not specified in any of the supplied tuple of dicts.
287-
Ignore any keys specified in the `ignore` set.
288-
289-
Returns a copy of defaults dictionary if there are any
290-
keys that are not found in any of the supplied dictionaries.
291-
If the supplied dictionaries have non-None values for
292-
everything the property cycler has, then just return
293-
an empty dictionary. Ignored keys are excluded from the
294-
returned dictionary.
295-
285+
If some keys in the property cycle (excluding those in the set
286+
*ignore*) are absent or set to None in the dict *kw*, return a copy
287+
of the next entry in the property cycle, excluding keys in *ignore*.
288+
Otherwise, don't advance the property cycle, and return an empty dict.
296289
"""
297-
prop_keys = self._prop_keys
298-
if ignore is None:
299-
ignore = set()
300-
prop_keys = prop_keys - ignore
301-
302-
if any(all(kw.get(k, None) is None for kw in kwargs)
303-
for k in prop_keys):
290+
prop_keys = self._prop_keys - ignore
291+
if any(kw.get(k, None) is None for k in prop_keys):
304292
# Need to copy this dictionary or else the next time around
305293
# in the cycle, the dictionary could be missing entries.
306294
default_dict = next(self.prop_cycler).copy()
@@ -310,21 +298,18 @@ def _getdefaults(self, ignore, *kwargs):
310298
default_dict = {}
311299
return default_dict
312300

313-
def _setdefaults(self, defaults, *kwargs):
301+
def _setdefaults(self, defaults, kw):
314302
"""
315-
Given a defaults dictionary, and any other dictionaries,
316-
update those other dictionaries with information in defaults if
317-
none of the other dictionaries contains that information.
318-
303+
Add to the dict *kw* the entries in the dict *default* that are absent
304+
or set to None in *kw*.
319305
"""
320306
for k in defaults:
321-
if all(kw.get(k, None) is None for kw in kwargs):
322-
for kw in kwargs:
323-
kw[k] = defaults[k]
307+
if kw.get(k, None) is None:
308+
kw[k] = defaults[k]
324309

325310
def _makeline(self, x, y, kw, kwargs):
326311
kw = {**kw, **kwargs} # Don't modify the original kw.
327-
default_dict = self._getdefaults(None, kw)
312+
default_dict = self._getdefaults(set(), kw)
328313
self._setdefaults(default_dict, kw)
329314
seg = mlines.Line2D(x, y, **kw)
330315
return seg
@@ -425,8 +410,6 @@ def _plot_args(self, tup, kwargs):
425410

426411

427412
class _AxesBase(martist.Artist):
428-
"""
429-
"""
430413
name = "rectilinear"
431414

432415
_shared_x_axes = cbook.Grouper()

0 commit comments

Comments
 (0)
0