back to table · edit · history · where entries came from · files · download
1912 bytes, as of the version from 2026-11-02 09:34 (current). Recorded here, not run.
"""Rebuild eta-data.json from the attached original MAGMA text data.
Run with ordinary Python: python3 rebuild_eta_data.py
No MAGMA code is executed. Exact rational weights remain strings.
"""
import ast
import json
import re
from pathlib import Path
ROOT=Path(__file__).resolve().parent
CLASSES={'1A':(4,10,'g4'),'2A':(8,6,'g8'),'3A':(36,4,'g12'),
'3B':(12,4,'g12'),'3C':(36,4,'g12'),'4A':(16,6,'g8'),
'4B':(32,6,'g8'),'5A':(20,4,'g20')}
def rebuild():
raw=json.loads((ROOT/'source-inputs.json').read_text())
data={}
for cl,(level,weight,denname) in CLASSES.items():
text=re.search(denname+r':=(\[.*?\]);',raw['etahalf.m']).group(1)
den=dict(ast.literal_eval(text.replace('<','(').replace('>',')')))
source=f'EtaWt{weight}_{level}.m';cf=f'EtaCoeffs{cl}.m'
basis=ast.literal_eval(raw[source].split(':=',1)[1].strip().rstrip(';').replace('<','(').replace('>',')'))
weights=[s.strip() for s in raw[cf].split('[',1)[1].split(']')[0].split(',')]
assert len(weights)==len(basis)
terms=[]
for coeff,eta in zip(weights,basis):
if coeff=='0':continue
exps=dict(eta)
for d,e in den.items():exps[d]=exps.get(d,0)-e
exps=[[d,e] for d,e in sorted(exps.items()) if e]
assert sum(e for d,e in exps)==1
assert sum(d*e for d,e in exps)%24==0
terms.append({'coefficient':coeff,'eta_exponents':exps})
data[cl]={'level':level,'basis_file':source,'coefficients_file':cf,'denominator':denname,'terms':terms}
return data
if __name__=='__main__':
rebuilt=json.dumps(rebuild(),indent=2)
existing=ROOT/'eta-data.json'
if existing.exists():
assert existing.read_text()==rebuilt
print('Every frozen eta exponent and rational coefficient agrees with the original source inputs.')
else:existing.write_text(rebuilt)