Skip to content

Commit 6804989

Browse files
committed
More coverage and small behavior change
1 parent b44dee6 commit 6804989

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

src/sage/modular/modform/element.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,25 @@ def __call__(self, x, prec=None):
283283
sage: f(0.0+0.0*I)
284284
0
285285
286+
For simplicity, ``float`` or ``complex`` input are converted to ``CC``, except for
287+
input ``0`` where exact result is returned::
288+
289+
sage: result = f(0.3r); result # rel tol 1e-12
290+
0.299999997396191
291+
sage: result.parent()
292+
Complex Field with 53 bits of precision
293+
sage: result = f(0.3r + 0.3jr); result # rel tol 1e-12
294+
0.299999359878484 + 0.299999359878484*I
295+
sage: result.parent()
296+
Complex Field with 53 bits of precision
297+
298+
Symbolic numerical values use precision of ``CC`` by default::
299+
300+
sage: f(sqrt(1/2)) # rel tol 1e-12
301+
0.700041406692037
302+
sage: f(sqrt(1/2)*QQbar.zeta(8)) # rel tol 1e-12
303+
0.496956554651376 + 0.496956554651376*I
304+
286305
Higher precision::
287306
288307
sage: f(ComplexField(128)(0.3)) # rel tol 1e-36
@@ -354,6 +373,20 @@ def eval_at_tau(self, tau):
354373
355374
TESTS:
356375
376+
Symbolic numerical values use precision of ``CC`` by default::
377+
378+
sage: f.eval_at_tau(sqrt(1/5)*I) # rel tol 1e-12
379+
0.0123633234207127
380+
sage: f.eval_at_tau(sqrt(1/2)*QQbar.zeta(8)) # rel tol 1e-12
381+
-0.114263670441098
382+
383+
For simplicity, ``complex`` input are converted to ``CC``::
384+
385+
sage: result = f.eval_at_tau(0.3jr); result # rel tol 1e-12
386+
0.00150904633897550
387+
sage: result.parent()
388+
Complex Field with 53 bits of precision
389+
357390
Check ``SR`` does not make the result lose precision::
358391
359392
sage: f = EisensteinForms(1, 4).0
@@ -362,6 +395,7 @@ def eval_at_tau(self, tau):
362395
"""
363396
from sage.libs.pari.convert_sage import gen_to_sage
364397
from sage.libs.pari import pari
398+
from sage.rings.cc import CC
365399
from sage.rings.complex_mpfr import ComplexNumber, ComplexField
366400
from sage.rings.real_mpfr import RealNumber
367401
from sage.symbolic.expression import Expression
@@ -370,16 +404,10 @@ def eval_at_tau(self, tau):
370404
tau = tau.pyobject()
371405
except TypeError:
372406
pass
373-
if isinstance(tau, (RealNumber, ComplexNumber)):
374-
precision = tau.prec()
375-
else:
376-
precision = 53
377-
result = gen_to_sage(pari(self.parent()).mfeval(self, tau, precision=precision))
378-
if isinstance(tau, (float, complex)):
379-
result = complex(result)
380-
elif isinstance(tau, (RealNumber, ComplexNumber)):
381-
result = ComplexField(precision)(result)
382-
return result
407+
if not isinstance(tau, (RealNumber, ComplexNumber)):
408+
tau = CC(tau)
409+
precision = tau.prec()
410+
return ComplexField(precision)(pari.mfeval(self.parent(), self, tau, precision=precision))
383411

384412
@cached_method
385413
def valuation(self):

0 commit comments

Comments
 (0)