Retire routing archives and consolidate documentation tooling
Generate the guide, walkthrough, and gallery figures from one command. Keep benchmark fixtures and attribution with the tests and fold the durable findings from completed plans into the guides.
This commit is contained in:
parent
5c4d32cc3e
commit
a05980e8af
1 changed files with 374 additions and 17204 deletions
|
|
@ -23,6 +23,8 @@ from matplotlib import pyplot as plt # noqa: E402
|
|||
from matplotlib.lines import Line2D # noqa: E402
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterable
|
||||
|
||||
from matplotlib.axes import Axes
|
||||
|
||||
from inire import RoutingRunResult
|
||||
|
|
@ -108,6 +110,24 @@ def _plot_case(problem: RoutingProblem, options: RoutingOptions, run: RoutingRun
|
|||
plt.close(fig)
|
||||
|
||||
|
||||
def render_layouts(layouts: dict, output_dir: Path, *, cases: Iterable[str] | None = None) -> int:
|
||||
"""Render selected gallery layouts and report whether all routes verified."""
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
all_verified = True
|
||||
for name in dict.fromkeys(cases or layouts):
|
||||
problem, options = build_problem(layouts[name])
|
||||
run = route(problem, options=options)
|
||||
valid = sum(result.is_valid for result in run.results_by_net.values())
|
||||
print(f"{name}: {valid}/{len(problem.nets)} verified")
|
||||
if valid != len(problem.nets):
|
||||
all_verified = False
|
||||
print(" " + ", ".join(f"{res.net_id}: {res.outcome}" for res in run.results_by_net.values() if not res.is_valid))
|
||||
_plot_case(problem, options, run, output_dir / f"example-{name}.png")
|
||||
|
||||
return 0 if all_verified else 1
|
||||
|
||||
|
||||
def main() -> int:
|
||||
layouts = loads(INPUTS.read_text(encoding="utf-8"))
|
||||
parser = ArgumentParser(description=__doc__)
|
||||
|
|
@ -117,20 +137,7 @@ def main() -> int:
|
|||
)
|
||||
parser.add_argument("--output-dir", type=Path, default=INPUTS.parent, help="Directory for the setup and result PNGs.")
|
||||
args = parser.parse_args()
|
||||
args.output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
all_verified = True
|
||||
for name in dict.fromkeys(args.case or layouts):
|
||||
problem, options = build_problem(layouts[name])
|
||||
run = route(problem, options=options)
|
||||
valid = sum(result.is_valid for result in run.results_by_net.values())
|
||||
print(f"{name}: {valid}/{len(problem.nets)} verified")
|
||||
if valid != len(problem.nets):
|
||||
all_verified = False
|
||||
print(" " + ", ".join(f"{res.net_id}: {res.outcome}" for res in run.results_by_net.values() if not res.is_valid))
|
||||
_plot_case(problem, options, run, args.output_dir / f"example-{name}.png")
|
||||
|
||||
return 0 if all_verified else 1
|
||||
return render_layouts(layouts, args.output_dir, cases=args.case)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Reference in a new issue