Skip to content

Commit 357b34b

Browse files
author
Release Manager
committed
gh-36249: E228 and E225 in groups,interfaces,modules,plot fix pycodestyle warnings E228 and E225 in groups, interfaces, modules, plot scripted using autopep8, but only on files `src/sage/*/*.py` there ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36249 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents adc3df9 + 31e6f04 commit 357b34b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+511
-511
lines changed

src/sage/groups/cubic_braid.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,9 @@ def _repr_(self):
820820
Assion group on 2 strands of type U
821821
"""
822822
if self._cbg_type == CubicBraidGroup.type.Coxeter:
823-
return "Cubic Braid group on %s strands"%(self.strands())
823+
return "Cubic Braid group on %s strands" % (self.strands())
824824
else:
825-
return "Assion group on %s strands of type %s"%(self.strands() ,self._cbg_type.value)
825+
return "Assion group on %s strands of type %s" % (self.strands() ,self._cbg_type.value)
826826

827827
def index_set(self):
828828
r"""
@@ -916,7 +916,7 @@ def _internal_test_attached_group(self, attached_group, tester):
916916
elem = self.an_element()
917917
att_grp_elem = attached_group(elem)
918918
if self.is_finite() and self.strands() <= 7: # not realistic for larger number of strands
919-
att_grp_elem_back= self(att_grp_elem)
919+
att_grp_elem_back = self(att_grp_elem)
920920
tester.assertEqual(att_grp_elem_back, elem)
921921
return
922922

@@ -1183,14 +1183,14 @@ def create_sympl_realization(self, m):
11831183
# computing a hyperbolic decomposition basis with respect
11841184
# to the invariant bilinear form.
11851185
# -----------------------------------------------------------
1186-
xbas =[bas[mhalf -i -1] for i in range(mhalf)]
1187-
ybas =[bas[mhalf +i] for i in range(mhalf)]
1186+
xbas = [bas[mhalf - i - 1] for i in range(mhalf)]
1187+
ybas = [bas[mhalf + i] for i in range(mhalf)]
11881188

11891189
# -----------------------------------------------------------
11901190
# computing the List of transvection vectors according to
11911191
# the Assion paper, page 292.
11921192
# -----------------------------------------------------------
1193-
transvections =[xbas[0]] # t_1 = x_1
1193+
transvections = [xbas[0]] # t_1 = x_1
11941194
for i in range(mhalf-1):
11951195
transvections.append(ybas[i]) # t_{2i} = y_i
11961196
transvections.append(xbas[i] + xbas[i+1]) # t_{2i+1} = x_j + x_(j+1)
@@ -1256,26 +1256,26 @@ def create_unitary_realization(self, m):
12561256
# computing a orthonormal basis with respect
12571257
# to the invariant bilinear form.
12581258
# -----------------------------------------------------------
1259-
xbas =[]
1259+
xbas = []
12601260
for i in range(m):
12611261
if 2*i == m-1:
12621262
xbas.append(bas[i])
12631263
else:
1264-
xbas.append(a*bas[i] + a.frobenius()*bas[m-1 -i])
1264+
xbas.append(a*bas[i] + a.frobenius()*bas[m-1 - i])
12651265

12661266
# -----------------------------------------------------------
12671267
# computing the List of transvection vectors according to
12681268
# Assion paper, page 293.
12691269
# -----------------------------------------------------------
1270-
transvections =[xbas[0]] # t_1 = x_1
1270+
transvections = [xbas[0]] # t_1 = x_1
12711271
if m > 1:
12721272
transvections.append(xbas[0]+xbas[1]+xbas[2]) # t_2 = x_1 + x_2 + x_3
12731273
for j in range(mthird):
12741274
pos = 3*(j+1)-1
12751275
transvections.append(xbas[pos-1]) # t_{3i} = x_{3i-1}
1276-
if pos +1 < m:
1276+
if pos + 1 < m:
12771277
transvections.append(xbas[pos-1]+xbas[pos]+xbas[pos+1]) # t_{3i+1} = x_{3i-1} + x_{3i} + x_{3i+1}
1278-
if pos +3 < m:
1278+
if pos + 3 < m:
12791279
transvections.append(xbas[pos+1]+xbas[pos+2]+xbas[pos+3]) # t_{3i+2} = x_{3i+1} + x_{3i+2} + x_{3i+3}
12801280

12811281
# -----------------------------------------------------------
@@ -1286,7 +1286,7 @@ def create_unitary_realization(self, m):
12861286

12871287
def transvec2mat(v, bas=bas, bform=bform, fact=a):
12881288
# note x does not change under conjugation, since it belongs to standard basis
1289-
t = [x + fact *(x * bform * v.conjugate()) * v for x in bas]
1289+
t = [x + fact * (x * bform * v.conjugate()) * v for x in bas]
12901290
return matrix(F, t)
12911291

12921292
# ------------------------------------------------------------------------------

src/sage/groups/finitely_presented.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def rules(self):
643643
bfg = self._monoid_isomorphism.PreImagesRepresentative(bfpmon)
644644
btz = bfg.UnderlyingElement().TietzeWordAbstractWord(self._free_group.gap().GeneratorsOfGroup())
645645
bf = self._free_group(btz.sage())
646-
dic[af]=bf
646+
dic[af] = bf
647647
return dic
648648

649649
def is_confluent(self):
@@ -826,7 +826,7 @@ def _repr_(self):
826826
"""
827827
gens = ', '.join(self.variable_names())
828828
rels = ', '.join([ str(r) for r in self.relations() ])
829-
return 'Finitely presented group ' + '< '+ gens + ' | ' + rels + ' >'
829+
return 'Finitely presented group ' + '< ' + gens + ' | ' + rels + ' >'
830830

831831
def _latex_(self):
832832
"""
@@ -1112,7 +1112,7 @@ def direct_product(self, H, reduced=False, new_names=True):
11121112
name_itr = _lexi_gen() # Python generator for lexicographical variable names
11131113
gen_names = [next(name_itr) for i in GAP_gens]
11141114
else:
1115-
gen_names= [str(g) for g in self.gens()] + [str(g) for g in H.gens()]
1115+
gen_names = [str(g) for g in self.gens()] + [str(g) for g in H.gens()]
11161116
# Build the direct product in Sage for better variable names
11171117
ret_F = FreeGroup(gen_names)
11181118
ret_rls = tuple([ret_F(rel_word.TietzeWordAbstractWord(GAP_gens).sage())
@@ -1313,10 +1313,10 @@ def _element_constructor_(self, *args, **kwds):
13131313
sage: H([1, 2, 1, -2]) # indirect doctest
13141314
a*b*a*b^-1
13151315
"""
1316-
if len(args)!=1:
1316+
if len(args) != 1:
13171317
return self.element_class(self, *args, **kwds)
13181318
x = args[0]
1319-
if x==1:
1319+
if x == 1:
13201320
return self.one()
13211321
try:
13221322
P = x.parent()

src/sage/groups/finitely_presented_named.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def FinitelyGeneratedAbelianPresentation(int_list):
196196
invariants = FGP_Module(ZZ**(len(int_list)), col_sp).invariants()
197197
name_gen = _lexi_gen()
198198
F = FreeGroup([next(name_gen) for i in invariants])
199-
ret_rls = [F([i+1])**invariants[i] for i in range(len(invariants)) if invariants[i]!=0]
199+
ret_rls = [F([i+1])**invariants[i] for i in range(len(invariants)) if invariants[i] != 0]
200200

201201
# Build commutator relations
202202
gen_pairs = [[F.gen(i),F.gen(j)] for i in range(F.ngens()-1) for j in range(i+1,F.ngens())]
@@ -285,7 +285,7 @@ def commutator(a, b):
285285
# Third set of relations: [z, yi] = 1
286286
r3 = [commutator(z, y[i]) for i in range(n)]
287287
# Fourth set of relations: [xi, yi] = 1 for i != j
288-
r4 = [commutator(x[i], y[j]) for i in range(n) for j in range(n) if i!=j]
288+
r4 = [commutator(x[i], y[j]) for i in range(n) for j in range(n) if i != j]
289289
rls = r1 + r2 + r3 + r4
290290

291291
from sage.sets.primes import Primes

src/sage/groups/fqf_orthogonal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def _repr_(self):
380380
[ 0 2/3]
381381
generated by 2 elements
382382
"""
383-
return "Group of isometries of \n%s\ngenerated by %s elements"%(self.invariant_form(), len(self.gens()))
383+
return "Group of isometries of \n%s\ngenerated by %s elements" % (self.invariant_form(), len(self.gens()))
384384

385385
class ActionOnFqf(Action):
386386
r"""
@@ -547,7 +547,7 @@ def orbits(G, L):
547547
raise ValueError("torsion quadratic modules are not isometric")
548548
n = len(A.smith_form_gens())
549549
# separating the different primes here would speed things up
550-
b_cand = [[b for b in B if b.q()==a.q() and b.order() == a.order()] for a in A.smith_form_gens()]
550+
b_cand = [[b for b in B if b.q() == a.q() and b.order() == a.order()] for a in A.smith_form_gens()]
551551

552552
G = B.orthogonal_group(tuple())
553553
ambient = G.ambient()
@@ -569,7 +569,7 @@ def orbits(G, L):
569569
a = A.smith_form_gens()[i]
570570
card = ZZ.prod(A.smith_form_gen(k).order() for k in range(i+1))
571571
for b in b_cand[i]:
572-
if all(b.b(f[k])==a.b(A.smith_form_gens()[k]) for k in range(i)):
572+
if all(b.b(f[k]) == a.b(A.smith_form_gens()[k]) for k in range(i)):
573573
fnew = f + [b]
574574
# check that the elements of fnew are independent
575575
if B.submodule(fnew).cardinality() == card:

src/sage/groups/free_group.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,20 +213,20 @@ def __init__(self, parent, x):
213213
l = x.Tietze()
214214
except AttributeError:
215215
l = list(x)
216-
if len(l)>0:
216+
if len(l) > 0:
217217
if min(l) < -parent.ngens() or parent.ngens() < max(l):
218218
raise ValueError('generators not in the group')
219219
if 0 in l:
220220
raise ValueError('zero does not denote a generator')
221-
i=0
222-
while i<len(l)-1:
223-
if l[i]==-l[i+1]:
221+
i = 0
222+
while i < len(l)-1:
223+
if l[i] == -l[i+1]:
224224
l.pop(i)
225225
l.pop(i)
226-
if i>0:
227-
i=i-1
226+
if i > 0:
227+
i = i-1
228228
else:
229-
i=i+1
229+
i = i+1
230230
AbstractWordTietzeWord = libgap.eval('AbstractWordTietzeWord')
231231
x = AbstractWordTietzeWord(l, parent.gap().GeneratorsOfGroup())
232232
ElementLibGAP.__init__(self, parent, x)
@@ -788,7 +788,7 @@ def _repr_(self):
788788
sage: G._repr_()
789789
'Free Group on generators {a, b}'
790790
"""
791-
return 'Free Group on generators {'+ ', '.join(self.variable_names()) + '}'
791+
return 'Free Group on generators {' + ', '.join(self.variable_names()) + '}'
792792

793793
def rank(self):
794794
"""
@@ -870,10 +870,10 @@ def _element_constructor_(self, *args, **kwds):
870870
...
871871
TypeError: 'sage.rings.integer.Integer' object is not iterable
872872
"""
873-
if len(args)!=1:
873+
if len(args) != 1:
874874
return self.element_class(self, *args, **kwds)
875875
x = args[0]
876-
if x==1 or x == [] or x == ():
876+
if x == 1 or x == [] or x == ():
877877
return self.one()
878878
try:
879879
P = x.parent()
@@ -885,7 +885,7 @@ def _element_constructor_(self, *args, **kwds):
885885
return self([i.sign()*(self._names.index(P._names[abs(i)-1])+1)
886886
for i in x.Tietze()])
887887
else:
888-
raise ValueError('generators of %s not in the group'%x)
888+
raise ValueError('generators of %s not in the group' % x)
889889
return self.element_class(self, x, **kwds)
890890

891891
def abelian_invariants(self):

src/sage/groups/libgap_morphism.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ def preimage(self, S):
550550
phi = self.gap()
551551
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
552552
if not isinstance(S, (ParentLibGAP, PermutationGroup_generic)):
553-
raise TypeError("%s must be a GAP or permutation group of %s"%(S, self))
553+
raise TypeError("%s must be a GAP or permutation group of %s" % (S, self))
554554
if not self.codomain().gap().IsSubgroup(S.gap()).sage():
555-
raise ValueError("%s must be a subgroup of %s"%(S, self))
555+
raise ValueError("%s must be a subgroup of %s" % (S, self))
556556
preimage = phi.PreImage(S.gap())
557557
return self.domain()._subgroup_constructor(preimage)
558558

src/sage/interfaces/axiom.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _read_in_file_command(self, filename):
275275
# For some reason this trivial comp
276276
# keeps certain random freezes from occurring. Do not remove this.
277277
# The space before the \n is also important.
278-
return ')read %s \n'%filename
278+
return ')read %s \n' % filename
279279

280280
def _quit_string(self):
281281
"""
@@ -384,11 +384,11 @@ def set(self, var, value):
384384
'2'
385385
386386
"""
387-
cmd = '%s := %s'%(var, value)
387+
cmd = '%s := %s' % (var, value)
388388
out = self._eval_line(cmd, reformat=False)
389389

390390
if out.find("error") != -1:
391-
raise TypeError("Error executing code in Axiom\nCODE:\n\t%s\nAxiom ERROR:\n\t%s"%(cmd, out))
391+
raise TypeError("Error executing code in Axiom\nCODE:\n\t%s\nAxiom ERROR:\n\t%s" % (cmd, out))
392392

393393
def get(self, var):
394394
r"""
@@ -565,7 +565,7 @@ def __call__(self, x):
565565
"""
566566
self._check_valid()
567567
P = self.parent()
568-
return P('%s(%s)'%(self.name(), x))
568+
return P('%s(%s)' % (self.name(), x))
569569

570570
def _richcmp_(self, other, op):
571571
"""
@@ -601,11 +601,11 @@ def _richcmp_(self, other, op):
601601
602602
"""
603603
P = self.parent()
604-
if 'true' in P.eval("(%s = %s) :: Boolean"%(self.name(),other.name())):
604+
if 'true' in P.eval("(%s = %s) :: Boolean" % (self.name(),other.name())):
605605
return rich_to_bool(op, 0)
606-
elif 'true' in P.eval("(%s < %s) :: Boolean"%(self.name(), other.name())):
606+
elif 'true' in P.eval("(%s < %s) :: Boolean" % (self.name(), other.name())):
607607
return rich_to_bool(op, -1)
608-
elif 'true' in P.eval("(%s > %s) :: Boolean"%(self.name(),other.name())):
608+
elif 'true' in P.eval("(%s > %s) :: Boolean" % (self.name(),other.name())):
609609
return rich_to_bool(op, 1)
610610

611611
return NotImplemented
@@ -635,7 +635,7 @@ def __len__(self):
635635
6
636636
"""
637637
P = self._check_valid()
638-
s = P.eval('# %s '%self.name())
638+
s = P.eval('# %s ' % self.name())
639639
i = s.rfind('Type')
640640
return int(s[:i-1])
641641

@@ -667,9 +667,9 @@ def __getitem__(self, n):
667667
raise IndexError("index out of range")
668668
P = self._check_valid()
669669
if not isinstance(n, tuple):
670-
return P.new('%s(%s)'%(self._name, n))
670+
return P.new('%s(%s)' % (self._name, n))
671671
else:
672-
return P.new('%s(%s)'%(self._name, str(n)[1:-1]))
672+
return P.new('%s(%s)' % (self._name, str(n)[1:-1]))
673673

674674
def comma(self, *args):
675675
"""
@@ -733,7 +733,7 @@ def as_type(self, type):
733733
"""
734734
P = self._check_valid()
735735
type = P(type)
736-
return P.new("%s :: %s"%(self.name(), type.name()))
736+
return P.new("%s :: %s" % (self.name(), type.name()))
737737

738738
def unparsed_input_form(self):
739739
"""
@@ -750,7 +750,7 @@ def unparsed_input_form(self):
750750
751751
"""
752752
P = self._check_valid()
753-
s = P.eval('unparse(%s::InputForm)'%self._name)
753+
s = P.eval('unparse(%s::InputForm)' % self._name)
754754
if 'translation error' in s or 'Cannot convert' in s:
755755
raise NotImplementedError
756756
s = multiple_replace({'\r\n':'', # fix stupid Fortran-ish
@@ -855,7 +855,7 @@ def _sage_(self):
855855
#If all else fails, try using the unparsed input form
856856
try:
857857
import sage.misc.sage_eval
858-
vars=sage.symbolic.ring.var(str(self.variables())[1:-1])
858+
vars = sage.symbolic.ring.var(str(self.variables())[1:-1])
859859
if isinstance(vars,tuple):
860860
return sage.misc.sage_eval.sage_eval(self.unparsed_input_form(), locals={str(x):x for x in vars})
861861
else:

src/sage/interfaces/four_ti_2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def write_array(self, array, nrows, ncols, filename):
176176
sage: four_ti_2.write_array([[1,2,3],[3,4,5]], 2, 3, "test_file")
177177
"""
178178
f = open(os.path.join(self.directory(), filename), 'w')
179-
f.write("%s %s\n"%(nrows, ncols))
179+
f.write("%s %s\n" % (nrows, ncols))
180180
for row in array:
181181
f.write(" ".join(map(str, row)))
182182
f.write("\n")
@@ -444,7 +444,7 @@ def ppi(self, n):
444444
445445
"""
446446
self.call('ppi', f'{n} 2> /dev/null')
447-
return self.read_matrix('ppi%s.gra'%n)
447+
return self.read_matrix('ppi%s.gra' % n)
448448

449449
def circuits(self, mat=None, project=None):
450450
r"""

src/sage/interfaces/frobby.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ def hilbert(self, monomial_ideal):
168168
"""
169169
frobby_input = self._ideal_to_string(monomial_ideal)
170170
frobby_output = self('hilbert', input=frobby_input)
171-
ring=monomial_ideal.ring()
172-
lines=frobby_output.split('\n')
173-
if lines[-1]=='':
171+
ring = monomial_ideal.ring()
172+
lines = frobby_output.split('\n')
173+
if lines[-1] == '':
174174
lines.pop(-1)
175-
if lines[-1]=='(coefficient)':
175+
if lines[-1] == '(coefficient)':
176176
lines.pop(-1)
177177
lines.pop(0)
178-
resul=0
178+
resul = 0
179179
for l in lines:
180180
lis = [int(_) for _ in l.split()]
181181
resul += lis[0]+prod([ring.gen(i)**lis[i+1] for i in range(len(lis)-1)])
@@ -206,9 +206,9 @@ def associated_primes(self, monomial_ideal):
206206
"""
207207
frobby_input = self._ideal_to_string(monomial_ideal)
208208
frobby_output = self('assoprimes', input=frobby_input)
209-
lines=frobby_output.split('\n')
209+
lines = frobby_output.split('\n')
210210
lines.pop(0)
211-
if lines[-1]=='':
211+
if lines[-1] == '':
212212
lines.pop(-1)
213213
lists = [[int(_) for _ in a.split()] for a in lines]
214214

@@ -334,10 +334,10 @@ def _parse_ideals(self, string, ring):
334334
lines.pop(0)
335335
matrices.append('1 '+str(ring.ngens())+'\n'+'0 '*ring.ngens()+'\n')
336336
else:
337-
nrows=int(lines[0].split()[0])
338-
nmatrix=lines.pop(0)+'\n'
337+
nrows = int(lines[0].split()[0])
338+
nmatrix = lines.pop(0)+'\n'
339339
for i in range(nrows):
340-
nmatrix+=lines.pop(0)+'\n'
340+
nmatrix += lines.pop(0)+'\n'
341341
matrices.append(nmatrix)
342342

343343
def to_ideal(exps):

0 commit comments

Comments
 (0)