offline_checks.py

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

1778 bytes, as of the version from 2026-12-02 03:19 (current). Recorded here, not run.

import contextlib
import io
import json
import platform
from pathlib import Path
import sys
import numberdb.sage as numberdb
from numberdb._generate import _written
from sage.rings.rational_field import QQ
from sage.version import version
from generate import GelfondConstant
import check_math
import dry_run

generator = GelfondConstant()
assert generator.parameters == () and list(generator.enumerate()) == [{}]
value = generator.value({},100)
assert type(value).__name__ == 'RealBall'
text = _written(value,100,'decimal')
math_report = check_math.report(text)
lo,hi = QQ(math_report['lower']), QQ(math_report['upper'])
ball_lo,ball_hi = value.lower().exact_rational(), value.upper().exact_rational()
assert max(lo,ball_lo) <= min(hi,ball_hi)
assert ball_hi-ball_lo < QQ(1)/10**149
s0,s1,ulp = check_math.decimal_interval(text)
assert s0 <= ball_lo <= ball_hi <= s1
buf = io.StringIO()
with contextlib.redirect_stdout(buf):
    status = dry_run.main([str(Path(__file__).with_name('generate.py'))])
assert status == 0
result = {'versions': {'python': platform.python_version(), 'sage': version, 'numberdb': numberdb.__version__},
          'skill_manifest': 'agents/runs/20261202T020739Z-build-skills/manifest.json',
          'enumeration': [{}], 'native_return_type': type(value).__name__, 'digits': 100,
          'working_bits': int(value.parent().precision()), 'relative_accuracy_bits': int(value.accuracy()),
          'ball_lower': str(ball_lo), 'ball_upper': str(ball_hi), 'ball_width': str(ball_hi-ball_lo),
          'ball_radius': str(value.rad()), 'stored_decimal': text,
          'serialized_contains_ball': True, 'independent_comparison': math_report,
          'dry_run_status': status, 'dry_run_log': buf.getvalue()}
print('RESULT_JSON=' + json.dumps(result))