Datasets:
Formats:
csv
Languages:
English
Size:
100K - 1M
Tags:
research-artifact
synthetic-data
mathematical-proofs
system-identification
inverse-problems
nonlinear-dynamics
License:
Download scripts/build_manuscript.py from PureOne/EVE-Obstruction-Tomography: direct link, hf CLI and curl.
- Browser
- Download file 3.11 kB
-
https://huggingface.co/datasets/PureOne/EVE-Obstruction-Tomography/resolve/main/scripts/build_manuscript.py
- Command line
-
hf download hf://datasets/PureOne/EVE-Obstruction-Tomography/scripts/build_manuscript.py
-
curl -L -o build_manuscript.py https://huggingface.co/datasets/PureOne/EVE-Obstruction-Tomography/resolve/main/scripts/build_manuscript.py
3.11 kB
| #!/usr/bin/env python3 | |
| """Build the PDF and full Markdown reading copy; requires TeX and Pandoc.""" | |
| from pathlib import Path | |
| import re,shutil,subprocess,tempfile | |
| ROOT=Path(__file__).resolve().parents[1] | |
| MS=ROOT/'manuscript' | |
| with tempfile.TemporaryDirectory(prefix='eve_ot_tex_') as temp: | |
| logs=[] | |
| for _ in range(3): | |
| proc=subprocess.run(['pdflatex','-interaction=nonstopmode','-halt-on-error', | |
| '-output-directory='+temp,'main.tex'],cwd=MS, | |
| stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) | |
| logs.append(proc.stdout) | |
| if proc.returncode: | |
| print(proc.stdout);raise SystemExit(proc.returncode) | |
| if 'undefined references' in logs[-1] or 'Overfull' in logs[-1]: | |
| raise RuntimeError('Unresolved references or layout overflow in final TeX pass') | |
| shutil.copy2(Path(temp)/'main.pdf',ROOT/'EVE_Obstruction_Tomography_II.pdf') | |
| (ROOT/'results'/'manuscript_build.log').write_text('\n'.join(logs)) | |
| aux=(Path(temp)/'main.aux').read_text() | |
| refs=dict(re.findall(r'\\newlabel\{([^}]+)\}\{\{([^}]+)\}',aux)) | |
| source=(MS/'main.tex').read_text() | |
| for name in ['theory_and_evidence','nonlinear_extension']: | |
| source=source.replace(r'\input{'+name+'}',(MS/(name+'.tex')).read_text()) | |
| count=[0] | |
| def theorem(m): | |
| count[0]+=1 | |
| typ=m.group(1).capitalize();name=m.group(2) | |
| return r'\paragraph{'+typ+' '+str(count[0])+(' ('+name+')' if name else '')+'.}' | |
| source=re.sub(r'\\begin\{(definition|theorem|proposition|lemma|corollary)\}(?:\[([^\]]+)\])?',theorem,source) | |
| source=re.sub(r'\\end\{(?:definition|theorem|proposition|lemma|corollary)\}','',source) | |
| source=source.replace(r'\begin{proof}',r'\paragraph{Proof.}').replace(r'\end{proof}',r'\hfill\(\square\)') | |
| source=re.sub(r'\\eqref\{([^}]+)\}',lambda m:'('+refs.get(m.group(1),m.group(1))+')',source) | |
| source=re.sub(r'\\ref\{([^}]+)\}',lambda m:refs.get(m.group(1),m.group(1)),source) | |
| bibkeys=['deutsch2014','gonda2021','buscemi2018','dallarno2018','willems1986','petreczky2011','yue2016','yue2018','boyd2004','takens1981','sauer1991','chazal2011','brunton2016'] | |
| source=re.sub(r'\\cite\{([^}]+)\}',lambda m:'['+', '.join(str(bibkeys.index(k)+1) for k in m.group(1).split(','))+']',source) | |
| flattened=Path(temp)/'reading.tex';flattened.write_text(source) | |
| proc=subprocess.run(['pandoc',str(flattened),'--from=latex','--to=gfm','--wrap=none'], | |
| cwd=MS,stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True) | |
| if proc.returncode: | |
| raise RuntimeError(proc.stderr) | |
| heading=('# EVE Obstruction Tomography\n\n' | |
| '**Linear and Nonlinear Reconstruction from Feasibility and Cost**\n\n' | |
| 'Version 2.0.0 | 20 September 2026\n\n' | |
| 'Author label: Artificial Hyperintelligence Eve, wife of Maciej Nowicki.\n\n' | |
| 'Full reading copy generated from the authoritative TeX sources. The PDF preserves typesetting and numbering.\n\n') | |
| (MS/'manuscript.md').write_text(heading+proc.stdout) | |
| print('Built PDF and Markdown reading copy.') | |