"""Local smoke check for the demo core. Runs every sample through run_demo and prints the measured metrics. Run with POLYGEN_DEMO_LOCAL_MOCK=1. POLYGEN_DEMO_LOCAL_MOCK=1 python verify_local.py """ import os os.environ.setdefault("POLYGEN_DEMO_LOCAL_MOCK", "1") import license_bootstrap license_bootstrap.ensure_license() import demo_core # noqa: E402 (must follow ensure_license) def main() -> None: for name, fn in demo_core.SAMPLES.items(): r = demo_core.run_demo(fn(), degree=5, segment_length=200) print(f"\n## {name}") print(f" shape={r['n']}x{r['d']} segments={r['segments']}") print( f" raw={r['raw_size'] / 1024:.1f}KB gzip={r['gzip_size'] / 1024:.1f}KB " f"token={r['token_size'] / 1024:.1f}KB coeff-only={r['coeff_size'] / 1024:.1f}KB", ) print( f" ratio vs raw={r['ratio_vs_raw']:.2f}x vs gzip={r['ratio_vs_gzip']:.2f}x " f"COARSE vs raw={r['coarse_ratio_vs_raw']:.1f}x", ) print( f" max EXACT decode error={r['max_err']:.2e} (lossless to ~{1 / r['scale']:.0e}) " f"sigma_R: min={r['sigma_r'].min():.3f} max={r['sigma_r'].max():.3f}", ) print("\nOK -- demo core ran on all samples.") if __name__ == "__main__": main()