Download data/build_audit_counts.py from PureOne/The-Simplest-Mind-Algorithm-of-All-V: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/datasets/PureOne/The-Simplest-Mind-Algorithm-of-All-V/resolve/main/data/build_audit_counts.py
- Command line
-
hf download hf://datasets/PureOne/The-Simplest-Mind-Algorithm-of-All-V/data/build_audit_counts.py
-
curl -L -o build_audit_counts.py https://huggingface.co/datasets/PureOne/The-Simplest-Mind-Algorithm-of-All-V/resolve/main/data/build_audit_counts.py
1.46 kB
| """Export the Manuscript V pooled audit counts as a flat CSV.""" | |
| import csv | |
| import json | |
| from pathlib import Path | |
| DATA_DIR = Path(__file__).resolve().parent | |
| SOURCE = DATA_DIR.parent / "reproducibility" / "residual_counts.json" | |
| OUTPUT = DATA_DIR / "audit_counts.csv" | |
| FIELDS = ( | |
| "case", "batch", "pair_index", "action_index", "feature_index", | |
| "attempts", "registered_heralds", "retained_heralds", | |
| ) | |
| def audit_rows(payload): | |
| if payload["schema"] != "residual-audit-counts-v1": | |
| raise ValueError(f"Unsupported count schema: {payload['schema']}") | |
| for case in payload["cases"]: | |
| pairs = case["compiled_design"]["pairs"] | |
| for batch_number, batch in enumerate(case["audit_batches"], start=1): | |
| for pair_index, (design, counts) in enumerate(zip(pairs, batch["pairs"], strict=True)): | |
| yield ( | |
| case["case"], batch_number, pair_index, design["action"], design["feature"], | |
| counts["attempts"], counts["registered_heralds"], counts["retained_heralds"], | |
| ) | |
| def main(): | |
| payload = json.loads(SOURCE.read_text(encoding="utf-8")) | |
| rows = list(audit_rows(payload)) | |
| with OUTPUT.open("w", encoding="utf-8", newline="") as stream: | |
| writer = csv.writer(stream, lineterminator="\n") | |
| writer.writerow(FIELDS) | |
| writer.writerows(rows) | |
| print(f"Wrote {len(rows):,} rows to {OUTPUT.name}") | |
| if __name__ == "__main__": | |
| main() | |