Skip to content

Commit

Permalink
gh-38862: some spaces around % in pyx files
Browse files Browse the repository at this point in the history
    
adding spaces around modulo signs in some pyx files (pycodestyle E228)

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
    
URL: #38862
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Nov 2, 2024
2 parents 2e287ac + e15036f commit 002c38e
Show file tree
Hide file tree
Showing 37 changed files with 112 additions and 111 deletions.
2 changes: 1 addition & 1 deletion src/sage/coding/codecan/autgroup_can_label.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class LinearCodeAutGroupCanLabel:
from sage.coding.linear_code import LinearCode, AbstractLinearCode

if not isinstance(C, AbstractLinearCode):
raise TypeError("%s is not a linear code"%C)
raise TypeError("%s is not a linear code" % C)

self.C = C
mat = C.generator_matrix()
Expand Down
12 changes: 6 additions & 6 deletions src/sage/combinat/rigged_configurations/rigged_partition.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ cdef class RiggedPartition(SageObject):

from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations
if RiggedConfigurations.options.convention == 'English':
ret_string += "\\cline{2-%s} "%(1+num_cols) + latex(self.vacancy_numbers[0])
ret_string += "\\cline{2-%s} " % (1+num_cols) + latex(self.vacancy_numbers[0])
for i, row_len in enumerate(self._list):

ret_string += " &" + "\\phantom{|}&"*row_len
Expand All @@ -210,7 +210,7 @@ cdef class RiggedPartition(SageObject):
ret_string += "\n\\end{array}\n}"
else:
for i, row_len in enumerate(reversed(self._list)):
ret_string += "\\cline{2-%s} "%(1 + row_len) + latex(self.vacancy_numbers[-i-1])
ret_string += "\\cline{2-%s} " % (1 + row_len) + latex(self.vacancy_numbers[-i-1])
ret_string += " &" + "\\phantom{|}&"*row_len

if num_cols == row_len:
Expand All @@ -220,7 +220,7 @@ cdef class RiggedPartition(SageObject):
ret_string += "}{l}{" + latex(self.rigging[-i-1]) + "}"

ret_string += " \\\\\n"
ret_string += "\\cline{2-%s}\n\\end{array}\n}"%(1 + num_cols)
ret_string += "\\cline{2-%s}\n\\end{array}\n}" % (1 + num_cols)

return ret_string

Expand Down Expand Up @@ -645,7 +645,7 @@ cdef class RiggedPartitionTypeB(RiggedPartition):
ret_string = "{\n\\begin{array}[t]{r|" + "c|"*num_cols + "l}\n"

if RiggedConfigurations.options.convention == 'English':
ret_string += "\\cline{2-%s} "%(1+num_cols) + latex(self.vacancy_numbers[0])
ret_string += "\\cline{2-%s} " % (1+num_cols) + latex(self.vacancy_numbers[0])
for i, row_len in enumerate(self._list):
ret_string += " &" + box_str*row_len

Expand All @@ -663,7 +663,7 @@ cdef class RiggedPartitionTypeB(RiggedPartition):
ret_string += "\n\\end{array}\n}"
else:
for i, row_len in enumerate(reversed(self._list)):
ret_string += "\\cline{2-%s} "%(1 + row_len)
ret_string += "\\cline{2-%s} " % (1 + row_len)
ret_string += latex(self.vacancy_numbers[-i-1])
ret_string += " &" + box_str*row_len

Expand All @@ -674,6 +674,6 @@ cdef class RiggedPartitionTypeB(RiggedPartition):
ret_string += "}{l}{" + latex(self.rigging[-i-1]) + "}"

ret_string += " \\\\\n"
ret_string += "\\cline{2-%s}\n\\end{array}\n}"%(1 + num_cols)
ret_string += "\\cline{2-%s}\n\\end{array}\n}" % (1 + num_cols)

return ret_string
2 changes: 1 addition & 1 deletion src/sage/groups/group.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ cdef class Group(Parent):
if not isinstance(category, tuple):
category = (category,)
if not any(cat.is_subcategory(Groups()) for cat in category):
raise ValueError("%s is not a subcategory of %s"%(category, Groups()))
raise ValueError("%s is not a subcategory of %s" % (category, Groups()))
Parent.__init__(self, base=base, category=category)

def is_abelian(self):
Expand Down
38 changes: 19 additions & 19 deletions src/sage/groups/perm_gps/partn_ref/data_structures.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def OP_represent(int n, merges, perm):
print("Finding:")
for i in range(n):
j = OP_find(OP, i)
s = "%d -> %d"%(i, j)
s = "%d -> %d" % (i, j)
if i == j:
s += ", root: size=%d, mcr=%d, rank=%d"%\
s += ", root: size=%d, mcr=%d, rank=%d" % \
(OP.size[i], OP.mcr[i], OP.rank[i])
print(s)
print("Allocating array to test merge_perm.")
Expand All @@ -165,9 +165,9 @@ def OP_represent(int n, merges, perm):
print("Finding:")
for i in range(n):
j = OP_find(OP, i)
s = "%d -> %d"%(i, j)
s = "%d -> %d" % (i, j)
if i == j:
s += ", root: size=%d, mcr=%d, rank=%d"%\
s += ", root: size=%d, mcr=%d, rank=%d" % \
(OP.size[i], OP.mcr[i], OP.rank[i])
print(s)
print("Deallocating OrbitPartition.")
Expand Down Expand Up @@ -474,7 +474,7 @@ def PS_represent(partition, splits):
print(PS.entries[i], PS.levels[i], i, n)
good = False
if not (PS.entries[n-1] == n-1 and PS.levels[n-1] == -1):
print("Failed at i = %d!"%(n-1))
print("Failed at i = %d!" % (n-1))
good = False
if not PS.degree == n or not PS.depth == 0:
print("Incorrect degree or depth!")
Expand All @@ -486,8 +486,8 @@ def PS_represent(partition, splits):
print("Creating PartitionStack from partition %s." % partition)
PS = PS_from_list(partition)
print("PartitionStack's data:")
print("entries -> %s"%[PS.entries[i] for i in range(n)])
print("levels -> %s"%[PS.levels[i] for i in range(n)])
print("entries -> %s" % [PS.entries[i] for i in range(n)])
print("levels -> %s" % [PS.levels[i] for i in range(n)])
print("depth = %d, degree = %d" % (PS.depth,PS.degree))
PS_print(PS)
print("Checking PS_is_discrete:")
Expand All @@ -506,7 +506,7 @@ def PS_represent(partition, splits):
good = True
for i in range(n):
if PS.entries[i] != PS2.entries[i] or PS.levels[i] != PS2.levels[i]:
print("Failed at i = %d!"%i)
print("Failed at i = %d!" % i)
good = False
if PS.degree != PS2.degree or PS.depth != PS2.depth:
print("Failure with degree or depth!")
Expand All @@ -517,7 +517,7 @@ def PS_represent(partition, splits):
PS_clear(PS2)
PS_print(PS2)
for s in splits:
print("Splitting point %d from original:"%s)
print("Splitting point %d from original:" % s)
print(PS_split_point(PS, s))
PS_print(PS)
print("Getting permutation from PS2->PS:")
Expand All @@ -528,7 +528,7 @@ def PS_represent(partition, splits):
print("Finding first smallest:")
bitset_init(b, n)
i = PS_first_smallest(PS, b)
print("Minimal element is %d, bitset is:"%i)
print("Minimal element is %d, bitset is:" % i)
print(bitset_string(b))
bitset_free(b)
print("Finding element 1:")
Expand Down Expand Up @@ -1187,7 +1187,7 @@ cdef bint SC_is_giant(int n, int num_perms, int *perms, float p, bitset_t suppor
# get a bit lost in the group, so our random elements are more random:
SC_identify(perm, n)
for i from 0 <= i < 10:
SC_mult_perms(perm, perm, perms + n*(rand()%num_perms), n)
SC_mult_perms(perm, perm, perms + n*(rand() % num_perms), n)

# look for elements with cycles of prime length q, m/2 < q < m-2
num_steps = <int> ceil(-log(1-p)*log(m)/log(2))
Expand All @@ -1203,7 +1203,7 @@ cdef bint SC_is_giant(int n, int num_perms, int *perms, float p, bitset_t suppor
sig_free(perm)
OP_dealloc(OP)
return True
SC_mult_perms(perm, perm, perms + n*(rand()%num_perms), n)
SC_mult_perms(perm, perm, perms + n*(rand() % num_perms), n)
OP_dealloc(OP)
sig_free(perm)
return False
Expand Down Expand Up @@ -1421,21 +1421,21 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain,
m = bitset_len(giant_support)
from sage.arith.misc import factorial
if not (order == factorial(m) or order == factorial(m)/2):
print("SC_is_giant failed: %s %s"%(str(L), order))
print("SC_is_giant failed: %s %s" % (str(L), order))
raise AssertionError
if order == factorial(n):
SC_dealloc(SC)
SC = SC_symmetric_group(n)
SC_order(SC,0,order.value)
if not order == factorial(n):
print("SC_symmetric_group failed: %s %s"%(str(L), order))
print("SC_symmetric_group failed: %s %s" % (str(L), order))
raise AssertionError
elif order == factorial(n)/2:
SC_dealloc(SC)
SC = SC_alternating_group(n)
SC_order(SC,0,order.value)
if not order == factorial(n)/2:
print("SC_alternating_group failed: %s %s"%(str(L), order))
print("SC_alternating_group failed: %s %s" % (str(L), order))
raise AssertionError
order2 = Integer(0)
SC_order(SCC,0,order2.value)
Expand Down Expand Up @@ -1540,8 +1540,8 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain,
if SC_is_giant(n, len(L), perm, 0.9, giant_support):
from sage.arith.misc import factorial
m = bitset_len(giant_support)
if order != factorial(m) and order != factorial(m)/2:
print("SC_is_giant failed: %s %s"%(str(L), order))
if order != factorial(m) and order != factorial(m)//2:
print("SC_is_giant failed: %s %s" % (str(L), order))
raise AssertionError
if order != G.order():
print("FAIL {}".format(L))
Expand Down Expand Up @@ -1572,13 +1572,13 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain,
if bool(SC_says) != bool(gap_says):
print("FAIL {}".format(L))
print('element {}'.format(permy))
print('GAP says %d, SC_contains(modify=0) says %d'%(gap_says, SC_says))
print('GAP says %d, SC_contains(modify=0) says %d' % (gap_says, SC_says))
raise AssertionError
SC_says = SC_contains(SC, 0, perm, 1)
if bool(SC_says) != bool(gap_says):
print("FAIL {}".format(L))
print('element {}'.format(permy))
print('GAP says %d, SC_contains(modify=0) says %d'%(gap_says, SC_says))
print('GAP says %d, SC_contains(modify=0) says %d' % (gap_says, SC_says))
raise AssertionError
SC_random_element(SC, 0, perm)
for j from 0 <= j < n:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/partn_ref/refinement_python.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cdef class PythonPartitionStack:
sage: P # implicit doctest
PythonPartitionStack of degree 7 and depth 0.
"""
return "PythonPartitionStack of degree %d and depth %d."%(self.c_ps.degree, self.c_ps.depth)
return "PythonPartitionStack of degree %d and depth %d." % (self.c_ps.degree, self.c_ps.depth)

def display(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/perm_gps/permgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
...
AssertionError: (1,3,5)(2,4,6) and [1, 2, 3, 4, 5, 6, 7] should have the same length
"""
assert len(x) == self.n, '%s and %s should have the same length'%(self, x)
assert len(x) == self.n, '%s and %s should have the same length' % (self, x)
return [ x[self.perm[i]] for i in range(self.n) ]

cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x):
Expand All @@ -1146,7 +1146,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
cdef int i
cdef ClonableIntArray y
cdef int l = self.n
assert x._len == l, '%s and %s should have the same length'%(self, x)
assert x._len == l, '%s and %s should have the same length' % (self, x)
y = x.clone()
for i in range(l):
y._list[i] = x._list[self.perm[i]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement):
sage: SemimonomialTransformationGroup(F, 4).an_element() # indirect doctest
((a, 1, 1, 1); (1,4,3,2), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1)
"""
return "(%s; %s, %s)"%(self.v, self.perm.cycle_string(),
self.get_autom())
return "(%s; %s, %s)" % (self.v, self.perm.cycle_string(),
self.get_autom())

cpdef _richcmp_(left, _right, int op):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/sage/libs/coxeter3/coxeter.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ cdef class CoxGroup(SageObject):
sage: W = CoxGroup(['A', 5]); W
Coxeter group of type A and rank 5
"""
return "Coxeter group of type %s and rank %s"%(self.type(), self.rank())
return "Coxeter group of type %s and rank %s" % (self.type(),
self.rank())

def __iter__(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/eclib/homspace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cdef class ModularSymbols:
sage: CremonaModularSymbols(37, cuspidal=True).__repr__()
'Cremona Cuspidal Modular Symbols space of dimension 4 for Gamma_0(37) of weight 2 with sign 0'
"""
return "Cremona %sModular Symbols space of dimension %s for Gamma_0(%s) of weight 2 with sign %s"%(
return "Cremona %sModular Symbols space of dimension %s for Gamma_0(%s) of weight 2 with sign %s" % (
'Cuspidal ' if self.is_cuspidal() else '',
self.dimension(), self.level(), self.sign())

Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/eclib/mat.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cdef class Matrix:
[-1 1 1 -1 0]
[ 0 -1 0 0 0]
"""
return "%s x %s Cremona matrix over Rational Field"%(self.nrows(), self.ncols())
return "%s x %s Cremona matrix over Rational Field" % (self.nrows(), self.ncols())

def str(self):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/eclib/mwrank.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ cdef class _bigint:
if s.isdigit() or s[0] == "-" and s[1:].isdigit():
self.x = str_to_bigint(str_to_bytes(s))
else:
raise ValueError("invalid _bigint: %r"%x)
raise ValueError("invalid _bigint: %r" % x)

def __dealloc__(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/eclib/newforms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ cdef class ECModularSymbol:
sage: M = ECModularSymbol(E, 0); M
Modular symbol with sign 0 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
"""
return "Modular symbol with sign %s over Rational Field attached to %s"%(self.sign, self._E)
return "Modular symbol with sign %s over Rational Field attached to %s" % (self.sign, self._E)

def __call__(self, r, sign=None, base_at_infinity=True):
r"""
Expand Down
Loading

0 comments on commit 002c38e

Please sign in to comment.