Skip to content

Commit 33264f6

Browse files
author
Release Manager
committed
gh-39892: some care for assert and not in pyx files fixing some suggestions of pycodestyle for code E275 ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39892 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents b159b4b + 2fe9f3d commit 33264f6

File tree

17 files changed

+39
-39
lines changed

17 files changed

+39
-39
lines changed

src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ cpdef find_construction_3_3(int k, int n):
292292
(11, 11, 16, 1)
293293
sage: find_construction_3_3(12,11)
294294
"""
295-
cdef int mm,nn,i
295+
cdef int mm, nn, i
296296
for mm in range(k-1, n//2+1):
297-
if not(is_available(k, mm) and is_available(k, mm + 1)):
297+
if not (is_available(k, mm) and is_available(k, mm + 1)):
298298
continue
299299

300300
for nn in range(2, n//mm+1):

src/sage/combinat/posets/hasse_cython.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class IncreasingChains(RecursivelyEnumeratedSet_forest):
116116
return True
117117
if self._conversion is not None:
118118
tup = [self._from_poset[elt] for elt in tup]
119-
if any(not(0 <= i < self._n) for i in tup):
119+
if not all(0 <= i < self._n for i in tup):
120120
return False
121121
y = tup[0]
122122
for k in range(1, len(tup)):

src/sage/combinat/rigged_configurations/rigged_partition.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ cdef class RiggedPartition(SageObject):
134134
"""
135135
# If it is empty, return saying so
136136
if not self._list:
137-
return("(/)\n")
137+
return "(/)\n"
138138

139139
from sage.combinat.partition import Partitions
140140
if Partitions.options.convention == "French":
@@ -148,7 +148,7 @@ cdef class RiggedPartition(SageObject):
148148
ret_str += "[ ]"*val
149149
ret_str += str(self.rigging[i])
150150
ret_str += "\n"
151-
return(ret_str)
151+
return ret_str
152152

153153
def _latex_(self):
154154
r"""
@@ -578,7 +578,7 @@ cdef class RiggedPartitionTypeB(RiggedPartition):
578578
"""
579579
# If it is empty, return saying so
580580
if not self._list:
581-
return("(/)\n")
581+
return "(/)\n"
582582

583583
from sage.combinat.partition import Partitions
584584
if Partitions.options.convention == "french":
@@ -599,7 +599,7 @@ cdef class RiggedPartitionTypeB(RiggedPartition):
599599
ret_str += box_str*val
600600
ret_str += str(self.rigging[i])
601601
ret_str += "\n"
602-
return(ret_str)
602+
return ret_str
603603

604604
def _latex_(self):
605605
r"""

src/sage/crypto/boolean_function.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ cdef long yellow_code(unsigned long a) noexcept:
100100
cdef unsigned long s = (8*sizeof(unsigned long)) >> 1
101101
cdef unsigned long m = (~0UL) >> s
102102
cdef unsigned long r = a
103-
while(s):
103+
while s:
104104
sig_check()
105105
r ^= (r&m) << s
106106
s >>= 1

src/sage/graphs/path_enumeration.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ def all_paths_iterator(self, starting_vertices=None, ending_vertices=None,
18551855
idx_to_path[idx] = path
18561856
pq.push((-len(path), idx))
18571857
idx = idx + 1
1858-
except(StopIteration):
1858+
except StopIteration:
18591859
pass
18601860
# Since we always extract a shortest path, using a heap
18611861
# can speed up the algorithm
@@ -1875,7 +1875,7 @@ def all_paths_iterator(self, starting_vertices=None, ending_vertices=None,
18751875
idx_to_path[idx] = path
18761876
pq.push((-len(path), idx))
18771877
idx = idx + 1
1878-
except(StopIteration):
1878+
except StopIteration:
18791879
pass
18801880

18811881

src/sage/graphs/strongly_regular_db.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,8 +2617,8 @@ def SRG_630_85_20_10():
26172617
hs = HoffmanSingletonGraph()
26182618
P = list(range(5)) + list(range(30, 35)) # a Petersen in hs
26192619
mc = [0, 1, 5, 6, 12, 13, 16, 17, 22, 23, 29, 33, 39, 42, 47]
2620-
assert(hs.subgraph(mc).is_regular(k=0)) # a maximum coclique
2621-
assert(hs.subgraph(P).is_regular(k=3))
2620+
assert hs.subgraph(mc).is_regular(k=0) # a maximum coclique
2621+
assert hs.subgraph(P).is_regular(k=3)
26222622
h = hs.automorphism_group().stabilizer(mc, action='OnSets')
26232623
l = h.orbit(tuple((x[0], x[1]) for x in hs.subgraph(P).matching()),
26242624
"OnSetsSets")

src/sage/groups/perm_gps/permgroup_element.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
565565
('b','c')
566566
"""
567567
cdef int i, j, vn = len(v)
568-
assert(vn <= self.n)
568+
assert vn <= self.n
569569
if convert:
570570
convert_dict = self._parent._domain_to_gap
571571
for i in range(len(v)):

src/sage/libs/singular/function.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,19 +629,19 @@ cdef class Converter(SageObject):
629629
3
630630
"""
631631
cdef leftv * v
632-
v=self.args
632+
v = self.args
633633
cdef int l
634-
l=0
634+
l = 0
635635
while v != NULL:
636-
l=l+1
637-
v=v.next
636+
l += 1
637+
v = v.next
638638
return l
639639

640640
cdef leftv* pop_front(self) except NULL:
641641
"""
642642
Pop a Singular element from the front of the list.
643643
"""
644-
assert(self.args != NULL)
644+
assert self.args != NULL
645645
cdef leftv *res = self.args
646646
self.args = self.args.next
647647
res.next = NULL

src/sage/libs/singular/ring.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,9 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
579579
_ring.ShortOut = 0
580580

581581
if order.is_local():
582-
assert(_ring.OrdSgn == -1)
582+
assert _ring.OrdSgn == -1
583583
if order.is_global():
584-
assert(_ring.OrdSgn == 1)
584+
assert _ring.OrdSgn == 1
585585

586586
return _ring
587587

src/sage/matrix/matrix0.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ cdef class Matrix(sage.structure.element.Matrix):
531531
sage: A.is_mutable()
532532
False
533533
"""
534-
return not(self._is_immutable)
534+
return not self._is_immutable
535535

536536
###########################################################
537537
# Entry access
@@ -5140,9 +5140,9 @@ cdef class Matrix(sage.structure.element.Matrix):
51405140
fac = o1.factor()
51415141
S = sum((pi - 1) * pi**(ei - 1) for pi, ei in fac)
51425142
if fac[0] == (2, 1):
5143-
impossible_order = not(S <= n + 1)
5143+
impossible_order = S > n + 1
51445144
else:
5145-
impossible_order = not(S <= n)
5145+
impossible_order = S > n
51465146
if impossible_order:
51475147
return Infinity
51485148

0 commit comments

Comments
 (0)