import json,sys
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parent))
import mpmath as mp
import numberdb.sage as numberdb
import checks
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
D=json.load(open(Path(__file__).with_name('stored-document.json')));ns={};exec(D['Programs']['example']['code'],ns)
r=[]
for d in [1,2,3,100]:
 val=ns['mu'](d);lo,hi=checks.decimal_bounds(D['Numbers'][str(d)])
 # This checks the mpmath example numerically. It is not rigorous evidence.
 passed=mp.mpf(str(lo.numerator()))/int(lo.denominator())<val<mp.mpf(str(hi.numerator()))/int(hi.denominator())
 r.append({'d':d,'value_110_digits':mp.nstr(val,110),'inside_stored_interval':bool(passed)})
assert all(x['inside_stored_interval'] for x in r)
print('PROGRAM_CHECK_JSON='+json.dumps({'mpmath_version':mp.__version__,'working_decimal_digits':mp.mp.dps,'samples':r}))
