From ef9e41860aa6617ca2211b9c9043414c02483237 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 4 Jan 2019 22:41:53 +0100 Subject: [PATCH] Make GridSpec.update docstring match behavior. The sentence "If any kwarg is None, default to the current value, if set, otherwise to rc." is clearly wrong given the lines just below, which overwrite the current value unconditonally: for k, v in kwargs.items(): if k in self._AllowedKeys: setattr(self, k, v) This can also be checked with e.g. from matplotlib.gridspec import GridSpec from matplotlib import pyplot as plt gs = GridSpec(1, 1, left=.5) gs.update(left=None) plt.figure().add_subplot(gs[0, 0]) plt.show() where the update reset left to the rc value. Given that the behavior has been like that ever since gridspec was added to matplotlib, it seems better to update the docstring. --- lib/matplotlib/gridspec.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index 222c67d66a17..f62e4db1c582 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -255,16 +255,15 @@ def __setstate__(self, state): def update(self, **kwargs): """ - Update the current values. If any kwarg is None, default to - the current value, if set, otherwise to rc. - """ + Update the current values. + Values set to None use the rcParams value. + """ for k, v in kwargs.items(): if k in self._AllowedKeys: setattr(self, k, v) else: - raise AttributeError("%s is unknown keyword" % (k,)) - + raise AttributeError(f"{k} is an unknown keyword") for figmanager in _pylab_helpers.Gcf.figs.values(): for ax in figmanager.canvas.figure.axes: # copied from Figure.subplots_adjust