Return passed in function in defun* decorators

This turn on more doctests, e.g.:

$ py.test mpmath/functions/qfunctions.py
============================= test session starts ==============================
platform linux -- Python 3.7.1, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/sk/src/mpmath/.hypothesis/examples')
rootdir: /home/sk/src/mpmath, inifile: setup.cfg
plugins: xdist-1.26.1, timeout-1.3.3, forked-1.0.1, cov-2.6.1, hypothesis-4.4.3
collected 4 items

mpmath/functions/qfunctions.py ....                                      [100%]

=========================== 4 passed in 0.49 seconds ===========================

Some doctests were adapted.
This commit is contained in:
Sergey B Kirpichev
2019-02-03 18:14:48 +03:00
parent fcf7d44d7b
commit ef7597994d
3 changed files with 9 additions and 6 deletions
+4 -4
View File
@@ -9770,8 +9770,8 @@ on the unit sphere::
>>> Y1 = lambda t,p: fp.spherharm(l1,m1,t,p)
>>> Y2 = lambda t,p: fp.conj(fp.spherharm(l2,m2,t,p))
>>> l1 = l2 = 3; m1 = m2 = 2
>>> print(fp.quad(lambda t,p: Y1(t,p)*Y2(t,p)*dS(t,p), *sphere))
(1+0j)
>>> fp.chop(fp.quad(lambda t,p: Y1(t,p)*Y2(t,p)*dS(t,p), *sphere))
1.0000000000000007
>>> m2 = 1 # m1 != m2
>>> print(fp.chop(fp.quad(lambda t,p: Y1(t,p)*Y2(t,p)*dS(t,p), *sphere)))
0.0
@@ -10011,7 +10011,7 @@ Pass ``exact=True`` to obtain exact values of Stirling numbers as integers::
>>> stirling1(42, 5)
-2.864498971768501633736628e+50
>>> print stirling1(42, 5, exact=True)
>>> print(stirling1(42, 5, exact=True))
-286449897176850163373662803014001546235808317440000
"""
@@ -10045,7 +10045,7 @@ Pass ``exact=True`` to obtain exact values of Stirling numbers as integers::
>>> stirling2(52, 10)
2.641822121003543906807485e+45
>>> print stirling2(52, 10, exact=True)
>>> print(stirling2(52, 10, exact=True))
2641822121003543906807485307053638921722527655
+3
View File
@@ -80,12 +80,15 @@ class SpecialFunctions(object):
def defun_wrapped(f):
SpecialFunctions.defined_functions[f.__name__] = f, True
return f
def defun(f):
SpecialFunctions.defined_functions[f.__name__] = f, False
return f
def defun_static(f):
setattr(SpecialFunctions, f.__name__, f)
return f
@defun_wrapped
def cot(ctx, z): return ctx.one / ctx.tan(z)
+2 -2
View File
@@ -938,8 +938,8 @@ def secondzeta(ctx, s, a = 0.015, **kwargs):
0.023104993115419
>>> xi = lambda s: 0.5*s*(s-1)*pi**(-0.5*s)*gamma(0.5*s)*zeta(s)
>>> Xi = lambda t: xi(0.5+t*j)
>>> -0.5*diff(Xi,0,n=2)/Xi(0)
(0.023104993115419 + 0.0j)
>>> chop(-0.5*diff(Xi,0,n=2)/Xi(0))
0.023104993115419
We may ask for an approximate error value::