readback_checks.py

back to table · edit · history · where entries came from · files · download

2243 bytes, as of the version from 2026-11-17 16:08 (current). Recorded here, not run.

"""Full readback checks, without repeating the completed quadrature run.
cat KEY | agents/sage.sh readback_checks.py generate.py checks.py stored.json
"""
import sys,json
from pathlib import Path
import mpmath as mp
import numberdb.sage as numberdb
from numberdb._write import _as_interval
from generate import EvenPowerBessel,normalized,stored_text
from checks import recurrence,phase,contains,bounds,parts,exact_q
key=sys.stdin.read().strip()
if '=' in key:key=key.split('=',1)[1].strip().strip('\"\'')
numberdb.configure(api_key=key)
doc=numberdb.table('T740');g=EvenPowerBessel();expected=recurrence()
report=g.verify(sample=None);print('VERIFY',report);assert report.ok and report.checked==32
identities=[]
for params in g.enumerate():
 n=int(params['n']);norm=params['normalization'];text=doc['Numbers'][str(n)][norm]
 if isinstance(text,dict):text=text['number']
 assert text==stored_text(g.value(params,100),100),(n,norm,'reproduction')
 v=expected[n]*(phase(n) if norm=='period' else 1)
 assert contains(text,v),(n,norm,'independent recurrence')
 high=normalized(n,norm,180)
 for t,component in zip(parts(text),(high.real(),high.imag())):
  lo,hi=bounds(t);interval=_as_interval(component)
  assert component.is_finite()
  assert exact_q(lo)<=interval.lower().exact_rational() and interval.upper().exact_rational()<=exact_q(hi)
 identities.append([n,norm])
assert [(int(n),norm) for n,v in doc['Numbers'].items() for norm in v]==[(p['n'],p['normalization']) for p in g.enumerate()]
assert not contains(doc['Numbers']['1']['bessel'],-mp.pi/2)
assert not contains(doc['Numbers']['3']['period'],expected[3]*phase(3)/2)
print('READBACK_JSON='+json.dumps({'table':'T740','checked_entries':32,'total_entries':32,'failures':[],'known_answer_control':contains(doc['Numbers']['1']['bessel'],mp.pi/2),'negative_control_rejected':True,'exact_serialized_reproduction':True,'high_ball_containment':True,'recurrence_containment':True,'identities':identities,'verify':{'checked':report.checked,'matched':report.matched,'missing':report.missing,'differing':report.differing},'limitations':'Installed verify may call unfamiliar complex spellings matched; all serialized strings and actual interval containment are additionally checked explicitly.'}))