From 9bf4238ade9599e489f49eaca81e9689859fc05c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 22 Jan 2017 22:52:51 -0800 Subject: [PATCH] Cleanup: use `is not` instead of `not ... is`, etc. --- lib/matplotlib/axes/_axes.py | 10 +++++----- lib/matplotlib/cbook/__init__.py | 7 ++----- lib/matplotlib/mlab.py | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index adc3d2d9b7e8..365194575349 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4002,16 +4002,16 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None, else: colors = None # use cmap, norm after collection is created - # Anything in maskargs will be unchanged unless it is the same length - # as x: - maskargs = x, y, s, c, colors, edgecolors, linewidths + # `delete_masked_points` only modifies arguments of the same length as + # `x`. x, y, s, c, colors, edgecolors, linewidths =\ - cbook.delete_masked_points(*maskargs) + cbook.delete_masked_points( + x, y, s, c, colors, edgecolors, linewidths) scales = s # Renamed for readability below. # to be API compatible - if marker is None and not (verts is None): + if marker is None and verts is not None: marker = (verts, 0) verts = None diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 2b438423e1e1..08e7f098d583 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -1497,15 +1497,12 @@ def __iter__(self): The iterator is invalid if interleaved with calls to join(). """ self.clean() - - class Token: - pass - token = Token() + token = object() # Mark each group as we come across if by appending a token, # and don't yield it twice for group in six.itervalues(self._mapping): - if not group[-1] is token: + if group[-1] is not token: yield [x() for x in group] group.append(token) diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index d5dd437f212d..ee456b7fc56b 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -3348,7 +3348,7 @@ def griddata(x, y, z, xi, yi, interp='nn'): # Remove masked points. mask = np.ma.getmask(z) - if not (mask is np.ma.nomask): + if mask is not np.ma.nomask: x = x.compress(~mask) y = y.compress(~mask) z = z.compressed()