File size: 1,766 Bytes
10d1f61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Rebuild the Hugging Face JSONL tables from the original results and fixtures."""
import json
from pathlib import Path

from exact_ranks import NINE, SOLIDS

ROOT = Path(__file__).resolve().parents[1]
DATA = ROOT / "data"


def coordinates():
    clouds = {name: [(point, 0) for point in points]
              for name, (points, _) in SOLIDS.items()}
    clouds["nine_unmarked"] = [(point, 0) for point in NINE]
    axes = [tuple(int(j == i) for j in range(3)) for i in range(3)]
    clouds["six_two_colors"] = ([(point, 1) for point in axes]
                                 + [(tuple(-v for v in point), 0) for point in axes])
    for name, records in clouds.items():
        for i, ((x, y, z), label) in enumerate(records):
            yield dict(cloud=name, point_index=i, x=x, y=y, z=z, node_label=label)


def main():
    DATA.mkdir(exist_ok=True)
    results = json.loads((ROOT / "research" / "results.json").read_text(encoding="utf-8"))
    tables = {
        "regular_shapes": [dict(shape=shape, **row)
                           for shape, rows in results["regular_shapes"].items() for row in rows],
        "nine_point": results["nine_point_exact"],
        "frame_checks": results["frame_checks"],
        "smooth_kernel": results["smooth_kernel_checks"],
        "point_clouds": list(coordinates()),
        "orbit_benchmark": [results["orbit_benchmark"]],
    }
    for name, rows in tables.items():
        with (DATA / f"{name}.jsonl").open("w", encoding="utf-8", newline="\n") as file:
            for row in rows:
                file.write(json.dumps(row, ensure_ascii=False, allow_nan=False,
                                      separators=(",", ":")) + "\n")
        print(f"{name}: {len(rows)} rows")


if __name__ == "__main__":
    main()