Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 199ee74

Browse files
author
Release Manager
committed
Trac #33563: fix some tests of emptiness
as suggested by {{{ pylint -d all -e C1801 src/sage }}} URL: https://trac.sagemath.org/33563 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): David Coudert
2 parents 596c5eb + bcedf4e commit 199ee74

File tree

20 files changed

+39
-48
lines changed

20 files changed

+39
-48
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=b96c0334857e7afceccdb63b4e9ccb0c2560961f
3-
md5=e18f9c50c26c1c4e6c004137fd9db79d
4-
cksum=2456915872
2+
sha1=8d686c033d3c8f745d0a6727c851f1293b9215a0
3+
md5=0909bbf96d514f3624c49247f2e39ac8
4+
cksum=1726119293
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d7a2f1f4880be729ef4d26ceaf3f1b8af941feb8
1+
d4f178fe1d70db93e9fe390905dc8f2ccc9b326c

src/sage/calculus/calculus.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,9 +1991,8 @@ def at(ex, *args, **kwds):
19911991
if len(args) == 1 and isinstance(args[0], list):
19921992
for c in args[0]:
19931993
kwds[str(c.lhs())] = c.rhs()
1994-
else:
1995-
if len(args):
1996-
raise TypeError("at can take at most one argument, which must be a list")
1994+
elif args:
1995+
raise TypeError("at can take at most one argument, which must be a list")
19971996

19981997
return ex.subs(**kwds)
19991998

@@ -2283,7 +2282,7 @@ def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima):
22832282
function_syms = {k: v for k, v in symbol_table.get('maxima', {}).items()
22842283
if _is_function(v)}
22852284

2286-
if not len(x):
2285+
if not x:
22872286
raise RuntimeError("invalid symbolic expression -- ''")
22882287
maxima.set('_tmp_', x)
22892288

src/sage/combinat/abstract_tree.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ def odd_nodes_tree(self, nodes, edges, matrix):
17311731
for i in range(split):
17321732
tmp(self[i], edge, nodes, edges, matrix)
17331733
# # prepare the root line
1734-
if len(matrix):
1734+
if matrix:
17351735
nb_of_and = matrix[0].count(sep)
17361736
sizetmp = len(matrix[0])
17371737
else:
@@ -1754,9 +1754,9 @@ def odd_nodes_tree(self, nodes, edges, matrix):
17541754
if self.is_empty():
17551755
empty_tree()
17561756
elif len(self) == 0 or all(subtree.is_empty()
1757-
for subtree in self):
1757+
for subtree in self):
17581758
one_node_tree(self)
1759-
elif len(self) % 2 == 0:
1759+
elif not len(self) % 2:
17601760
pair_nodes_tree(self, nodes, edges, matrix)
17611761
else:
17621762
odd_nodes_tree(self, nodes, edges, matrix)
@@ -1789,8 +1789,8 @@ def make_edges(edges):
17891789
("\n" +
17901790
path_begin +
17911791
"\n\t".join(make_edges(edges)) +
1792-
path_end if len(edges) else "")
1793-
if len(matrix) else "") +
1792+
path_end if edges else "")
1793+
if matrix else "") +
17941794
end_env +
17951795
"}")
17961796

src/sage/combinat/binary_tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,15 +2716,15 @@ def twisting_number(self):
27162716
return tn
27172717

27182718
L = self.comb('left')
2719-
if len(L):
2719+
if L:
27202720
tn[0] += 1
27212721
for h in L:
27222722
tw = BinaryTree([None, h]).twisting_number()
27232723
tn[0] += tw[0]
27242724
tn[1] += tw[1]
27252725

27262726
R = self.comb('right')
2727-
if len(R):
2727+
if R:
27282728
tn[1] += 1
27292729
for l in R:
27302730
tw = BinaryTree([l, None]).twisting_number()

src/sage/combinat/chas/wqsym.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def coproduct_on_basis(self, x):
646646
sage: M.coproduct( M([[1], [2]]) )
647647
M[] # M[{1}, {2}] + M[{1}] # M[{1}] + M[{1}, {2}] # M[]
648648
"""
649-
if not len(x):
649+
if not x:
650650
return self.one().tensor(self.one())
651651
K = self.indices()
652652

@@ -1212,7 +1212,7 @@ def coproduct_on_basis(self, x):
12121212
# The coproduct on the Q basis satisfies the same formula
12131213
# as on the M basis. This is easily derived from the
12141214
# formula on the M basis.
1215-
if not len(x):
1215+
if not x:
12161216
return self.one().tensor(self.one())
12171217
K = self.indices()
12181218

@@ -1723,7 +1723,7 @@ def coproduct_on_basis(self, x):
17231723
sage: AA(M(x).coproduct()) == x.coproduct()
17241724
True
17251725
"""
1726-
if not len(x):
1726+
if not x:
17271727
return self.one().tensor(self.one())
17281728
K = self.indices()
17291729

src/sage/combinat/fqsym.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def coproduct_on_basis(self, x):
639639
F[] # F[3, 2, 1] + F[1] # F[2, 1] + F[2, 1] # F[1]
640640
+ F[3, 2, 1] # F[]
641641
"""
642-
if not len(x):
642+
if not x:
643643
return self.one().tensor(self.one())
644644
return sum(self(Word(x[:i]).standard_permutation()).tensor(
645645
self(Word(x[i:]).standard_permutation()))

src/sage/geometry/polyhedron/backend_cdd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def parse_V_representation(intro, data):
334334
else:
335335
self.parent()._make_Vertex(self, coefficients)
336336
has_vertex = True
337-
if len(self._Vrepresentation) and not has_vertex:
337+
if self._Vrepresentation and not has_vertex:
338338
# when the Polyhedron consists only of lines/rays from the
339339
# origin, cddlib does not output the single vertex at the
340340
# origin so we have to add it here as the Polyhedron class

src/sage/geometry/polyhedron/base5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def _test_pyramid(self, tester=None, **options):
332332

333333
def check_pyramid_certificate(P, cert):
334334
others = set(v for v in P.vertices() if not v == cert)
335-
if len(others):
335+
if others:
336336
tester.assertTrue(any(set(f.ambient_Vrepresentation()) == others for f in P.facets()))
337337

338338
if self.is_compact():

src/sage/interfaces/gap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,14 +664,14 @@ def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if
664664
# them (on Python 3), currently just using the default encoding
665665
normal, error = bytes_to_str(normal), bytes_to_str(error)
666666

667-
if len(error):
667+
if error:
668668
if 'Error, Rebuild completion files!' in error:
669669
error += "\nRunning gap_reset_workspace()..."
670670
self.quit()
671671
gap_reset_workspace()
672672
error = error.replace('\r','')
673673
raise RuntimeError("%s produced error output\n%s\n executing %s"%(self, error,line))
674-
if not len(normal):
674+
if not normal:
675675
return ''
676676

677677
if isinstance(wait_for_prompt, str) and normal.ends_with(wait_for_prompt):
@@ -683,7 +683,7 @@ def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if
683683
else:
684684
n = 0
685685
out = normal[:-n]
686-
if len(out) and out[-1] == "\n":
686+
if out and out[-1] == "\n":
687687
out = out[:-1]
688688
return out
689689

0 commit comments

Comments
 (0)