Skip to content

Commit 25be314

Browse files
committed
pep8 cleanup in libs
1 parent b9e396a commit 25be314

File tree

7 files changed

+60
-53
lines changed

7 files changed

+60
-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
@@ -246,8 +246,11 @@ def __repr__(self):
246246
"""
247247
a1, a2, a3, a4, a6 = self.__ainvs
248248
# we do not assume a1, a2, a3 are reduced to {0,1}, {-1,0,1}, {0,1}
249-
coeff = lambda a: ''.join([" +" if a > 0 else " -",
250-
" " + str(abs(a)) if abs(a) > 1 else ""])
249+
250+
def coeff(a):
251+
return ''.join([" +" if a > 0 else " -",
252+
" " + str(abs(a)) if abs(a) > 1 else ""])
253+
251254
return ''.join(['y^2',
252255
' '.join([coeff(a1), 'xy']) if a1 else '',
253256
' '.join([coeff(a3), 'y']) if a3 else '',
@@ -606,12 +609,14 @@ def certain(self):
606609
"""
607610
return bool(self.__two_descent_data().getcertain())
608611

609-
#def fullmw(self):
610-
# return self.__two_descent_data().getfullmw()
612+
# def fullmw(self):
613+
# return self.__two_descent_data().getfullmw()
611614

612615
def CPS_height_bound(self):
613616
r"""
614-
Return the Cremona-Prickett-Siksek height bound. This is a
617+
Return the Cremona-Prickett-Siksek height bound.
618+
619+
This is a
615620
floating point number `B` such that if `P` is a point on the
616621
curve, then the naive logarithmic height `h(P)` is less than
617622
`B+\hat{h}(P)`, where `\hat{h}(P)` is the canonical height of
@@ -1282,9 +1287,9 @@ def search(self, height_limit=18, verbose=False):
12821287
"""
12831288
height_limit = float(height_limit)
12841289
int_bits = sys.maxsize.bit_length()
1285-
max_height_limit = int_bits * 0.693147 # log(2.0) = 0.693147 approx
1290+
max_height_limit = int_bits * 0.693147 # log(2.0) = 0.693147 approx
12861291
if height_limit >= max_height_limit:
1287-
raise ValueError("The height limit must be < {} = {}log(2) on a {}-bit machine.".format(max_height_limit, int_bits, int_bits+1))
1292+
raise ValueError("The height limit must be < {} = {}log(2) on a {}-bit machine.".format(max_height_limit, int_bits, int_bits + 1))
12881293

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

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
3.60546360143265208591582056420772677481026899659802474544 # 32-bit
174174
"""
175175

176+
176177
def _get_pari_instance():
177178
"""
178179
TESTS::
@@ -181,8 +182,8 @@ def _get_pari_instance():
181182
Interface to the PARI C library
182183
"""
183184
from cypari2 import Pari
184-
stack_initial = 1024*1024
185-
stack_max = 1024*stack_initial
185+
stack_initial = 1024 * 1024
186+
stack_max = 1024 * stack_initial
186187
P = Pari(stack_initial, stack_max)
187188

188189
# 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
@@ -95,7 +95,7 @@ def __exit__(self, typ, value, tb):
9595
b - 3*d^6 + 2*d^4 + d^3 + 2*d^2 - 3*d,
9696
a - 2*d^6 + d^5 - 2*d^4 + 3*d^3 + 3*d^2 - 2*d - 1]
9797
"""
98-
self.libsingular_option_context.__exit__(typ,value,tb)
98+
self.libsingular_option_context.__exit__(typ, value, tb)
9999

100100
def libsingular_gb_standard_options(func):
101101
r"""

0 commit comments

Comments
 (0)