Skip to content

Commit 15a83e1

Browse files
author
Release Manager
committed
gh-40026: just a few pep8 details nothing serious, but a little cleanup ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40026 Reported by: Frédéric Chapoton Reviewer(s): gmou3
2 parents 65116a5 + f685b6f commit 15a83e1

File tree

5 files changed

+43
-38
lines changed

5 files changed

+43
-38
lines changed

src/sage/groups/matrix_gps/binary_dihedral.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, n):
8282

8383
MS = MatrixSpace(R, 2)
8484
zero = R.zero()
85-
gens = [ MS([zeta, zero, zero, ~zeta]), MS([zero, i, i, zero]) ]
85+
gens = [MS([zeta, zero, zero, ~zeta]), MS([zero, i, i, zero])]
8686

8787
from sage.libs.gap.libgap import libgap
8888
gap_gens = [libgap(matrix_gen) for matrix_gen in gens]

src/sage/rings/polynomial/multi_polynomial_sequence.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,12 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None):
314314
except ImportError:
315315
BooleanMonomialMonoid = ()
316316

317-
def is_ring(r): return (isinstance(r, (MPolynomialRing_base,
318-
BooleanMonomialMonoid,
319-
InfinitePolynomialRing_sparse))
320-
or (isinstance(r, QuotientRing_nc)
321-
and isinstance(r.cover_ring(), MPolynomialRing_base)))
317+
def is_ring(r):
318+
return (isinstance(r, (MPolynomialRing_base,
319+
BooleanMonomialMonoid,
320+
InfinitePolynomialRing_sparse))
321+
or (isinstance(r, QuotientRing_nc)
322+
and isinstance(r.cover_ring(), MPolynomialRing_base)))
322323

323324
if is_ring(arg1):
324325
ring, gens = arg1, arg2
@@ -1101,7 +1102,7 @@ def macaulay_matrix(self, degree,
11011102
# order the rows with TOP
11021103
else:
11031104
R_monomials_useful = []
1104-
for i in range(degree,target_degree-self.minimal_degree()+1):
1105+
for i in range(degree, target_degree-self.minimal_degree()+1):
11051106
R_monomials_useful += R_monomials_of_degree[i]
11061107
R_monomials_useful.sort()
11071108
for mon in R_monomials_useful:
@@ -1461,6 +1462,7 @@ def maximal_degree(self):
14611462
return max(f.degree() for f in self)
14621463
except ValueError:
14631464
return -1 # empty sequence
1465+
14641466
def minimal_degree(self):
14651467
"""
14661468
Return the minimal degree of any polynomial in this sequence.
@@ -1777,7 +1779,8 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc
17771779
else:
17781780
# slower, more flexible solution
17791781
if skip is None:
1780-
def skip(lm, tail): return False
1782+
def skip(lm, tail):
1783+
return False
17811784

17821785
while True:
17831786
linear = []
@@ -1997,7 +2000,9 @@ def solve(self, algorithm='polybori', n=1,
19972000
eliminated_variables = {f.lex_lead() for f in reductors}
19982001
leftover_variables = {x.lm() for x in R_origin.gens()} - solved_variables - eliminated_variables
19992002

2000-
def key_convert(x): return R_origin(x).lm()
2003+
def key_convert(x):
2004+
return R_origin(x).lm()
2005+
20012006
if leftover_variables != set():
20022007
partial_solutions = solutions
20032008
solutions = []

src/sage/schemes/generic/algebraic_scheme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ def Jacobian(self):
13581358
d = self.codimension()
13591359
minors = self.Jacobian_matrix().minors(d)
13601360
I = self.defining_ideal()
1361-
minors = tuple([ I.reduce(m) for m in minors ])
1361+
minors = tuple([I.reduce(m) for m in minors])
13621362
return I.ring().ideal(I.gens() + minors)
13631363

13641364
def reduce(self):

src/sage/schemes/generic/divisor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def CurvePointToIdeal(C, P):
6969
R = A.coordinate_ring()
7070
n = A.ngens()
7171
x = A.gens()
72-
polys = [ ]
73-
m = n-1
72+
polys = []
73+
m = n - 1
7474
while m > 0 and P[m] == 0:
7575
m += -1
7676
if isinstance(A, ProjectiveSpace_ring):

src/sage/schemes/plane_conics/con_field.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def __init__(self, A, f):
7070
Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2
7171
"""
7272
super().__init__(A, f)
73-
self._coefficients = [f[(2,0,0)], f[(1,1,0)], f[(1,0,1)],
74-
f[(0,2,0)], f[(0,1,1)], f[(0,0,2)]]
73+
self._coefficients = [f[(2, 0, 0)], f[(1, 1, 0)], f[(1, 0, 1)],
74+
f[(0, 2, 0)], f[(0, 1, 1)], f[(0, 0, 2)]]
7575
self._parametrization = None
7676
self._diagonal_matrix = None
7777

@@ -116,13 +116,13 @@ def base_extend(self, S):
116116
return self
117117
if not S.has_coerce_map_from(B):
118118
raise ValueError("No natural map from the base ring of self "
119-
"(= %s) to S (= %s)" % (self, S))
119+
"(= %s) to S (= %s)" % (self, S))
120120
from .constructor import Conic
121121
con = Conic([S(c) for c in self.coefficients()],
122122
self.variable_names())
123123
if self._rational_point is not None:
124124
pt = [S(c) for c in Sequence(self._rational_point)]
125-
if not pt == [0,0,0]:
125+
if not pt == [0, 0, 0]:
126126
# The following line stores the point in the cache
127127
# if (and only if) there is no point in the cache.
128128
pt = con.point(pt)
@@ -284,26 +284,26 @@ def diagonal_matrix(self):
284284
"""
285285
A = self.symmetric_matrix()
286286
B = self.base_ring()
287-
basis = [vector(B,{2:0,i:1}) for i in range(3)]
287+
basis = [vector(B, {2: 0, i: 1}) for i in range(3)]
288288
for i in range(3):
289289
zerovalue = (basis[i]*A*basis[i].column() == 0)
290290
if zerovalue:
291-
for j in range(i+1,3):
291+
for j in range(i+1, 3):
292292
if basis[j]*A*basis[j].column() != 0:
293293
b = basis[i]
294294
basis[i] = basis[j]
295295
basis[j] = b
296296
zerovalue = False
297297
if zerovalue:
298-
for j in range(i+1,3):
298+
for j in range(i+1, 3):
299299
if basis[i]*A*basis[j].column() != 0:
300300
basis[i] = basis[i]+basis[j]
301301
zerovalue = False
302302
if not zerovalue:
303303
l = (basis[i]*A*basis[i].column())
304-
for j in range(i+1,3):
304+
for j in range(i+1, 3):
305305
basis[j] = basis[j] - \
306-
(basis[i]*A*basis[j].column())/l * basis[i]
306+
(basis[i]*A*basis[j].column())/l * basis[i]
307307
T = matrix(basis).transpose()
308308
return T.transpose()*A*T, T
309309

@@ -537,24 +537,24 @@ def has_rational_point(self, point=False,
537537

538538
if isinstance(B, sage.rings.abc.ComplexField):
539539
if point:
540-
[_,_,_,d,e,f] = self._coefficients
540+
_, _, _, d, e, f = self._coefficients
541541
if d == 0:
542-
return True, self.point([0,1,0])
542+
return True, self.point([0, 1, 0])
543543
return True, self.point([0, ((e**2-4*d*f).sqrt()-e)/(2*d), 1],
544544
check=False)
545545
return True
546546
if isinstance(B, sage.rings.abc.RealField):
547547
D, T = self.diagonal_matrix()
548-
[a, b, c] = [D[0,0], D[1,1], D[2,2]]
548+
a, b, c = [D[0, 0], D[1, 1], D[2, 2]]
549549
if a == 0:
550-
ret = True, self.point(T*vector([1,0,0]), check=False)
550+
ret = True, self.point(T*vector([1, 0, 0]), check=False)
551551
elif a*c <= 0:
552-
ret = True, self.point(T*vector([(-c/a).sqrt(),0,1]),
552+
ret = True, self.point(T*vector([(-c/a).sqrt(), 0, 1]),
553553
check=False)
554554
elif b == 0:
555-
ret = True, self.point(T*vector([0,1,0]), check=False)
555+
ret = True, self.point(T*vector([0, 1, 0]), check=False)
556556
elif b*c <= 0:
557-
ret = True, self.point(T*vector([0,(-c/b).sqrt(),0,1]),
557+
ret = True, self.point(T*vector([0, (-c/b).sqrt(), 0, 1]),
558558
check=False)
559559
else:
560560
ret = False, None
@@ -617,16 +617,16 @@ def has_singular_point(self, point=False):
617617
return ret[0]
618618
B = self.base_ring()
619619
if B.characteristic() == 2:
620-
[a,b,c,d,e,f] = self.coefficients()
620+
a, b, c, d, e, f = self.coefficients()
621621
if b == 0 and c == 0 and e == 0:
622622
for i in range(3):
623623
if [a, d, f][i] == 0:
624-
return True, self.point(vector(B, {2:0, i:1}))
624+
return True, self.point(vector(B, {2: 0, i: 1}))
625625
if hasattr(a/f, 'is_square') and hasattr(a/f, 'sqrt'):
626626
if (a/f).is_square():
627-
return True, self.point([1,0,(a/f).sqrt()])
627+
return True, self.point([1, 0, (a/f).sqrt()])
628628
if (d/f).is_square():
629-
return True, self.point([0,1,(d/f).sqrt()])
629+
return True, self.point([0, 1, (d/f).sqrt()])
630630
raise NotImplementedError("Sorry, find singular point on conics not implemented over all fields of characteristic 2.")
631631
pt = [e, c, b]
632632
if self.defining_polynomial()(pt) == 0:
@@ -760,7 +760,7 @@ def is_smooth(self):
760760
True
761761
"""
762762
if self.base_ring().characteristic() == 2:
763-
[a,b,c,d,e,f] = self.coefficients()
763+
a, b, c, d, e, f = self.coefficients()
764764
if b == 0 and c == 0 and e == 0:
765765
return False
766766
return self.defining_polynomial()([e, c, b]) != 0
@@ -803,7 +803,7 @@ def _magma_init_(self, magma):
803803
kmn = magma(self.base_ring())._ref()
804804
coeffs = self.coefficients()
805805
magma_coeffs = [coeffs[i]._magma_init_(magma) for i in [0, 3, 5, 1, 4, 2]]
806-
return 'Conic([%s|%s])' % (kmn,','.join(magma_coeffs))
806+
return 'Conic([%s|%s])' % (kmn, ','.join(magma_coeffs))
807807

808808
def matrix(self):
809809
r"""
@@ -1265,10 +1265,10 @@ def upper_triangular_matrix(self):
12651265
x^2 + 2*x*y + y^2 + 3*x*z + z^2
12661266
"""
12671267
from sage.matrix.constructor import matrix
1268-
[a,b,c,d,e,f] = self.coefficients()
1269-
return matrix([[ a, b, c ],
1270-
[ 0, d, e ],
1271-
[ 0, 0, f ]])
1268+
a, b, c, d, e, f = self.coefficients()
1269+
return matrix([[a, b, c],
1270+
[0, d, e],
1271+
[0, 0, f]])
12721272

12731273
def variable_names(self):
12741274
r"""

0 commit comments

Comments
 (0)