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

Skip to content

Commit ab524d9

Browse files
committed
Cleanups: rely on booleanness of lists.
1 parent 90f6eb8 commit ab524d9

9 files changed

Lines changed: 11 additions & 11 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ def axis(self, *v, **kwargs):
16501650
matplotlib.axes.Axes.set_ylim
16511651
"""
16521652

1653-
if len(v) == 0 and len(kwargs) == 0:
1653+
if len(v) == len(kwargs) == 0:
16541654
xmin, xmax = self.get_xlim()
16551655
ymin, ymax = self.get_ylim()
16561656
return xmin, xmax, ymin, ymax

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def _iter_collection_uses_per_path(self, paths, all_transforms,
465465
is not the same for every path.
466466
"""
467467
Npaths = len(paths)
468-
if Npaths == 0 or (len(facecolors) == 0 and len(edgecolors) == 0):
468+
if Npaths == 0 or len(facecolors) == len(edgecolors) == 0:
469469
return 0
470470
Npath_ids = max(Npaths, len(all_transforms))
471471
N = max(Npath_ids, len(offsets))

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _on_timer(self):
7171

7272
# Gtk timeout_add() requires that the callback returns True if it
7373
# is to be called again.
74-
if len(self.callbacks) > 0 and not self._single:
74+
if self.callbacks and not self._single:
7575
return True
7676
else:
7777
self._timer = None

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ def __init__(self, unit="", places=None, sep=" "):
12371237
def __call__(self, x, pos=None):
12381238
s = "%s%s" % (self.format_eng(x), self.unit)
12391239
# Remove the trailing separator when there is neither prefix nor unit
1240-
if len(self.sep) > 0 and s.endswith(self.sep):
1240+
if self.sep and s.endswith(self.sep):
12411241
s = s[:-len(self.sep)]
12421242
return self.fix_minus(s)
12431243

lib/matplotlib/tight_layout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
315315

316316
subplots.append(ax)
317317

318-
if (len(nrows_list) == 0) or (len(ncols_list) == 0):
318+
if len(nrows_list) == 0 or len(ncols_list) == 0:
319319
return {}
320320

321321
max_nrows = max(nrows_list)

lib/matplotlib/tri/triangulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_from_args_and_kwargs(*args, **kwargs):
137137
# Check triangles in kwargs then args.
138138
triangles = kwargs.pop('triangles', None)
139139
from_args = False
140-
if triangles is None and len(args) > 0:
140+
if triangles is None and args:
141141
triangles = args[0]
142142
from_args = True
143143

lib/matplotlib/type1font.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _read(self, file):
8282
return rawdata
8383

8484
data = b''
85-
while len(rawdata) > 0:
85+
while rawdata:
8686
if not rawdata.startswith(b'\x80'):
8787
raise RuntimeError('Broken pfb file (expected byte 128, '
8888
'got %d)' % ord(rawdata[0]))

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True,
525525
# of data and decides how to scale the view portal to fit it.
526526
if tight is None:
527527
# if image data only just use the datalim
528-
_tight = self._tight or (len(self.images)>0 and
529-
len(self.lines)==0 and
530-
len(self.patches)==0)
528+
_tight = self._tight or (
529+
len(self.images) > 0
530+
and len(self.lines) == len(self.patches) == 0)
531531
else:
532532
_tight = self._tight = bool(tight)
533533

setupext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def get_file_hash(filename):
267267
hasher = hashlib.sha256()
268268
with open(filename, 'rb') as fd:
269269
buf = fd.read(BLOCKSIZE)
270-
while len(buf) > 0:
270+
while buf:
271271
hasher.update(buf)
272272
buf = fd.read(BLOCKSIZE)
273273
return hasher.hexdigest()

0 commit comments

Comments
 (0)