generate.py

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

1519 bytes, as of the version from 2026-10-27 01:06 (current). Recorded here, not run.

"""Recompute the complete attached selection without network access.

    pip install numberdb python-flint mpmath
    python generate.py
    python generate.py --independent

Download the whole bundle. The default recomputes every value and checks its
recorded interval. --independent also uses independent algorithms and controls.
These commands never submit, approve, publish, or change the website.
"""

import argparse
import json
from pathlib import Path

from balanced_checks import assert_contained, check
from balanced_values import BalancedValues


generator = BalancedValues()
ScorerGiValues = BalancedValues
ScorerHiValues = BalancedValues


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--independent', action='store_true')
    options = parser.parse_args()
    numbers = json.loads(Path(__file__).with_name('balanced-numbers.json').read_text())
    if options.independent:
        evidence = check(generator, numbers)
        print('Independent checks passed for', evidence['entries'], 'entries')
    else:
        for params in generator.enumerate():
            identity = str(params['x'])
            entry = numbers[identity]
            written = entry['number'] if isinstance(entry, dict) else entry
            result = generator.value(params, generator.digits_for(params))
            assert_contained(written, result['number'], identity)
        print(generator.table, len(numbers), 'recorded values reproduced; no website access')