8000 pep8 cleanup in libs by fchapoton · Pull Request #39048 · sagemath/sage · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pep8 cleanup in libs #39048

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

Merged
merged 1 commit into from
Dec 8, 2024
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
17 changes: 9 additions & 8 deletions src/sage/libs/coxeter3/coxeter_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def m(self, i, j):
"""
from sage.misc.superseded import deprecation
deprecation(30237, "the .m(i, j) method has been deprecated; use .coxeter_matrix()[i,j] instead.")
return self.coxeter_matrix()[i,j]
return self.coxeter_matrix()[i, j]

def kazhdan_lusztig_polynomial(self, u, v, constant_term_one=True):
r"""
Expand Down Expand Up @@ -354,8 +354,9 @@ def kazhdan_lusztig_polynomial(self, u, v, constant_term_one=True):
return p
ZZq = PolynomialRing(ZZ, 'q', sparse=True)
# This is the same as q**len_diff * p(q**(-2))
len_diff = v.length()-u.length()
d = {-2*deg+len_diff: coeff for deg,coeff in enumerate(p) if coeff != 0}
len_diff = v.length() - u.length()
d = {-2 * deg + len_diff: coeff for deg, coeff in enumerate(p)
if coeff != 0}
return ZZq(d)

def parabolic_kazhdan_lusztig_polynomial(self, u, v, J, constant_term_one=True):
Expand Down Expand Up @@ -414,11 +415,11 @@ def parabolic_kazhdan_lusztig_polynomial(self, u, v, J, constant_term_one=True):
WOI = self.weak_order_ideal(lambda x: J_set.issuperset(x.descents()))
if constant_term_one:
P = PolynomialRing(ZZ, 'q')
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u*z,v)
for z in WOI if (u*z).bruhat_le(v))
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u * z, v)
for z in WOI if (u * z).bruhat_le(v))
P = PolynomialRing(ZZ, 'q', sparse=True)
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u*z,v, constant_term_one=False).shift(z.length())
for z in WOI if (u*z).bruhat_le(v))
return P.sum((-1)**(z.length()) * self.kazhdan_lusztig_polynomial(u * z, v, constant_term_one=False).shift(z.length())
for z in WOI if (u * z).bruhat_le(v))

class Element(ElementWrapper):
wrapped_class = CoxGroupElement
Expand Down Expand Up @@ -701,7 +702,7 @@ def action_on_rational_function(self, f):

for exponent in exponents:
# Construct something in the root lattice from the exponent vector
exponent = sum(e*b for e, b in zip(exponent, basis_elements))
exponent = sum(e * b for e, b in zip(exponent, basis_elements))
exponent = self.action(exponent)

monomial = 1
Expand Down
19 changes: 12 additions & 7 deletions src/sage/libs/eclib/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,11 @@
"""
a1, a2, a3, a4, a6 = self.__ainvs
# we do not assume a1, a2, a3 are reduced to {0,1}, {-1,0,1}, {0,1}
coeff = lambda a: ''.join([" +" if a > 0 else " -",
" " + str(abs(a)) if abs(a) > 1 else ""])

def coeff(a):
return ''.join([" +" if a > 0 else " -",
" " + str(abs(a)) if abs(a) > 1 else ""])

return ''.join(['y^2',
' '.join([coeff(a1), 'xy']) if a1 else '',
' '.join([coeff(a3), 'y']) if a3 else '',
Expand Down Expand Up @@ -606,12 +609,14 @@
"""
return bool(self.__two_descent_data().getcertain())

#def fullmw(self):
# return self.__two_descent_data().getfullmw()
# def fullmw(self):
# return self.__two_descent_data().getfullmw()

def CPS_height_bound(self):
r"""
Return the Cremona-Prickett-Siksek height bound. This is a
Return the Cremona-Prickett-Siksek height bound.

This is a
floating point number `B` such that if `P` is a point on the
curve, then the naive logarithmic height `h(P)` is less than
`B+\hat{h}(P)`, where `\hat{h}(P)` is the canonical height of
Expand Down Expand Up @@ -1282,9 +1287,9 @@
"""
height_limit = float(height_limit)
int_bits = sys.maxsize.bit_length()
max_height_limit = int_bits * 0.693147 # log(2.0) = 0.693147 approx
max_height_limit = int_bits * 0.693147 # log(2.0) = 0.693147 approx
if height_limit >= max_height_limit:
raise ValueError("The height limit must be < {} = {}log(2) on a {}-bit machine.".format(max_height_limit, int_bits, int_bits+1))
raise ValueError("The height limit must be < {} = {}log(2) on a {}-bit machine.".format(max_height_limit, int_bits, int_bits + 1))

Check warning on line 1292 in src/sage/libs/eclib/interface.py

View check run for this annotation

Codecov / codecov/patch

src/sage/libs/eclib/interface.py#L1292

Added line #L1292 was not covered by tests

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

Expand Down
62 changes: 31 additions & 31 deletions src/sage/libs/gap/gap_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@


# selected gap globals to use in tab completion
common_gap_globals = set([
'Assert',
'Cyclotomics',
'GaussianIntegers',
'GaussianRationals',
'GlobalMersenneTwister',
'GlobalRandomSource',
'InfoAlgebra',
'InfoAttributes',
'InfoBckt',
'InfoCharacterTable',
'InfoCoh',
'InfoComplement',
'InfoCoset',
'InfoFpGroup',
'InfoGroebner',
'InfoGroup',
'InfoLattice',
'InfoMatrix',
'InfoMonomial',
'InfoNumtheor',
'InfoOptions',
'InfoPackageLoading',
'InfoPcSubgroup',
'InfoWarning',
'Integers',
'NiceBasisFiltersInfo',
'Primes',
'Rationals',
'TableOfMarksComponents'
]) | common_gap_functions
common_gap_globals = {
'Assert',
'Cyclotomics',
'GaussianIntegers',
'GaussianRationals& 8000 #39;,
'GlobalMersenneTwister',
'GlobalRandomSource',
'InfoAlgebra',
'InfoAttributes',
'InfoBckt',
'InfoCharacterTable',
'InfoCoh',
'InfoComplement',
'InfoCoset',
'InfoFpGroup',
'InfoGroebner',
'InfoGroup',
'InfoLattice',
'InfoMatrix',
'InfoMonomial',
'InfoNumtheor',
'InfoOptions',
'InfoPackageLoading',
'InfoPcSubgroup',
'InfoWarning',
'Integers',
'NiceBasisFiltersInfo',
'Primes',
'Rationals',
'TableOfMarksComponents'
} | common_gap_functions
2 changes: 1 addition & 1 deletion src/sage/libs/gap/test_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_loop_2():
G = libgap.FreeGroup(2)
a, b = G.GeneratorsOfGroup()
for i in range(100):
rel = libgap([a**2, b**2, a*b*a*b])
rel = libgap([a**2, b**2, a * b * a * b])
H = G / rel
H1 = H.GeneratorsOfGroup()[0]
n = H1.Order()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/libs/giac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
return PolynomialSequence([P(0)], P, immutable=True)

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

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

# compute de groebner basis with giac
gb_giac = F.gbasis(list(var_names), giac_order)
Expand Down
5 changes: 3 additions & 2 deletions src/sage/libs/pari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
3.60546360143265208591582056420772677481026899659802474544 # 32-bit
"""


def _get_pari_instance():
"""
TESTS::
Expand All @@ -181,8 +182,8 @@ def _get_pari_instance():
Interface to the PARI C library
"""
from cypari2 import Pari
stack_initial = 1024*1024
stack_max = 1024*stack_initial
stack_initial = 1024 * 1024
stack_max = 1024 * stack_initial
P = Pari(stack_initial, stack_max)

# pari_init_opts() overrides MPIR's memory allocation functions,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/singular/standard_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __exit__(self, typ, value, tb):
b - 3*d^6 + 2*d^4 + d^3 + 2*d^2 - 3*d,
a - 2*d^6 + d^5 - 2*d^4 + 3*d^3 + 3*d^2 - 2*d - 1]
"""
self.libsingular_option_context.__exit__(typ,value,tb)
self.libsingular_option_context.__exit__(typ, value, tb)

def libsingular_gb_standard_options(func):
r"""
Expand Down
Loading
0