Datasets:
Formats:
csv
Languages:
English
Size:
1K - 10K
Tags:
mathematics
inverse-problems
observability
noncommutative-algebra
symbolic-computation
calibration-rigidity
Download hub_tools/prepare_viewer_data.py from PureOne/AELYRION-NOULITH-III: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/datasets/PureOne/AELYRION-NOULITH-III/resolve/main/hub_tools/prepare_viewer_data.py
- Command line
-
hf download hf://datasets/PureOne/AELYRION-NOULITH-III/hub_tools/prepare_viewer_data.py
-
curl -L -o prepare_viewer_data.py https://huggingface.co/datasets/PureOne/AELYRION-NOULITH-III/resolve/main/hub_tools/prepare_viewer_data.py
2.05 kB
| #!/usr/bin/env python3 | |
| """Regenerate lossless CSV viewer projections and synchronize the data catalog.""" | |
| from __future__ import annotations | |
| import csv,hashlib,json | |
| from pathlib import Path | |
| ROOT=Path(__file__).resolve().parents[1] | |
| def main(): | |
| dest=ROOT/"hub_data";dest.mkdir(exist_ok=True) | |
| for name in ["v3_components_m6","v3_visibility_certificates"]: | |
| records=json.loads((ROOT/"data"/(name+".json")).read_text(encoding="utf-8")) | |
| rows=[] | |
| for r in records: | |
| row={"record_json":json.dumps(r,ensure_ascii=False,separators=(",",":")),"channels":6} | |
| if name=="v3_components_m6": | |
| row.update(component_id=r["type"]+"-"+"-".join(map(str,r["labels_zero_based"])), | |
| kind=r["type"],dimension=r["dimension"], | |
| labels_zero_based_json=json.dumps(r["labels_zero_based"],separators=(",",":")), | |
| equation_count=len(r["linear_equations_ascending_edges"])) | |
| else: | |
| row.update(stratum=r["stratum"],blocks=3,visible=r["visible"], | |
| normalized_response_exact=str(r["normalized_response"]), | |
| motif_json=json.dumps(r["motif"],separators=(",",":"))) | |
| rows.append(row) | |
| p=dest/(name+".csv") | |
| with p.open("w",newline="",encoding="utf-8") as f: | |
| w=csv.DictWriter(f,fieldnames=list(rows[0]));w.writeheader();w.writerows(rows) | |
| print(name,len(rows)) | |
| cp=ROOT/"data_catalog.json" | |
| catalog=json.loads(cp.read_text(encoding="utf-8")) | |
| for item in catalog["configurations"]: | |
| p=ROOT/item["path"] | |
| with p.open(newline="",encoding="utf-8") as f: | |
| r=csv.DictReader(f);rows=list(r) | |
| item.update(columns=r.fieldnames,rows=len(rows),sha256=hashlib.sha256(p.read_bytes()).hexdigest()) | |
| catalog["total_rows"]=sum(x["rows"] for x in catalog["configurations"]) | |
| cp.write_text(json.dumps(catalog,indent=2,ensure_ascii=False)+"\n",encoding="utf-8") | |
| return 0 | |
| if __name__=="__main__":raise SystemExit(main()) | |