Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E228 and E225 in groups,interfaces,modules,plot #36249

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/sage/groups/cubic_braid.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,9 @@ def _repr_(self):
Assion group on 2 strands of type U
"""
if self._cbg_type == CubicBraidGroup.type.Coxeter:
return "Cubic Braid group on %s strands"%(self.strands())
return "Cubic Braid group on %s strands" % (self.strands())
else:
return "Assion group on %s strands of type %s"%(self.strands() ,self._cbg_type.value)
return "Assion group on %s strands of type %s" % (self.strands() ,self._cbg_type.value)

def index_set(self):
r"""
Expand Down Expand Up @@ -901,7 +901,7 @@ def _internal_test_attached_group(self, attached_group, tester):
elem = self.an_element()
att_grp_elem = attached_group(elem)
if self.is_finite() and self.strands() <= 7: # not realistic for larger number of strands
att_grp_elem_back= self(att_grp_elem)
att_grp_elem_back = self(att_grp_elem)
tester.assertEqual(att_grp_elem_back, elem)
return

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

# -----------------------------------------------------------
# computing the List of transvection vectors according to
# the Assion paper, page 292.
# -----------------------------------------------------------
transvections =[xbas[0]] # t_1 = x_1
transvections = [xbas[0]] # t_1 = x_1
for i in range(mhalf-1):
transvections.append(ybas[i]) # t_{2i} = y_i
transvections.append(xbas[i] + xbas[i+1]) # t_{2i+1} = x_j + x_(j+1)
Expand Down Expand Up @@ -1234,26 +1234,26 @@ def create_unitary_realization(self, m):
# computing a orthonormal basis with respect
# to the invariant bilinear form.
# -----------------------------------------------------------
xbas =[]
xbas = []
for i in range(m):
if 2*i == m-1:
xbas.append(bas[i])
else:
xbas.append(a*bas[i] + a.frobenius()*bas[m-1 -i])
xbas.append(a*bas[i] + a.frobenius()*bas[m-1 - i])

# -----------------------------------------------------------
# computing the List of transvection vectors according to
# Assion paper, page 293.
# -----------------------------------------------------------
transvections =[xbas[0]] # t_1 = x_1
transvections = [xbas[0]] # t_1 = x_1
if m > 1:
transvections.append(xbas[0]+xbas[1]+xbas[2]) # t_2 = x_1 + x_2 + x_3
for j in range(mthird):
pos = 3*(j+1)-1
transvections.append(xbas[pos-1]) # t_{3i} = x_{3i-1}
if pos +1 < m:
if pos + 1 < m:
transvections.append(xbas[pos-1]+xbas[pos]+xbas[pos+1]) # t_{3i+1} = x_{3i-1} + x_{3i} + x_{3i+1}
if pos +3 < m:
if pos + 3 < m:
transvections.append(xbas[pos+1]+xbas[pos+2]+xbas[pos+3]) # t_{3i+2} = x_{3i+1} + x_{3i+2} + x_{3i+3}

# -----------------------------------------------------------
Expand All @@ -1264,7 +1264,7 @@ def create_unitary_realization(self, m):

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

# ------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/sage/groups/finitely_presented.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def rules(self):
bfg = self._monoid_isomorphism.PreImagesRepresentative(bfpmon)
btz = bfg.UnderlyingElement().TietzeWordAbstractWord(self._free_group.gap().GeneratorsOfGroup())
bf = self._free_group(btz.sage())
dic[af]=bf
dic[af] = bf
return dic

def is_confluent(self):
Expand Down Expand Up @@ -826,7 +826,7 @@ def _repr_(self):
"""
gens = ', '.join(self.variable_names())
rels = ', '.join([ str(r) for r in self.relations() ])
return 'Finitely presented group ' + '< '+ gens + ' | ' + rels + ' >'
return 'Finitely presented group ' + '< ' + gens + ' | ' + rels + ' >'

def _latex_(self):
"""
Expand Down Expand Up @@ -1112,7 +1112,7 @@ def direct_product(self, H, reduced=False, new_names=True):
name_itr = _lexi_gen() # Python generator for lexicographical variable names
gen_names = [next(name_itr) for i in GAP_gens]
else:
gen_names= [str(g) for g in self.gens()] + [str(g) for g in H.gens()]
gen_names = [str(g) for g in self.gens()] + [str(g) for g in H.gens()]
# Build the direct product in Sage for better variable names
ret_F = FreeGroup(gen_names)
ret_rls = tuple([ret_F(rel_word.TietzeWordAbstractWord(GAP_gens).sage())
Expand Down Expand Up @@ -1313,10 +1313,10 @@ def _element_constructor_(self, *args, **kwds):
sage: H([1, 2, 1, -2]) # indirect doctest
a*b*a*b^-1
"""
if len(args)!=1:
if len(args) != 1:
return self.element_class(self, *args, **kwds)
x = args[0]
if x==1:
if x == 1:
return self.one()
try:
P = x.parent()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/finitely_presented_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def FinitelyGeneratedAbelianPresentation(int_list):
invariants = FGP_Module(ZZ**(len(int_list)), col_sp).invariants()
name_gen = _lexi_gen()
F = FreeGroup([next(name_gen) for i in invariants])
ret_rls = [F([i+1])**invariants[i] for i in range(len(invariants)) if invariants[i]!=0]
ret_rls = [F([i+1])**invariants[i] for i in range(len(invariants)) if invariants[i] != 0]

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

from sage.sets.primes import Primes
Expand Down
6 changes: 3 additions & 3 deletions src/sage/groups/fqf_orthogonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def _repr_(self):
[ 0 2/3]
generated by 2 elements
"""
return "Group of isometries of \n%s\ngenerated by %s elements"%(self.invariant_form(), len(self.gens()))
return "Group of isometries of \n%s\ngenerated by %s elements" % (self.invariant_form(), len(self.gens()))

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

G = B.orthogonal_group(tuple())
ambient = G.ambient()
Expand All @@ -566,7 +566,7 @@ def orbits(G, L):
a = A.smith_form_gens()[i]
card = ZZ.prod(A.smith_form_gen(k).order() for k in range(i+1))
for b in b_cand[i]:
if all(b.b(f[k])==a.b(A.smith_form_gens()[k]) for k in range(i)):
if all(b.b(f[k]) == a.b(A.smith_form_gens()[k]) for k in range(i)):
fnew = f + [b]
# check that the elements of fnew are independent
if B.submodule(fnew).cardinality() == card:
Expand Down
22 changes: 11 additions & 11 deletions src/sage/groups/free_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,20 @@
l = x.Tietze()
except AttributeError:
l = list(x)
if len(l)>0:
if len(l) > 0:
if min(l) < -parent.ngens() or parent.ngens() < max(l):
raise ValueError('generators not in the group')
if 0 in l:
raise ValueError('zero does not denote a generator')
i=0
while i<len(l)-1:
if l[i]==-l[i+1]:
i = 0
while i < len(l)-1:
if l[i] == -l[i+1]:
l.pop(i)
l.pop(i)
if i>0:
i=i-1
if i > 0:
i = i-1
else:
i=i+1
i = i+1
AbstractWordTietzeWord = libgap.eval('AbstractWordTietzeWord')
x = AbstractWordTietzeWord(l, parent.gap().GeneratorsOfGroup())
ElementLibGAP.__init__(self, parent, x)
Expand Down Expand Up @@ -788,7 +788,7 @@
sage: G._repr_()
'Free Group on generators {a, b}'
"""
return 'Free Group on generators {'+ ', '.join(self.variable_names()) + '}'
return 'Free Group on generators {' + ', '.join(self.variable_names()) + '}'

def rank(self):
"""
Expand Down Expand Up @@ -870,10 +870,10 @@
...
TypeError: 'sage.rings.integer.Integer' object is not iterable
"""
if len(args)!=1:
if len(args) != 1:
return self.element_class(self, *args, **kwds)
x = args[0]
if x==1 or x == [] or x == ():
if x == 1 or x == [] or x == ():
return self.one()
try:
P = x.parent()
Expand All @@ -885,7 +885,7 @@
return self([i.sign()*(self._names.index(P._names[abs(i)-1])+1)
for i in x.Tietze()])
else:
raise ValueError('generators of %s not in the group'%x)
raise ValueError('generators of %s not in the group' % x)

Check warning on line 888 in src/sage/groups/free_group.py

View check run for this annotation

Codecov / codecov/patch

src/sage/groups/free_group.py#L888

Added line #L888 was not covered by tests
return self.element_class(self, x, **kwds)

def abelian_invariants(self):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/libgap_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@
phi = self.gap()
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
if not isinstance(S, (ParentLibGAP, PermutationGroup_generic)):
raise TypeError("%s must be a GAP or permutation group of %s"%(S, self))
raise TypeError("%s must be a GAP or permutation group of %s" % (S, self))

Check warning on line 549 in src/sage/groups/libgap_morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/groups/libgap_morphism.py#L549

Added line #L549 was not covered by tests
if not self.codomain().gap().IsSubgroup(S.gap()).sage():
raise ValueError("%s must be a subgroup of %s"%(S, self))
raise ValueError("%s must be a subgroup of %s" % (S, self))

Check warning on line 551 in src/sage/groups/libgap_morphism.py

View check run for this annotation

Codecov / codecov/patch

src/sage/groups/libgap_morphism.py#L551

Added line #L551 was not covered by tests
preimage = phi.PreImage(S.gap())
return self.domain()._subgroup_constructor(preimage)

Expand Down
26 changes: 13 additions & 13 deletions src/sage/interfaces/axiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
# For some reason this trivial comp
# keeps certain random freezes from occurring. Do not remove this.
# The space before the \n is also important.
return ')read %s \n'%filename
return ')read %s \n' % filename

def _quit_string(self):
"""
Expand Down Expand Up @@ -384,11 +384,11 @@
'2'

"""
cmd = '%s := %s'%(var, value)
cmd = '%s := %s' % (var, value)

Check warning on line 387 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L387

Added line #L387 was not covered by tests
out = self._eval_line(cmd, reformat=False)

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

Check warning on line 391 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L391

Added line #L391 was not covered by tests

def get(self, var):
r"""
Expand Down Expand Up @@ -565,7 +565,7 @@
"""
self._check_valid()
P = self.parent()
return P('%s(%s)'%(self.name(), x))
return P('%s(%s)' % (self.name(), x))

Check warning on line 568 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L568

Added line #L568 was not covered by tests

def _richcmp_(self, other, op):
"""
Expand Down Expand Up @@ -601,11 +601,11 @@

"""
P = self.parent()
if 'true' in P.eval("(%s = %s) :: Boolean"%(self.name(),other.name())):
if 'true' in P.eval("(%s = %s) :: Boolean" % (self.name(),other.name())):

Check warning on line 604 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L604

Added line #L604 was not covered by tests
return rich_to_bool(op, 0)
elif 'true' in P.eval("(%s < %s) :: Boolean"%(self.name(), other.name())):
elif 'true' in P.eval("(%s < %s) :: Boolean" % (self.name(), other.name())):

Check warning on line 606 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L606

Added line #L606 was not covered by tests
return rich_to_bool(op, -1)
elif 'true' in P.eval("(%s > %s) :: Boolean"%(self.name(),other.name())):
elif 'true' in P.eval("(%s > %s) :: Boolean" % (self.name(),other.name())):

Check warning on line 608 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L608

Added line #L608 was not covered by tests
return rich_to_bool(op, 1)

return NotImplemented
Expand Down Expand Up @@ -635,7 +635,7 @@
6
"""
P = self._check_valid()
s = P.eval('# %s '%self.name())
s = P.eval('# %s ' % self.name())

Check warning on line 638 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L638

Added line #L638 was not covered by tests
i = s.rfind('Type')
return int(s[:i-1])

Expand Down Expand Up @@ -667,9 +667,9 @@
raise IndexError("index out of range")
P = self._check_valid()
if not isinstance(n, tuple):
return P.new('%s(%s)'%(self._name, n))
return P.new('%s(%s)' % (self._name, n))

Check warning on line 670 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L670

Added line #L670 was not covered by tests
else:
return P.new('%s(%s)'%(self._name, str(n)[1:-1]))
return P.new('%s(%s)' % (self._name, str(n)[1:-1]))

Check warning on line 672 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L672

Added line #L672 was not covered by tests

def comma(self, *args):
"""
Expand Down Expand Up @@ -733,7 +733,7 @@
"""
P = self._check_valid()
type = P(type)
return P.new("%s :: %s"%(self.name(), type.name()))
return P.new("%s :: %s" % (self.name(), type.name()))

Check warning on line 736 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L736

Added line #L736 was not covered by tests

def unparsed_input_form(self):
"""
Expand All @@ -750,7 +750,7 @@

"""
P = self._check_valid()
s = P.eval('unparse(%s::InputForm)'%self._name)
s = P.eval('unparse(%s::InputForm)' % self._name)

Check warning on line 753 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L753

Added line #L753 was not covered by tests
if 'translation error' in s or 'Cannot convert' in s:
raise NotImplementedError
s = multiple_replace({'\r\n':'', # fix stupid Fortran-ish
Expand Down Expand Up @@ -855,7 +855,7 @@
#If all else fails, try using the unparsed input form
try:
import sage.misc.sage_eval
vars=sage.symbolic.ring.var(str(self.variables())[1:-1])
vars = sage.symbolic.ring.var(str(self.variables())[1:-1])

Check warning on line 858 in src/sage/interfaces/axiom.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/axiom.py#L858

Added line #L858 was not covered by tests
if isinstance(vars,tuple):
return sage.misc.sage_eval.sage_eval(self.unparsed_input_form(), locals={str(x):x for x in vars})
else:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/interfaces/four_ti_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
sage: four_ti_2.write_array([[1,2,3],[3,4,5]], 2, 3, "test_file")
"""
f = open(os.path.join(self.directory(), filename), 'w')
f.write("%s %s\n"%(nrows, ncols))
f.write("%s %s\n" % (nrows, ncols))
for row in array:
f.write(" ".join(map(str, row)))
f.write("\n")
Expand Down Expand Up @@ -444,7 +444,7 @@

"""
self.call('ppi', f'{n} 2> /dev/null')
return self.read_matrix('ppi%s.gra'%n)
return self.read_matrix('ppi%s.gra' % n)

Check warning on line 447 in src/sage/interfaces/four_ti_2.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/four_ti_2.py#L447

Added line #L447 was not covered by tests

def circuits(self, mat=None, project=None):
r"""
Expand Down
20 changes: 10 additions & 10 deletions src/sage/interfaces/frobby.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@
"""
frobby_input = self._ideal_to_string(monomial_ideal)
frobby_output = self('hilbert', input=frobby_input)
ring=monomial_ideal.ring()
lines=frobby_output.split('\n')
if lines[-1]=='':
ring = monomial_ideal.ring()
lines = frobby_output.split('\n')
if lines[-1] == '':

Check warning on line 173 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L171-L173

Added lines #L171 - L173 were not covered by tests
lines.pop(-1)
if lines[-1]=='(coefficient)':
if lines[-1] == '(coefficient)':

Check warning on line 175 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L175

Added line #L175 was not covered by tests
lines.pop(-1)
lines.pop(0)
resul=0
resul = 0

Check warning on line 178 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L178

Added line #L178 was not covered by tests
for l in lines:
lis = [int(_) for _ in l.split()]
resul += lis[0]+prod([ring.gen(i)**lis[i+1] for i in range(len(lis)-1)])
Expand Down Expand Up @@ -206,9 +206,9 @@
"""
frobby_input = self._ideal_to_string(monomial_ideal)
frobby_output = self('assoprimes', input=frobby_input)
lines=frobby_output.split('\n')
lines = frobby_output.split('\n')

Check warning on line 209 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L209

Added line #L209 was not covered by tests
lines.pop(0)
if lines[-1]=='':
if lines[-1] == '':

Check warning on line 211 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L211

Added line #L211 was not covered by tests
lines.pop(-1)
lists = [[int(_) for _ in a.split()] for a in lines]

Expand Down Expand Up @@ -334,10 +334,10 @@
lines.pop(0)
matrices.append('1 '+str(ring.ngens())+'\n'+'0 '*ring.ngens()+'\n')
else:
nrows=int(lines[0].split()[0])
nmatrix=lines.pop(0)+'\n'
nrows = int(lines[0].split()[0])
nmatrix = lines.pop(0)+'\n'

Check warning on line 338 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L337-L338

Added lines #L337 - L338 were not covered by tests
for i in range(nrows):
nmatrix+=lines.pop(0)+'\n'
nmatrix += lines.pop(0)+'\n'

Check warning on line 340 in src/sage/interfaces/frobby.py

View check run for this annotation

Codecov / codecov/patch

src/sage/interfaces/frobby.py#L340

Added line #L340 was not covered by tests
matrices.append(nmatrix)

def to_ideal(exps):
Expand Down
Loading
Loading