special._mptestutils

Module Contents

Classes

Arg(self,a=None,b=None,inclusive_a=True,inclusive_b=True) Generate a set of numbers on the real axis, concentrating on
FixedArg(self,values)
ComplexArg(self,a=complex,b=complex)
IntArg(self,a=None,b=1000)
MpmathData(self,scipy_func,mpmath_func,arg_spec,name=None,dps=None,prec=None,n=None,rtol=1e-07,atol=1e-300,ignore_inf_sign=False,distinguish_nan_and_inf=True,nan_ok=True,param_filter=None)
TimeoutError()

Functions

get_args(argspec,n)
assert_mpmath_equal(*a,**kw)
nonfunctional_tooslow(func)
mpf2float(x) Convert an mpf to the nearest floating point number. Just using
mpc2complex(x)
trace_args(func)
time_limited(timeout=0.5,return_val=None,use_sigalrm=True) Decorator for setting a timeout for pure-Python functions.
exception_to_nan(func) Decorate function to return nan if it raises an exception
inf_to_nan(func) Decorate function to return nan if it returns inf
mp_assert_allclose(res,std,atol=0,rtol=1e-17) Compare lists of mpmath.mpf’s or mpmath.mpc’s directly so that it
class Arg(a=None, b=None, inclusive_a=True, inclusive_b=True)

Generate a set of numbers on the real axis, concentrating on ‘interesting’ regions and covering all orders of magnitude.

__init__(a=None, b=None, inclusive_a=True, inclusive_b=True)
values(n)

Return an array containing approximatively n numbers.

class FixedArg(values)
__init__(values)
values(n)
class ComplexArg(a=complex, b=complex)
__init__(a=complex, b=complex)
values(n)
class IntArg(a=None, b=1000)
__init__(a=None, b=1000)
values(n)
get_args(argspec, n)
class MpmathData(scipy_func, mpmath_func, arg_spec, name=None, dps=None, prec=None, n=None, rtol=1e-07, atol=1e-300, ignore_inf_sign=False, distinguish_nan_and_inf=True, nan_ok=True, param_filter=None)
__init__(scipy_func, mpmath_func, arg_spec, name=None, dps=None, prec=None, n=None, rtol=1e-07, atol=1e-300, ignore_inf_sign=False, distinguish_nan_and_inf=True, nan_ok=True, param_filter=None)
check()
__repr__()
assert_mpmath_equal(*a, **kw)
nonfunctional_tooslow(func)
mpf2float(x)

Convert an mpf to the nearest floating point number. Just using float directly doesn’t work because of results like this:

with mp.workdps(50):
float(mpf(“0.99999999999999999”)) = 0.9999999999999999
mpc2complex(x)
trace_args(func)
class TimeoutError
time_limited(timeout=0.5, return_val=None, use_sigalrm=True)

Decorator for setting a timeout for pure-Python functions.

If the function does not return within timeout seconds, the value return_val is returned instead.

On POSIX this uses SIGALRM by default. On non-POSIX, settrace is used. Do not use this with threads: the SIGALRM implementation does probably not work well. The settrace implementation only traces the current thread.

The settrace implementation slows down execution speed. Slowdown by a factor around 10 is probably typical.

exception_to_nan(func)

Decorate function to return nan if it raises an exception

inf_to_nan(func)

Decorate function to return nan if it returns inf

mp_assert_allclose(res, std, atol=0, rtol=1e-17)

Compare lists of mpmath.mpf’s or mpmath.mpc’s directly so that it can be done to higher precision than double.