-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_tilings.py
More file actions
71 lines (58 loc) · 2.06 KB
/
Copy pathvalidate_tilings.py
File metadata and controls
71 lines (58 loc) · 2.06 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from __future__ import annotations
import sys
from collections.abc import Iterator
from pathlib import Path
from typing import TypedDict
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from backend.simulation.topology import build_topology
from backend.simulation.topology_catalog import (
TOPOLOGY_VARIANTS,
is_aperiodic_geometry,
)
from backend.simulation.topology_validation import (
TopologyValidationResult,
recommended_validation_options,
validate_topology,
)
class ValidationParameters(TypedDict):
width: int
height: int
patch_depth: int | None
def iter_validation_targets() -> Iterator[tuple[str, ValidationParameters]]:
for definition in TOPOLOGY_VARIANTS:
if definition.family == "mixed":
yield definition.geometry_key, {"width": 3, "height": 3, "patch_depth": None}
elif is_aperiodic_geometry(definition.geometry_key):
yield definition.geometry_key, {"width": 0, "height": 0, "patch_depth": 3}
def validate_manifest_tilings() -> tuple[tuple[str, TopologyValidationResult], ...]:
results = []
for geometry, parameters in iter_validation_targets():
topology = build_topology(
geometry,
parameters["width"],
parameters["height"],
parameters["patch_depth"],
)
results.append(
(
geometry,
validate_topology(topology, **recommended_validation_options(geometry)),
)
)
return tuple(results)
def main() -> int:
results = validate_manifest_tilings()
all_valid = True
for geometry, result in results:
if result.is_valid:
print(f"PASS {geometry} ({result.checked_cell_count} cells)")
continue
all_valid = False
for line in result.summary_lines():
print(line)
print("INFO full-catalog literature verification: py -3 tools/verify_reference_tilings.py")
return 0 if all_valid else 1
if __name__ == "__main__":
raise SystemExit(main())