Skip to content

Commit 03e3e8a

Browse files
committed
E228 and E225 in groups,interfaces,modules,plot
1 parent 4103129 commit 03e3e8a

Some content is hidden

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

46 files changed

+496
-496
lines changed

src/sage/groups/cubic_braid.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,9 @@ def _repr_(self):
805805
Assion group on 2 strands of type U
806806
"""
807807
if self._cbg_type == CubicBraidGroup.type.Coxeter:
808-
return "Cubic Braid group on %s strands"%(self.strands())
808+
return "Cubic Braid group on %s strands" % (self.strands())
809809
else:
810-
return "Assion group on %s strands of type %s"%(self.strands() ,self._cbg_type.value)
810+
return "Assion group on %s strands of type %s" % (self.strands() ,self._cbg_type.value)
811811

812812
def index_set(self):
813813
r"""
@@ -901,7 +901,7 @@ def _internal_test_attached_group(self, attached_group, tester):
901901
elem = self.an_element()
902902
att_grp_elem = attached_group(elem)
903903
if self.is_finite() and self.strands() <= 7: # not realistic for larger number of strands
904-
att_grp_elem_back= self(att_grp_elem)
904+
att_grp_elem_back = self(att_grp_elem)
905905
tester.assertEqual(att_grp_elem_back, elem)
906906
return
907907

@@ -1161,14 +1161,14 @@ def create_sympl_realization(self, m):
11611161
# computing a hyperbolic decomposition basis with respect
11621162
# to the invariant bilinear form.
11631163
# -----------------------------------------------------------
1164-
xbas =[bas[mhalf -i -1] for i in range(mhalf)]
1165-
ybas =[bas[mhalf +i] for i in range(mhalf)]
1164+
xbas = [bas[mhalf - i - 1] for i in range(mhalf)]
1165+
ybas = [bas[mhalf + i] for i in range(mhalf)]
11661166

11671167
# -----------------------------------------------------------
11681168
# computing the List of transvection vectors according to
11691169
# the Assion paper, page 292.
11701170
# -----------------------------------------------------------
1171-
transvections =[xbas[0]] # t_1 = x_1
1171+
transvections = [xbas[0]] # t_1 = x_1
11721172
for i in range(mhalf-1):
11731173
transvections.append(ybas[i]) # t_{2i} = y_i
11741174
transvections.append(xbas[i] + xbas[i+1]) # t_{2i+1} = x_j + x_(j+1)
@@ -1234,26 +1234,26 @@ def create_unitary_realization(self, m):
12341234
# computing a orthonormal basis with respect
12351235
# to the invariant bilinear form.
12361236
# -----------------------------------------------------------
1237-
xbas =[]
1237+
xbas = []
12381238
for i in range(m):
12391239
if 2*i == m-1:
12401240
xbas.append(bas[i])
12411241
else:
1242-
xbas.append(a*bas[i] + a.frobenius()*bas[m-1 -i])
1242+
xbas.append(a*bas[i] + a.frobenius()*bas[m-1 - i])
12431243

12441244
# -----------------------------------------------------------
12451245
# computing the List of transvection vectors according to
12461246
# Assion paper, page 293.
12471247
# -----------------------------------------------------------
1248-
transvections =[xbas[0]] # t_1 = x_1
1248+
transvections = [xbas[0]] # t_1 = x_1
12491249
if m > 1:
12501250
transvections.append(xbas[0]+xbas[1]+xbas[2]) # t_2 = x_1 + x_2 + x_3
12511251
for j in range(mthird):
12521252
pos = 3*(j+1)-1
12531253
transvections.append(xbas[pos-1]) # t_{3i} = x_{3i-1}
1254-
if pos +1 < m:
1254+
if pos + 1 < m:
12551255
transvections.append(xbas[pos-1]+xbas[pos]+xbas[pos+1]) # t_{3i+1} = x_{3i-1} + x_{3i} + x_{3i+1}
1256-
if pos +3 < m:
1256+
if pos + 3 < m:
12571257
transvections.append(xbas[pos+1]+xbas[pos+2]+xbas[pos+3]) # t_{3i+2} = x_{3i+1} + x_{3i+2} + x_{3i+3}
12581258

12591259
# -----------------------------------------------------------
@@ -1264,7 +1264,7 @@ def create_unitary_realization(self, m):
12641264

12651265
def transvec2mat(v, bas=bas, bform=bform, fact=a):
12661266
# note x does not change under conjugation, since it belongs to standard basis
1267-
t = [x + fact *(x * bform * v.conjugate()) * v for x in bas]
1267+
t = [x + fact * (x * bform * v.conjugate()) * v for x in bas]
12681268
return matrix(F, t)
12691269

12701270
# ------------------------------------------------------------------------------

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
@@ -377,7 +377,7 @@ def _repr_(self):
377377
[ 0 2/3]
378378
generated by 2 elements
379379
"""
380-
return "Group of isometries of \n%s\ngenerated by %s elements"%(self.invariant_form(), len(self.gens()))
380+
return "Group of isometries of \n%s\ngenerated by %s elements" % (self.invariant_form(), len(self.gens()))
381381

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

549549
G = B.orthogonal_group(tuple())
550550
ambient = G.ambient()
@@ -566,7 +566,7 @@ def orbits(G, L):
566566
a = A.smith_form_gens()[i]
567567
card = ZZ.prod(A.smith_form_gen(k).order() for k in range(i+1))
568568
for b in b_cand[i]:
569-
if all(b.b(f[k])==a.b(A.smith_form_gens()[k]) for k in range(i)):
569+
if all(b.b(f[k]) == a.b(A.smith_form_gens()[k]) for k in range(i)):
570570
fnew = f + [b]
571571
# check that the elements of fnew are independent
572572
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
@@ -546,9 +546,9 @@ def preimage(self, S):
546546
phi = self.gap()
547547
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
548548
if not isinstance(S, (ParentLibGAP, PermutationGroup_generic)):
549-
raise TypeError("%s must be a GAP or permutation group of %s"%(S, self))
549+
raise TypeError("%s must be a GAP or permutation group of %s" % (S, self))
550550
if not self.codomain().gap().IsSubgroup(S.gap()).sage():
551-
raise ValueError("%s must be a subgroup of %s"%(S, self))
551+
raise ValueError("%s must be a subgroup of %s" % (S, self))
552552
preimage = phi.PreImage(S.gap())
553553
return self.domain()._subgroup_constructor(preimage)
554554

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)