Skip to content

Commit

Permalink
sagemathgh-39125: some care for pep8 E262 (comments)
Browse files Browse the repository at this point in the history
some care (partial) for pep8 code E262

E262 inline comment should start with '# '

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.

URL: sagemath#39125
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert, Frédéric Chapoton
  • Loading branch information
Release Manager committed Dec 15, 2024
2 parents bc78677 + 5518497 commit 48f0f6e
Show file tree
Hide file tree
Showing 30 changed files with 154 additions and 147 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=ebc4bd50c332f06ad5b2a4ce6217ec65790655ab
sha256=a2fa7623b406a7937ebfbe3cc6d9e17bcf0c219dec2646320b7266326d789b56
sha1=4bfbede9ee43afe8be5bb485ae0356a5f4356426
sha256=1361739b3a8f647f4bcddcc9829e70621a4350b12afdf7ba06f166bbd199e5f0
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a72ae6d615ddfd3e49b36c200aaf14c24a265916
a12f52bce924bfc10396fc379887bfabccbd45a2
2 changes: 1 addition & 1 deletion src/sage/categories/category_with_axiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2525,7 +2525,7 @@ def __init__(self, base_category):
Category_over_base_ring.__init__(self, base_category.base_ring())


class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom):#, Category_singleton, FastHashable_class):
class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom): # Category_singleton, FastHashable_class):
pass


Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/groupoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, G=None):
sage: C = Groupoid(S8)
sage: TestSuite(C).run()
"""
CategoryWithParameters.__init__(self) #, "Groupoid")
CategoryWithParameters.__init__(self) # "Groupoid")
if G is None:
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
G = SymmetricGroup(8)
Expand All @@ -56,8 +56,8 @@ def _repr_(self):
"""
return "Groupoid with underlying set %s" % self.__G

#def construction(self):
# return (self.__class__, self.__G)
# def construction(self):
# return (self.__class__, self.__G)

def _make_named_class_key(self, name):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/unital_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def one_from_one_basis(self):
sage: Aone().parent() is A # needs sage.combinat sage.modules
True
"""
return self.monomial(self.one_basis()) #.
return self.monomial(self.one_basis())

@lazy_attribute
def one(self):
Expand Down
25 changes: 12 additions & 13 deletions src/sage/coding/guruswami_sudan/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sage.matrix.constructor import matrix
from sage.misc.misc_c import prod

####################### Linear algebra system solving ###############################
# ###################### Linear algebra system solving ###############################


def _flatten_once(lstlst):
Expand All @@ -50,9 +50,9 @@ def _flatten_once(lstlst):
for lst in lstlst:
yield from lst

#*************************************************************
# *************************************************************
# Linear algebraic Interpolation algorithm, helper functions
#*************************************************************
# *************************************************************


def _monomial_list(maxdeg, l, wy):
Expand Down Expand Up @@ -137,9 +137,9 @@ def eqs_affine(x0, y0):
jhat = monomial[1]
if ihat >= i and jhat >= j:
icoeff = binomial(ihat, i) * x0**(ihat-i) \
if ihat > i else 1
if ihat > i else 1
jcoeff = binomial(jhat, j) * y0**(jhat-j) \
if jhat > j else 1
if jhat > j else 1
eq[monomial] = jcoeff * icoeff
eqs.append([eq.get(monomial, 0) for monomial in monomials])
return eqs
Expand Down Expand Up @@ -284,12 +284,12 @@ def gs_interpolation_linalg(points, tau, parameters, wy):
# Pick a nonzero element from the right kernel
sol = Ker.basis()[0]
# Construct the Q polynomial
PF = M.base_ring()['x', 'y'] #make that ring a ring in <x>
PF = M.base_ring()['x', 'y'] # make that ring a ring in <x>
x, y = PF.gens()
Q = sum([x**monomials[i][0] * y**monomials[i][1] * sol[i] for i in range(0, len(monomials))])
return Q
return sum([x**m[0] * y**m[1] * sol[i]
for i, m in enumerate(monomials)])

####################### Lee-O'Sullivan's method ###############################
# ###################### Lee-O'Sullivan's method ###############################


def lee_osullivan_module(points, parameters, wy):
Expand Down Expand Up @@ -397,12 +397,11 @@ def gs_interpolation_lee_osullivan(points, tau, parameters, wy):
from .utils import _degree_of_vector
s, l = parameters[0], parameters[1]
F = points[0][0].parent()
M = lee_osullivan_module(points, (s,l), wy)
shifts = [i * wy for i in range(0,l+1)]
M = lee_osullivan_module(points, (s, l), wy)
shifts = [i * wy for i in range(l + 1)]
Mnew = M.reduced_form(shifts=shifts)
# Construct Q as the element of the row with the lowest weighted degree
Qlist = min(Mnew.rows(), key=lambda r: _degree_of_vector(r, shifts))
PFxy = F['x,y']
xx, yy = PFxy.gens()
Q = sum(yy**i * PFxy(Qlist[i]) for i in range(0,l+1))
return Q
return sum(yy**i * PFxy(Qlist[i]) for i in range(l + 1))
32 changes: 16 additions & 16 deletions src/sage/combinat/diagram_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ def brauer_diagrams(k):
{{-3, 3}, {-2, 2}, {-1, 1}}]
"""
if k in ZZ:
s = list(range(1,k+1)) + list(range(-k,0))
s = list(range(1, k+1)) + list(range(-k,0))
for p in perfect_matchings_iterator(k):
yield [(s[a],s[b]) for a,b in p]
elif k + ZZ(1) / ZZ(2) in ZZ: # Else k in 1/2 ZZ
k = ZZ(k + ZZ(1) / ZZ(2))
elif k + ZZ.one() / 2 in ZZ: # Else k in 1/2 ZZ
k = ZZ(k + ZZ.one() / 2)
s = list(range(1, k)) + list(range(-k+1,0))
for p in perfect_matchings_iterator(k-1):
yield [(s[a],s[b]) for a,b in p] + [[k, -k]]
yield [(s[a], s[b]) for a, b in p] + [[k, -k]]


def temperley_lieb_diagrams(k):
Expand Down Expand Up @@ -1203,7 +1203,7 @@ def __init__(self, order, category=None):
self.order = ZZ(order)
base_set = frozenset(list(range(1,order+1)) + list(range(-order,0)))
else:
#order is a half-integer.
# order is a half-integer.
self.order = QQ(order)
base_set = frozenset(list(range(1,ZZ(ZZ(1)/ZZ(2) + order)+1))
+ list(range(ZZ(-ZZ(1)/ZZ(2) - order),0)))
Expand Down Expand Up @@ -4865,7 +4865,7 @@ def key_func(P):
count_left += 1
for j in range(i):
prop_intervals[j].append([bot])
for j in range(i+1,total_prop):
for j in range(i+1, total_prop):
prop_intervals[j].append([top])
if not left_moving:
top, bot = bot, top
Expand Down Expand Up @@ -4964,10 +4964,10 @@ def sgn(x):
for i in list(diagram):
l1.append(list(i))
l2.extend(list(i))
output = "\\begin{tikzpicture}[scale = 0.5,thick, baseline={(0,-1ex/2)}] \n\\tikzstyle{vertex} = [shape = circle, minimum size = 7pt, inner sep = 1pt] \n" #setup beginning of picture
for i in l2: #add nodes
output = "\\begin{tikzpicture}[scale = 0.5,thick, baseline={(0,-1ex/2)}] \n\\tikzstyle{vertex} = [shape = circle, minimum size = 7pt, inner sep = 1pt] \n" # setup beginning of picture
for i in l2: # add nodes
output = output + "\\node[vertex] (G-{}) at ({}, {}) [shape = circle, draw{}] {{}}; \n".format(i, (abs(i)-1)*1.5, sgn(i), filled_str)
for i in l1: #add edges
for i in l1: # add edges
if len(i) > 1:
l4 = list(i)
posList = []
Expand All @@ -4980,29 +4980,29 @@ def sgn(x):
posList.sort()
negList.sort()
l4 = posList + negList
l5 = l4[:] #deep copy
l5 = l4[:] # deep copy
for j in range(len(l5)):
l5[j-1] = l4[j] #create a permuted list
l5[j-1] = l4[j] # create a permuted list
if len(l4) == 2:
l4.pop()
l5.pop() #pops to prevent duplicating edges
l5.pop() # pops to prevent duplicating edges
for j in zip(l4, l5):
xdiff = abs(j[1])-abs(j[0])
y1 = sgn(j[0])
y2 = sgn(j[1])
if y2-y1 == 0 and abs(xdiff) < 5: #if nodes are close to each other on same row
diffCo = (0.5+0.1*(abs(xdiff)-1)) #gets bigger as nodes are farther apart; max value of 1; min value of 0.5.
if y2-y1 == 0 and abs(xdiff) < 5: # if nodes are close to each other on same row
diffCo = (0.5+0.1*(abs(xdiff)-1)) # gets bigger as nodes are farther apart; max value of 1; min value of 0.5.
outVec = (sgn(xdiff)*diffCo, -1*diffCo*y1)
inVec = (-1*diffCo*sgn(xdiff), -1*diffCo*y2)
elif y2-y1 != 0 and abs(xdiff) == 1: #if nodes are close enough curviness looks bad.
elif y2-y1 != 0 and abs(xdiff) == 1: # if nodes are close enough curviness looks bad.
outVec = (sgn(xdiff)*0.75, -1*y1)
inVec = (-1*sgn(xdiff)*0.75, -1*y2)
else:
outVec = (sgn(xdiff)*1, -1*y1)
inVec = (-1*sgn(xdiff), -1*y2)
output = output + "\\draw[{}] (G-{}) .. controls +{} and +{} .. {}(G-{}); \n".format(
edge_options(j), j[0], outVec, inVec, edge_additions(j), j[1])
output = output + "\\end{tikzpicture}" #end picture
output = output + "\\end{tikzpicture}" # end picture
return output


Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/growth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2592,11 +2592,11 @@ def forward_rule(self, y, e, t, f, x, content):
z, h = x, e
elif x == t != y:
z, h = y, e
else: # x != t and y != t
else: # x != t and y != t
qx = SkewPartition([x.to_partition(), t.to_partition()])
qy = SkewPartition([y.to_partition(), t.to_partition()])
if not all(c in qx.cells() for c in qy.cells()):
res = [(j-i) % self.k for i,j in qx.cells()]
res = [(j-i) % self.k for i, j in qx.cells()]
assert len(set(res)) == 1
r = res[0]
z = y.affine_symmetric_group_simple_action(r)
Expand Down
20 changes: 11 additions & 9 deletions src/sage/combinat/k_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,12 +1625,12 @@ def from_core_tableau(cls, t, k):
[[None, 2], [3]]
"""
t = SkewTableau(list(t))
shapes = [ Core(p, k+1).to_bounded_partition() for p in intermediate_shapes(t) ]#.to_chain() ]
shapes = [ Core(p, k+1).to_bounded_partition() for p in intermediate_shapes(t) ] # .to_chain() ]
if t.inner_shape() == Partition([]):
l = []
else:
l = [[None]*i for i in shapes[0]]
for i in range(1,len(shapes)):
for i in range(1, len(shapes)):
p = shapes[i]
if len(l) < len(p):
l += [[]]
Expand Down Expand Up @@ -2068,8 +2068,10 @@ def from_core_tableau(cls, t, k):
[s0*s3, s2*s1]
"""
t = SkewTableau(list(t))
shapes = [ Core(p, k+1).to_grassmannian() for p in intermediate_shapes(t) ] #t.to_chain() ]
perms = [ shapes[i]*(shapes[i-1].inverse()) for i in range(len(shapes)-1,0,-1)]
shapes = [Core(p, k + 1).to_grassmannian()
for p in intermediate_shapes(t)] # t.to_chain() ]
perms = [shapes[i] * (shapes[i - 1].inverse())
for i in range(len(shapes) - 1, 0, -1)]
return cls(perms, k, inner_shape=t.inner_shape())

def k_charge(self, algorithm='I'):
Expand Down Expand Up @@ -4222,16 +4224,16 @@ def _left_action_list( cls, Tlist, tij, v, k ):
"""
innershape = Core([len(r) for r in Tlist], k + 1)
outershape = innershape.affine_symmetric_group_action(tij, transposition=True)
if outershape.length() == innershape.length()+1:
if outershape.length() == innershape.length() + 1:
for c in SkewPartition([outershape.to_partition(),innershape.to_partition()]).cells():
while c[0] >= len(Tlist):
Tlist.append([])
Tlist[c[0]].append( v )
Tlist[c[0]].append(v)
if len(Tlist[c[0]])-c[0] == tij[1]:
Tlist[c[0]][-1] = -Tlist[c[0]][-1] #mark the cell that is on the j-1 diagonal
Tlist[c[0]][-1] = -Tlist[c[0]][-1] # mark the cell that is on the j-1 diagonal
return Tlist
else:
raise ValueError("%s is not a single step up in the strong lattice" % tij)

raise ValueError("%s is not a single step up in the strong lattice" % tij)

@classmethod
def follows_tableau_unsigned_standard( cls, Tlist, k ):
Expand Down
16 changes: 8 additions & 8 deletions src/sage/combinat/partition_kleshchev.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def conormal_cells(self, i=None):
carry[res] += 1
else:
res = KP._multicharge[0] + self[row] - row - 1
if row == len(self)-1 or self[row] > self[row+1]: # removable cell
if row == len(self)-1 or self[row] > self[row+1]: # removable cell
carry[res] -= 1
if row == 0 or self[row-1] > self[row]: #addable cell
if row == 0 or self[row-1] > self[row]: # addable cell
if carry[res+1] >= 0:
conormals[res+1].append((row, self[row]))
else:
Expand Down Expand Up @@ -661,25 +661,25 @@ def normal_cells(self, i=None):
part_lens = [len(part) for part in self] # so we don't repeatedly call these
KP = self.parent()
if KP._convention[0] == 'L':
rows = [(k,r) for k,ell in enumerate(part_lens) for r in range(ell+1)]
rows = [(k, r) for k, ell in enumerate(part_lens) for r in range(ell+1)]
else:
rows = [(k,r) for k,ell in reversed(list(enumerate(part_lens))) for r in range(ell+1)]
rows = [(k, r) for k, ell in reversed(list(enumerate(part_lens))) for r in range(ell+1)]
if KP._convention[1] == 'S':
rows.reverse()

for row in rows:
k,r = row
if r == part_lens[k]: # addable cell at bottom of a component
k, r = row
if r == part_lens[k]: # addable cell at bottom of a component
carry[KP._multicharge[k]-r] += 1
else:
part = self[k]
res = KP._multicharge[k] + (part[r] - r - 1)
if r == part_lens[k]-1 or part[r] > part[r+1]: # removable cell
if r == part_lens[k]-1 or part[r] > part[r+1]: # removable cell
if carry[res] == 0:
normals[res].insert(0, (k, r, part[r]-1))
else:
carry[res] -= 1
if r == 0 or part[r-1] > part[r]: #addable cell
if r == 0 or part[r-1] > part[r]: # addable cell
carry[res+1] += 1

# finally return the result
Expand Down
4 changes: 3 additions & 1 deletion src/sage/combinat/root_system/cartan_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,9 @@ def _samples(self):
[CartanType(t) for t in [["I", 5], ["H", 3], ["H", 4]]] + \
[t.affine() for t in finite_crystallographic if t.is_irreducible()] + \
[CartanType(t) for t in [["BC", 1, 2], ["BC", 5, 2]]] + \
[CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1], ["F", 4, 1], ["G", 2, 1],["BC", 1, 2], ["BC", 5, 2]]] #+ \
[CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1],
["F", 4, 1], ["G", 2, 1],
["BC", 1, 2], ["BC", 5, 2]]] # + \
# [ g ]

_colors = {1: 'blue', -1: 'blue',
Expand Down
28 changes: 14 additions & 14 deletions src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2284,28 +2284,28 @@ def _invert_morphism(self, n, base_ring,
sage: c2 == d2
True
"""
#Decide whether we know how to go from self to other or
#from other to self
# Decide whether we know how to go from self to other or
# from other to self
if to_other_function is not None:
known_cache = self_to_other_cache #the known direction
unknown_cache = other_to_self_cache #the unknown direction
known_cache = self_to_other_cache # the known direction
unknown_cache = other_to_self_cache # the unknown direction
known_function = to_other_function
else:
unknown_cache = self_to_other_cache #the known direction
known_cache = other_to_self_cache #the unknown direction
unknown_cache = self_to_other_cache # the known direction
known_cache = other_to_self_cache # the unknown direction
known_function = to_self_function

#Do nothing if we've already computed the inverse
#for degree n.
# Do nothing if we've already computed the inverse
# for degree n.
if n in known_cache and n in unknown_cache:
return

#Univariate polynomial arithmetic is faster
#over ZZ. Since that is all we need to compute
#the transition matrices between S and P, we
#should use that.
#Zt = ZZ['t']
#t = Zt.gen()
# Univariate polynomial arithmetic is faster
# over ZZ. Since that is all we need to compute
# the transition matrices between S and P, we
# should use that.
# Zt = ZZ['t']
# t = Zt.gen()
one = base_ring.one()
zero = base_ring.zero()

Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/six_vertex_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ def to_alternating_sign_matrix(self):
[ 0 1 -1 1]
[ 0 0 1 0]
"""
from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix #AlternatingSignMatrices
#ASM = AlternatingSignMatrices(self.parent()._nrows)
#return ASM(self.to_signed_matrix())
from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix # AlternatingSignMatrices
# ASM = AlternatingSignMatrices(self.parent()._nrows)
# return ASM(self.to_signed_matrix())
return AlternatingSignMatrix(self.to_signed_matrix())
6 changes: 3 additions & 3 deletions src/sage/databases/db_class_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

from .db_modular_polynomials import _dbz_to_integers

disc_format = "%07d" # disc_length = 7
level_format = "%03d" # level_length = 3
disc_format = "%07d" # disc_length = 7
level_format = "%03d" # level_length = 3


class ClassPolynomialDatabase:
Expand All @@ -52,7 +52,7 @@ def _dbpath(self, disc, level=1):
if level != 1:
raise NotImplementedError("Level (= %s) > 1 not yet implemented" % level)
n1 = 5000*((abs(disc)-1)//5000)
s1 = disc_format % (n1+1) #_pad_int(n1+1, disc_length)
s1 = disc_format % (n1+1) # _pad_int(n1+1, disc_length)
s2 = disc_format % (n1+5000)
subdir = "%s-%s" % (s1, s2)
discstr = disc_format % abs(disc)
Expand Down
Loading

0 comments on commit 48f0f6e

Please sign in to comment.