Skip to content

Commit e05f75f

Browse files
committed
more fixes for E228 and E225 in combinat and some other folders
1 parent 4d3e807 commit e05f75f

28 files changed

+330
-330
lines changed

src/sage/combinat/affine_permutation.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def grassmannian_quotient(self, i=0, side='right'):
394394
while not (D == [i] or D == []):
395395
m = D[0]
396396
if m == i:
397-
m=D[1]
397+
m = D[1]
398398
if side == 'right':
399399
fin = fin.apply_simple_reflection(m, side='left')
400400
gr = gr.apply_simple_reflection(m, side='right')
@@ -470,7 +470,7 @@ def value(self, i, base_window=False):
470470
if base_window:
471471
self[i-1]
472472
window = (i-1) // (self.k+1)
473-
return self[(i-1)%(self.k+1)] + window*(self.k+1)
473+
return self[(i-1) % (self.k+1)] + window*(self.k+1)
474474

475475
def position(self, i):
476476
r"""
@@ -518,7 +518,7 @@ def apply_simple_reflection_right(self, i):
518518
if j == 0:
519519
a = l[0]
520520
l[0] = l[-1] - (self.k+1)
521-
l[-1] = a +(self.k+1)
521+
l[-1] = a + (self.k+1)
522522
else:
523523
a = l[j-1]
524524
l[j-1] = l[j]
@@ -589,7 +589,7 @@ def has_right_descent(self, i) -> bool:
589589
sage: p.has_right_descent(0)
590590
False
591591
"""
592-
return self.value(i)>self.value(i+1)
592+
return self.value(i) > self.value(i+1)
593593

594594
def has_left_descent(self, i) -> bool:
595595
r"""
@@ -708,20 +708,20 @@ def maximal_cyclic_factor(self, typ='decreasing', side='right', verbose=False):
708708
j = i
709709
for _ in range(1, self.k):
710710
if (typ[0],side[0]) == ('d', 'r'):
711-
j=(j+1)%(k+1)
711+
j = (j+1) % (k+1)
712712
if (typ[0],side[0]) == ('i', 'r'):
713-
j=(j-1)%(k+1)
713+
j = (j-1) % (k+1)
714714
if (typ[0],side[0]) == ('d', 'l'):
715-
j=(j-1)%(k+1)
715+
j = (j-1) % (k+1)
716716
if (typ[0],side[0]) == ('i', 'l'):
717-
j=(j+1)%(k+1)
717+
j = (j+1) % (k+1)
718718
if y.has_descent(j, side):
719-
y=y.apply_simple_reflection(j,side)
720-
T.append(j%(k+1))
719+
y = y.apply_simple_reflection(j,side)
720+
T.append(j % (k+1))
721721
if verbose:
722722
print(i, T)
723723
if len(T) > len(best_T):
724-
best_T=T
724+
best_T = T
725725
#if (typ[0],side[0])==('i','r'): best_T.reverse()
726726
#if (typ[0],side[0])==('d','l'): best_T.reverse()
727727
#if typ[0]=='d': best_T.reverse()
@@ -791,7 +791,7 @@ def maximal_cyclic_decomposition(self, typ='decreasing', side='right', verbose=F
791791
y = y.apply_simple_reflection_left(i)
792792
if verbose:
793793
print(S, y.length())
794-
if side[0]=='r':
794+
if side[0] == 'r':
795795
listy.reverse()
796796
return listy
797797

@@ -848,13 +848,13 @@ def to_lehmer_code(self, typ='decreasing', side='right'):
848848
#value than the number in position i. Then cyclically shift
849849
#the resulting vector.
850850
for i in range(self.k+1):
851-
a=self(i)
851+
a = self(i)
852852
for j in range(i-self.k, i):
853-
b=self(j)
853+
b = self(j)
854854
# A small rotation is necessary for the reduced word from
855855
# the Lehmer code to match the element.
856856
if a < b:
857-
code[i-1]+=((b-a)//(self.k+1)+1)
857+
code[i-1] += ((b-a)//(self.k+1)+1)
858858
elif typ[0] == 'i' and side[0] == 'l':
859859
#Find number of positions to the right of i smaller than i, then
860860
#cyclically shift the resulting vector.
@@ -866,7 +866,7 @@ def to_lehmer_code(self, typ='decreasing', side='right'):
866866
#the lehmer code to match the element.
867867
if b < i:
868868
code[i-1] += (i-b) // (self.k+1) + 1
869-
elif typ[0] == 'd' and side[0]=='l':
869+
elif typ[0] == 'd' and side[0] == 'l':
870870
#Find number of positions to the left of i larger than i.
871871
for i in range(self.k+1):
872872
pos = self.position(i)
@@ -1029,7 +1029,7 @@ def tableau_of_word(self, w, typ='decreasing', side='right', alpha=None):
10291029
if x0.length() != len(w):
10301030
raise ValueError("word was not reduced")
10311031
if alpha is None:
1032-
alpha=Composition([1 for i in w])
1032+
alpha = Composition([1 for i in w])
10331033
else:
10341034
if sum(alpha) != len(w):
10351035
raise ValueError("size of alpha must match length of w")
@@ -1647,7 +1647,7 @@ def check(self):
16471647
if not len(self) == 6:
16481648
raise ValueError("length of list must be 6")
16491649
#Check that we have an even number of 'big' elements left of the 7th entry.
1650-
s = sum(i//6 - (i%6 == 0) for i in self if i > 6)
1650+
s = sum(i//6 - (i % 6 == 0) for i in self if i > 6)
16511651
if s % 2:
16521652
raise ValueError("type G affine permutations have an even number of"
16531653
" entries greater than 6 to the left of the 7th position")
@@ -1678,7 +1678,7 @@ def value(self, i, base_window=False):
16781678
if base_window:
16791679
self[i-1]
16801680
window = (i-1) // N
1681-
return self[(i-1)%N] + window*(N)
1681+
return self[(i-1) % N] + window*(N)
16821682

16831683
def position(self, i):
16841684
r"""
@@ -1758,28 +1758,28 @@ def apply_simple_reflection_left(self, i):
17581758
l = []
17591759
if i == 1:
17601760
for m in range(6):
1761-
res=self[m]%6
1762-
if res==1 or res==3 or res==5:
1761+
res = self[m] % 6
1762+
if res == 1 or res == 3 or res == 5:
17631763
l.append(self[m]+1)
1764-
elif res==2 or res==4 or res==0:
1764+
elif res == 2 or res == 4 or res == 0:
17651765
l.append(self[m]-1)
17661766
else:
17671767
l.append(self[m])
17681768
elif i == 2:
17691769
for m in range(6):
1770-
res=self[m]%6
1771-
if res==2 or res==4:
1770+
res = self[m] % 6
1771+
if res == 2 or res == 4:
17721772
l.append(self[m]+1)
1773-
elif res==3 or res==5:
1773+
elif res == 3 or res == 5:
17741774
l.append(self[m]-1)
17751775
else:
17761776
l.append(self[m])
17771777
elif i == 0:
17781778
for m in range(6):
1779-
res=self[m]%6
1780-
if res==1 or res==2:
1779+
res = self[m] % 6
1780+
if res == 1 or res == 2:
17811781
l.append(self[m]-2)
1782-
elif res==5 or res==0:
1782+
elif res == 5 or res == 0:
17831783
l.append(self[m]+2)
17841784
else:
17851785
l.append(self[m])
@@ -1983,9 +1983,9 @@ def AffinePermutationGroup(cartan_type):
19831983
Type G affine permutation with window [0, 4, -1, 8, 3, 7]
19841984
"""
19851985
ct = CartanType(cartan_type)
1986-
if ct.letter=='A':
1986+
if ct.letter == 'A':
19871987
return AffinePermutationGroupTypeA(ct)
1988-
if ct.letter=='B':
1988+
if ct.letter == 'B':
19891989
return AffinePermutationGroupTypeB(ct)
19901990
if ct.letter == 'C':
19911991
return AffinePermutationGroupTypeC(ct)
@@ -2140,7 +2140,7 @@ def index_set(self):
21402140
"""
21412141
return self.cartan_type().index_set()
21422142

2143-
_index_set=index_set
2143+
_index_set = index_set
21442144

21452145
def reflection_index_set(self):
21462146
r"""

src/sage/combinat/integer_vector.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def is_gale_ryser(r,s):
111111
# builds the corresponding partitions, i.e.
112112
# removes the 0 and sorts the sequences
113113
from sage.combinat.partition import Partition
114-
r2 = Partition(sorted([x for x in r if x>0], reverse=True))
115-
s2 = Partition(sorted([x for x in s if x>0], reverse=True))
114+
r2 = Partition(sorted([x for x in r if x > 0], reverse=True))
115+
s2 = Partition(sorted([x for x in s if x > 0], reverse=True))
116116

117117
# If the two sequences only contained zeroes
118118
if len(r2) == 0 and len(s2) == 0:
@@ -361,13 +361,13 @@ def gale_ryser_theorem(p1, p2, algorithm="gale",
361361

362362
elif algorithm == "gale":
363363
from sage.numerical.mip import MixedIntegerLinearProgram
364-
k1, k2=len(p1), len(p2)
364+
k1, k2 = len(p1), len(p2)
365365
p = MixedIntegerLinearProgram(solver=solver)
366366
b = p.new_variable(binary=True)
367367
for (i,c) in enumerate(p1):
368-
p.add_constraint(p.sum([b[i,j] for j in range(k2)]) ==c)
368+
p.add_constraint(p.sum([b[i,j] for j in range(k2)]) == c)
369369
for (i,c) in enumerate(p2):
370-
p.add_constraint(p.sum([b[j,i] for j in range(k1)]) ==c)
370+
p.add_constraint(p.sum([b[j,i] for j in range(k1)]) == c)
371371
p.set_objective(None)
372372
p.solve()
373373
b = p.get_values(b, convert=ZZ, tolerance=integrality_tolerance)

src/sage/combinat/integer_vectors_mod_permgroup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ def is_canonical(self, v, check=True):
431431
False
432432
"""
433433
if check:
434-
assert isinstance(v, (ClonableIntArray, list)), '%s should be a list or a integer vector'%v
435-
assert (self.n == len(v)), '%s should be of length %s'%(v, self.n)
434+
assert isinstance(v, (ClonableIntArray, list)), '%s should be a list or a integer vector' % v
435+
assert (self.n == len(v)), '%s should be of length %s' % (v, self.n)
436436
for p in v:
437437
assert (p == NN(p)), 'Elements of %s should be integers' % v
438438
return is_canonical(self._sgs, self.element_class(self, list(v), check=False))
@@ -473,7 +473,7 @@ def __call__(self, v, check=True):
473473
if v.parent() is self:
474474
return v
475475
else:
476-
raise ValueError('%s should be a Python list of integer'%(v))
476+
raise ValueError('%s should be a Python list of integer' % (v))
477477
except Exception:
478478
return self.element_class(self, list(v), check=check)
479479

@@ -499,7 +499,7 @@ def orbit(self, v):
499499
sage: I.orbit([1,1,1,1])
500500
{[1, 1, 1, 1]}
501501
"""
502-
assert isinstance(v, (list, ClonableIntArray)), '%s should be a Python list or an element of %s'%(v, self)
502+
assert isinstance(v, (list, ClonableIntArray)), '%s should be a Python list or an element of %s' % (v, self)
503503
try:
504504
if v.parent() is self:
505505
return orbit(self._sgs, v)
@@ -720,7 +720,7 @@ def __call__(self, v, check=True):
720720
if v.parent() is self:
721721
return v
722722
else:
723-
raise ValueError('%s should be a Python list of integer'%(v))
723+
raise ValueError('%s should be a Python list of integer' % (v))
724724
except Exception:
725725
return self.element_class(self, list(v), check=check)
726726

0 commit comments

Comments
 (0)