Download examples/load_jsonl.py from PureOne/Avenyra-Geometric-Memory-Physics: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/datasets/PureOne/Avenyra-Geometric-Memory-Physics/resolve/main/examples/load_jsonl.py
- Command line
-
hf download hf://datasets/PureOne/Avenyra-Geometric-Memory-Physics/examples/load_jsonl.py
-
curl -L -o load_jsonl.py https://huggingface.co/datasets/PureOne/Avenyra-Geometric-Memory-Physics/resolve/main/examples/load_jsonl.py
1.46 kB
| #!/usr/bin/env python3 | |
| """Inspect local data without installing a Hub client or executing remote code.""" | |
| import argparse | |
| from fractions import Fraction | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def main(): | |
| schema = json.loads((ROOT / "DATA_SCHEMA.json").read_text(encoding="utf-8")) | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--config", default="claims", choices=list(schema["configurations"])) | |
| parser.add_argument("--show", type=int, default=1) | |
| args = parser.parse_args() | |
| rows = [json.loads(line) for line in (ROOT / schema["configurations"][args.config]["path"]).read_text(encoding="utf-8").splitlines()] | |
| print(f"{args.config}: {len(rows)} rows; organizational split=test") | |
| for row in rows[:max(0, args.show)]: | |
| print(json.dumps(row, indent=2, ensure_ascii=False)) | |
| if args.config == "tomography_exact": | |
| comparisons = 0 | |
| for row in rows: | |
| for z, expected in zip(row["probe_z"], row["probe_response_exact"]): | |
| z = Fraction(z) | |
| actual = sum((Fraction(r)*Fraction(t)/(z+Fraction(t)) for r,t in zip(row["r"], row["t"])), Fraction(0)) | |
| if actual != Fraction(expected): | |
| raise ValueError(f"Response mismatch in {row['record_id']}") | |
| comparisons += 1 | |
| print(f"Exact spectral-response comparisons passed: {comparisons}") | |
| if __name__ == "__main__": | |
| main() | |