From d474a98a37ef07ea702e31183ebbf9979288c67b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 6 Sep 2018 23:50:13 +0200 Subject: [PATCH] Various cleanups. - Document that in `margins()`, `tight` can be None, which is different from False (it keeps the previous setting). - Conversely, in two places, don't check for 'is True / is False', but just for normal truthiness. In particular, for the check on `get_clip_on()`, this is consistent with the check in `Artist.get_tightbbox()`. (Note that there are plently of other `is True` / `is False` checks in the codebase but they arise because the variable can also take some other values, e.g. a string or None.) - Fix a docstring. --- lib/matplotlib/axes/_base.py | 4 +--- lib/matplotlib/backend_tools.py | 2 -- lib/matplotlib/bezier.py | 2 +- lib/matplotlib/lines.py | 2 +- lib/matplotlib/mathtext.py | 16 ++++++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index d7bdc4a08475..1065effbad06 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2262,7 +2262,7 @@ def margins(self, *margins, x=None, y=None, tight=True): arguments, but can be used individually to alter on e.g., only the y-axis. - tight : bool, default is True + tight : bool or None, default is True The *tight* parameter is passed to :meth:`autoscale_view`, which is executed after a margin is changed; the default here is *True*, on the assumption that when margins are @@ -2270,7 +2270,6 @@ def margins(self, *margins, x=None, y=None, tight=True): usually desired. Set *tight* to *None* will preserve the previous setting. - Returns ------- xmargin, ymargin : float @@ -2282,7 +2281,6 @@ def margins(self, *margins, x=None, y=None, tight=True): the "sticky artists" will be modified. To force all of the margins to be set, set :attr:`use_sticky_edges` to `False` before calling :meth:`margins`. - """ if margins and x is not None and y is not None: diff --git a/lib/matplotlib/backend_tools.py b/lib/matplotlib/backend_tools.py index a913dbaf6dc7..4e5cd5789aed 100644 --- a/lib/matplotlib/backend_tools.py +++ b/lib/matplotlib/backend_tools.py @@ -190,7 +190,6 @@ def enable(self, event=None): `trigger` calls this method when `toggled` is False """ - pass def disable(self, event=None): @@ -206,7 +205,6 @@ def disable(self, event=None): * Another `ToolToggleBase` derived tool is triggered (from the same `ToolManager`) """ - pass @property diff --git a/lib/matplotlib/bezier.py b/lib/matplotlib/bezier.py index 0877038d5776..6eb42e3a86de 100644 --- a/lib/matplotlib/bezier.py +++ b/lib/matplotlib/bezier.py @@ -279,7 +279,7 @@ def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False): path_out = Path(concat([verts_right, path.vertices[i:]]), concat([codes_right, path.codes[i:]])) - if reorder_inout and begin_inside is False: + if reorder_inout and not begin_inside: path_in, path_out = path_out, path_in return path_in, path_out diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 18cc6d389b24..8ac215d34baf 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -683,7 +683,7 @@ def recache(self, always=False): self.axes.name == 'rectilinear' and self.axes.get_xscale() == 'linear' and self._markevery is None and - self.get_clip_on() is True): + self.get_clip_on()): self._subslice = True nanmask = np.isnan(x) if nanmask.any(): diff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py index 8be721ee3422..e7944ffe7d1b 100644 --- a/lib/matplotlib/mathtext.py +++ b/lib/matplotlib/mathtext.py @@ -45,13 +45,17 @@ # FONTS def get_unicode_index(symbol, math=True): - """get_unicode_index(symbol, [bool]) -> integer + r""" + Return the integer index (from the Unicode table) of *symbol*. -Return the integer index (from the Unicode table) of symbol. *symbol* -can be a single unicode character, a TeX command (i.e. r'\\pi'), or a -Type1 symbol name (i.e. 'phi'). -If math is False, the current symbol should be treated as a non-math symbol. -""" + Parameters + ---------- + symbol : str + A single unicode character, a TeX command (e.g. r'\pi') or a Type1 + symbol name (e.g. 'phi'). + math : bool, default is True + If False, always treat as a single unicode character. + """ # for a non-math symbol, simply return its unicode index if not math: return ord(symbol)