Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1206f4

Browse files
committed
Cleanup: use is not instead of not ... is, etc.
1 parent 0384b85 commit c1206f4

File tree

4 files changed

+13
-32
lines changed

4 files changed

+13
-32
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,16 +3998,16 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
39983998
else:
39993999
colors = None # use cmap, norm after collection is created
40004000

4001-
# Anything in maskargs will be unchanged unless it is the same length
4002-
# as x:
4003-
maskargs = x, y, s, c, colors, edgecolors, linewidths
4001+
# `delete_masked_points` only modifies arguments of the same length as
4002+
# `x`.
40044003
x, y, s, c, colors, edgecolors, linewidths =\
4005-
cbook.delete_masked_points(*maskargs)
4004+
cbook.delete_masked_points(
4005+
x, y, s, c, colors, edgecolors, linewidths)
40064006

40074007
scales = s # Renamed for readability below.
40084008

40094009
# to be API compatible
4010-
if marker is None and not (verts is None):
4010+
if marker is None and verts is not None:
40114011
marker = (verts, 0)
40124012
verts = None
40134013

lib/matplotlib/backends/backend_pdf.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,27 +2336,11 @@ def delta(self, other):
23362336
cmds = []
23372337
fill_performed = False
23382338
for params, cmd in self.commands:
2339-
different = False
2340-
for p in params:
2341-
ours = getattr(self, p)
2342-
theirs = getattr(other, p)
2343-
try:
2344-
if (ours is None or theirs is None):
2345-
different = bool(not(ours is theirs))
2346-
else:
2347-
different = bool(ours != theirs)
2348-
except ValueError:
2349-
ours = np.asarray(ours)
2350-
theirs = np.asarray(theirs)
2351-
different = (ours.shape != theirs.shape or
2352-
np.any(ours != theirs))
2353-
if different:
2354-
break
2355-
2356-
# Need to update hatching if we also updated fillcolor
2357-
if params == ('_hatch',) and fill_performed:
2358-
different = True
2359-
2339+
different = (
2340+
any(not np.array_equal(getattr(self, p), getattr(other, p))
2341+
for p in params)
2342+
# Need to update hatching if we also updated fillcolor
2343+
or (params == ('_hatch',) and fill_performed))
23602344
if different:
23612345
if params == ('_fillcolor',):
23622346
fill_performed = True

lib/matplotlib/cbook/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,15 +1505,12 @@ def __iter__(self):
15051505
The iterator is invalid if interleaved with calls to join().
15061506
"""
15071507
self.clean()
1508-
1509-
class Token:
1510-
pass
1511-
token = Token()
1508+
token = object()
15121509

15131510
# Mark each group as we come across if by appending a token,
15141511
# and don't yield it twice
15151512
for group in six.itervalues(self._mapping):
1516-
if not group[-1] is token:
1513+
if group[-1] is not token:
15171514
yield [x() for x in group]
15181515
group.append(token)
15191516

lib/matplotlib/mlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3348,7 +3348,7 @@ def griddata(x, y, z, xi, yi, interp='nn'):
33483348

33493349
# Remove masked points.
33503350
mask = np.ma.getmask(z)
3351-
if not (mask is np.ma.nomask):
3351+
if mask is not np.ma.nomask:
33523352
x = x.compress(~mask)
33533353
y = y.compress(~mask)
33543354
z = z.compressed()

0 commit comments

Comments
 (0)