Skip to content

Commit da151a9

Browse files
author
Release Manager
committed
gh-39048: pep8 cleanup in libs just fixing most pep8 warning in the `libs` folder ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39048 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents b5d7b78 + 25be314 commit da151a9

File tree

7 files changed

+59
-53
lines changed

7 files changed

+59
-53
lines changed

src/sage/libs/coxeter3/coxeter_group.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def m(self, i, j):
279279
"""
280280
from sage.misc.superseded import deprecation
281281
deprecation(30237, "the .m(i, j) method has been deprecated; use .coxeter_matrix()[i,j] instead.")
282-
return self.coxeter_matrix()[i,j]
282+
return self.coxeter_matrix()[i, j]
283283

284284
def kazhdan_lusztig_polynomial(self, u, v, constant_term_one=True):
285285
r"""
@@ -354,8 +354,9 @@ def kazhdan_lusztig_polynomial(self, u, v, constant_term_one=True):
354354
return p
355355
ZZq = PolynomialRing(ZZ, 'q', sparse=True)
356356
# This is the same as q**len_diff * p(q**(-2))
357-
len_diff = v.length()-u.length()
358-
d = {-2*deg+len_diff: coeff for deg,coeff in enumerate(p) if coeff != 0}
357+
len_diff = v.length() - u.length()
358+
d = {-2 * deg + len_diff: coeff for deg, coeff in enumerate(p)
359+
if coeff != 0}
359360
return ZZq(d)
360361

361362
def parabolic_kazhdan_lusztig_polynomial(self, u, v, J, constant_term_one=True):
@@ -414,11 +415,11 @@ def parabolic_kazhdan_lusztig_polynomial(self, u, v, J, constant_term_one=True):
414415
WOI = self.weak_order_ideal(lambda x: J_set.issuperset(x.descents()))
415416
if constant_term_one:
416417
P = PolynomialRing(ZZ, 'q')
417-
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u*z,v)
418-
for z in WOI if (u*z).bruhat_le(v))
418+
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u * z, v)
419+
for z in WOI if (u * z).bruhat_le(v))
419420
P = PolynomialRing(ZZ, 'q', sparse=True)
420-
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u*z,v, constant_term_one=False).shift(z.length())
421-
for z in WOI if (u*z).bruhat_le(v))
421+
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u * z, v, constant_term_one=False).shift(z.length())
422+
for z in WOI if (u * z).bruhat_le(v))
422423

423424
class Element(ElementWrapper):
424425
wrapped_class = CoxGroupElement
@@ -701,7 +702,7 @@ def action_on_rational_function(self, f):
701702

702703
for exponent in exponents:
703704
# Construct something in the root lattice from the exponent vector
704-
exponent = sum(e*b for e, b in zip(exponent, basis_elements))
705+
exponent = sum(e * b for e, b in zip(exponent, basis_elements))
705706
exponent = self.action(exponent)
706707

707708
monomial = 1

src/sage/libs/eclib/interface.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ def __repr__(self):
247247
"""
248248
a1, a2, a3, a4, a6 = self.__ainvs
249249
# we do not assume a1, a2, a3 are reduced to {0,1}, {-1,0,1}, {0,1}
250-
coeff = lambda a: ''.join([" +" if a > 0 else " -",
251-
" " + str(abs(a)) if abs(a) > 1 else ""])
250+
251+
def coeff(a):
252+
return ''.join([" +" if a > 0 else " -",
253+
" " + str(abs(a)) if abs(a) > 1 else ""])
254+
252255
return ''.join(['y^2',
253256
' '.join([coeff(a1), 'xy']) if a1 else '',
254257
' '.join([coeff(a3), 'y']) if a3 else '',
@@ -614,12 +617,14 @@ def certain(self):
614617
"""
615618
return bool(self.__two_descent_data().getcertain())
616619

617-
#def fullmw(self):
618-
# return self.__two_descent_data().getfullmw()
620+
# def fullmw(self):
621+
# return self.__two_descent_data().getfullmw()
619622

620623
def CPS_height_bound(self):
621624
r"""
622-
Return the Cremona-Prickett-Siksek height bound. This is a
625+
Return the Cremona-Prickett-Siksek height bound.
626+
627+
This is a
623628
floating point number `B` such that if `P` is a point on the
624629
curve, then the naive logarithmic height `h(P)` is less than
625630
`B+\hat{h}(P)`, where `\hat{h}(P)` is the canonical height of
@@ -1290,9 +1295,9 @@ def search(self, height_limit=18, verbose=False):
12901295
"""
12911296
height_limit = float(height_limit)
12921297
int_bits = sys.maxsize.bit_length()
1293-
max_height_limit = int_bits * 0.693147 # log(2.0) = 0.693147 approx
1298+
max_height_limit = int_bits * 0.693147 # log(2.0) = 0.693147 approx
12941299
if height_limit >= max_height_limit:
1295-
raise ValueError("The height limit must be < {} = {}log(2) on a {}-bit machine.".format(max_height_limit, int_bits, int_bits+1))
1300+
raise ValueError("The height limit must be < {} = {}log(2) on a {}-bit machine.".format(max_height_limit, int_bits, int_bits + 1))
12961301

12971302
moduli_option = 0 # Use Stoll's sieving program... see strategies in ratpoints-1.4.c
12981303

src/sage/libs/gap/gap_globals.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,34 @@
1515

1616

1717
# selected gap globals to use in tab completion
18-
common_gap_globals = set([
19-
'Assert',
20-
'Cyclotomics',
21-
'GaussianIntegers',
22-
'GaussianRationals',
23-
'GlobalMersenneTwister',
24-
'GlobalRandomSource',
25-
'InfoAlgebra',
26-
'InfoAttributes',
27-
'InfoBckt',
28-
'InfoCharacterTable',
29-
'InfoCoh',
30-
'InfoComplement',
31-
'InfoCoset',
32-
'InfoFpGroup',
33-
'InfoGroebner',
34-
'InfoGroup',
35-
'InfoLattice',
36-
'InfoMatrix',
37-
'InfoMonomial',
38-
'InfoNumtheor',
39-
'InfoOptions',
40-
'InfoPackageLoading',
41-
'InfoPcSubgroup',
42-
'InfoWarning',
43-
'Integers',
44-
'NiceBasisFiltersInfo',
45-
'Primes',
46-
'Rationals',
47-
'TableOfMarksComponents'
48-
]) | common_gap_functions
18+
common_gap_globals = {
19+
'Assert',
20+
'Cyclotomics',
21+
'GaussianIntegers',
22+
'GaussianRationals',
23+
'GlobalMersenneTwister',
24+
'GlobalRandomSource',
25+
'InfoAlgebra',
26+
'InfoAttributes',
27+
'InfoBckt',
28+
'InfoCharacterTable',
29+
'InfoCoh',
30+
'InfoComplement',
31+
'InfoCoset',
32+
'InfoFpGroup',
33+
'InfoGroebner',
34+
'InfoGroup',
35+
'InfoLattice',
36+
'InfoMatrix',
37+
'InfoMonomial',
38+
'InfoNumtheor',
39+
'InfoOptions',
40+
'InfoPackageLoading',
41+
'InfoPcSubgroup',
42+
'InfoWarning',
43+
'Integers',
44+
'NiceBasisFiltersInfo',
45+
'Primes',
46+
'Rationals',
47+
'TableOfMarksComponents'
48+
} | common_gap_functions

src/sage/libs/gap/test_long.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_loop_2():
2828
G = libgap.FreeGroup(2)
2929
a, b = G.GeneratorsOfGroup()
3030
for i in range(100):
31-
rel = libgap([a**2, b**2, a*b*a*b])
31+
rel = libgap([a**2, b**2, a * b * a * b])
3232
H = G / rel
3333
H1 = H.GeneratorsOfGroup()[0]
3434
n = H1.Order()

src/sage/libs/giac/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
287287
return PolynomialSequence([P(0)], P, immutable=True)
288288

289289
# check for name confusions
290-
blackgiacconstants = ['i', 'e'] # NB e^k is expanded to exp(k)
290+
blackgiacconstants = ['i', 'e'] # NB e^k is expanded to exp(k)
291291
blacklist = blackgiacconstants + [str(j) for j in libgiac.VARS()]
292292
problematicnames = sorted(set(P.gens_dict()).intersection(blacklist))
293293

@@ -336,8 +336,8 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
336336
var_names = var_names[:len(blocks[0])]
337337
else:
338338
raise NotImplementedError(
339-
"%s is not a supported term order in "
340-
"Giac Groebner bases." % P.term_order())
339+
"%s is not a supported term order in "
340+
"Giac Groebner bases." % P.term_order())
341341

342342
# compute de groebner basis with giac
343343
gb_giac = F.gbasis(list(var_names), giac_order)

src/sage/libs/pari/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def _get_pari_instance():
182182
Interface to the PARI C library
183183
"""
184184
from cypari2 import Pari
185-
stack_initial = 1024*1024
186-
stack_max = 1024*stack_initial
185+
stack_initial = 1024 * 1024
186+
stack_max = 1024 * stack_initial
187187
P = Pari(stack_initial, stack_max)
188188

189189
# pari_init_opts() overrides MPIR's memory allocation functions,

src/sage/libs/singular/standard_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __exit__(self, typ, value, tb):
9696
b - 3*d^6 + 2*d^4 + d^3 + 2*d^2 - 3*d,
9797
a - 2*d^6 + d^5 - 2*d^4 + 3*d^3 + 3*d^2 - 2*d - 1]
9898
"""
99-
self.libsingular_option_context.__exit__(typ,value,tb)
99+
self.libsingular_option_context.__exit__(typ, value, tb)
100100

101101

102102
def libsingular_gb_standard_options(func):

0 commit comments

Comments
 (0)