Skip to content

Commit

Permalink
Added mainly cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasdeu committed Feb 9, 2024
1 parent 0131953 commit ce74d32
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
12 changes: 6 additions & 6 deletions darmonpoints/padicperiods.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def precompute_powers(p, q, N):
pdict[2 * i] = q * pdict[2 * i - 2]
for i in range(1, N + 2):
idx = i**2 - i
if not pdict.has_key(idx):
if idx not in pdict.keys():
pdict[idx] = pdict[2 * i - 2] * pdict[idx - 2 * i + 2]
return pdict


# Theta functions of (25) in Teitelbaum's
# and also the other theta functions that we need to compute the lambda's according to the formulas (23)
# We sum terms until we get the result to the accuracy prec. When deciding the set of indicies over which we sum, we have made several simplifications that probably cause that we sum more terms than strictly needed for that accuracy, but this probably won't be an issue...
# We sum terms until we get the result to the accuracy prec. When deciding the set of indices over which we sum, we have made several simplifications that probably cause that we sum more terms than strictly needed for that accuracy, but this probably won't be an issue...
def Thetas(p1, p2, p3, q1, q2, q3, prec=None):
if prec is None:
prec = 2 * p1.parent().precision_cap()
Expand Down Expand Up @@ -921,7 +921,7 @@ def find_igusa_invariants_from_AB(A, B, T, scaling, prec, **kwargs):
phi = kwargs.get("phi", lambda x: Qp(p, prec)(x))
mat_coeffs_range = kwargs.get("mat_coeffs_range", 3)
base = kwargs.setdefault("base", QQ)
if kwargs.has_key("list_I10"):
if "list_I10" in kwargs.keys():
list_I10 = kwargs["list_I10"]
kwargs["list_I10_padic"] = [phi(o) for o in list_I10]
# matlists = kwargs.get('matlists',generate_matlists(Lambdalist,mat_coeffs_range))
Expand Down Expand Up @@ -1057,9 +1057,9 @@ def find_igusa_invariants(


def check_generic(xvec, prec, data, **kwargs):
if kwargs.has_key("cheatjs"):
if "cheatjs" in kwargs.keys():
return check_cheatjs(xvec, prec, data, **kwargs)
elif kwargs.has_key("list_I10"):
elif "list_I10" in kwargs.keys():
return check_absoluteinvs(xvec, prec, data, **kwargs) + check_listI10(
xvec, prec, data, **kwargs
)
Expand Down Expand Up @@ -1499,7 +1499,7 @@ def guess_equation(
K0 = Qq(Pnrm**2, prec, names="s")
A = K0(take_to_Qp(Pnrm**Aval * Alog.exp() * Amul))
B = K0(take_to_Qp(Pnrm**Bval * Blog.exp() * Bmul))
if not param_dict.has_key("list_I10"):
if "list_I10" not in param_dict.keys():
param_dict["list_I10"] = generate_listI10(
G.F, G.ideal_p * G.discriminant * G.level
)
Expand Down
60 changes: 46 additions & 14 deletions darmonpoints/schottky.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sage.structure.richcmp import richcmp
from sage.structure.sage_object import SageObject
from sage.structure.unique_representation import UniqueRepresentation

from sage.misc.latex import latex
from .divisors import Divisors, DivisorsElement
from .meromorphic import *

Expand Down Expand Up @@ -220,23 +220,37 @@ def improve_one(self):

def _repr_(self):
a, b = self.a, self.b
if b is None:
try:
lst = a.as_list_of_differences()
if len(lst) == 1:
a, b = lst[0]
except AttributeError:
pass
try:
a = self.a.lift()
b = self.b.lift()
a = a.lift()
b = b.lift()
except AttributeError:
pass
return f"Θ(z;{a},{b})_{{{self.m}}}"

def _latex_(self):
a, b = self.a, self.b
if b is None:
try:
lst = a.as_list_of_differences()
if len(lst) == 1:
a, b = lst[0]
except AttributeError:
pass
try:
a = self.a.rational_reconstruction()
b = self.b.rational_reconstruction()
a = a.lift()
b = b.lift()
except AttributeError:
pass
try:
a = self.a.lift()
b = self.b.lift()
a = a.rational_reconstruction()
b = b.rational_reconstruction()
except AttributeError:
pass
return f"\\Theta(z;{latex(a)},{latex(b)})_{{{latex(self.m)}}}"
Expand All @@ -261,7 +275,11 @@ def evaluate(self, z, recursive=True):
)
return ans

def eval_derivative(self, z):
def eval_derivative(self, z, recursive=True):
if recursive and not G.in_fundamental_domain(z, closure=True):
raise NotImplementedError("Recursivity not implemented for derivative")
if isinstance(z, DivisorsElement):
return prod(self.eval_derivative(P, recursive=recursive) ** n for P, n in z)
v0 = self.val(z)
Fnz = {}
for ky, F in self.Fn.items():
Expand Down Expand Up @@ -309,6 +327,9 @@ def generators(self):
def inverse_generators(self):
return self._inverse_generators

def _repr_(self):
return "Schottky group with %s generators"%len(self.generators())

def enumerate_group_elements(self, length):
return enumerate_group_elements(
self._generators, self._inverse_generators, length
Expand Down Expand Up @@ -693,6 +714,7 @@ def find_equivalent_divisor(self, D):

def theta(self, prec, a=ZZ(0), b=ZZ(1), **kwargs):
r"""
Compute the Theta function
EXAMPLES ::
Expand All @@ -718,11 +740,21 @@ def theta(self, prec, a=ZZ(0), b=ZZ(1), **kwargs):
DK = Divisors(K)
gens = self.generators()
D0 = DK(a) - DK(b)
s = kwargs.pop("s", None)
if s is not None:
D0 += s * D0
D = self.find_equivalent_divisor(D0)
return ThetaOC(self, a=D, b=None, prec=prec, **kwargs).improve(prec)
ans = ThetaOC(self, a=D, b=None, prec=prec, **kwargs)
improve = kwargs.pop("improve", True)
if improve:
ans = ans.improve(prec)
return ans

@cached_method
def u_function(self, gamma, prec, a=None, **kwargs):
r"""
Compute u_gamma
"""
K = self.base_ring()
DK = Divisors(K)
if a is None:
Expand All @@ -735,7 +767,7 @@ def u_function(self, gamma, prec, a=None, **kwargs):
@cached_method
def period(self, i, j, prec, **kwargs):
r"""
Computes the (i,j)-entry of the period matrix.
Compute the (i,j)-entry of the period matrix.
EXAMPLES ::
Expand All @@ -747,9 +779,9 @@ def period(self, i, j, prec, **kwargs):
sage: h1 = matrix(K, 2, 2, [-5,32,-8,35])
sage: h2 = matrix(K, 2, 2, [-13,80,-8,43])
sage: G = SchottkyGroup(K, (h1,h2))
sage: q00g = G.period_naive(prec, 0, 0)
sage: q01g = G.period_naive(prec, 0, 1)
sage: q11g = G.period_naive(prec, 1, 1)
sage: q00g = G.period_naive(0, 0, prec)
sage: q01g = G.period_naive(0, 1, prec)
sage: q11g = G.period_naive(1, 1, prec)
sage: q00 = G.period(0,0, prec)
sage: q01 = G.period(0,1, prec)
sage: q11 = G.period(1,1, prec)
Expand All @@ -776,7 +808,7 @@ def period(self, i, j, prec, **kwargs):
verbose(f"{den = }")
return num / den

def period_naive(self, prec, i, j, **kwargs):
def period_naive(self, i, j, prec, **kwargs):
g1 = self.generators()[i]
g2 = self.generators()[j]
z1 = self.find_point(g1)
Expand Down

0 comments on commit ce74d32

Please sign in to comment.