save_invariants#
- save_invariants(diagrams, invariant_funcs, path, parallel=True, max_workers=None)#
Compute and save invariants for diagrams.
- Two modes:
parallel=True: treat
path
as a directory and write one file per diagram.parallel=False: treat
path
as a single file and write a combined table.
- Parameters:
diagrams (Iterable[Any]) – Iterable of diagram-like objects.
invariant_funcs (Mapping[str, Callable[[Any], Any]] | Callable[[Any], Any]) –
Mapping
{name: func}
for multi-invariant output.Single callable for single-invariant output.
path (str | Path) – Directory (parallel) or file path (sequential).
parallel (bool) – Use process pool and per-diagram files when True.
max_workers (int | None) – Number of workers; defaults to
os.cpu_count()
.
- Raises:
ValueError – If
parallel
is True andpath
is not a directory.ValueError – If
parallel
is False andpath
already exists as a directory.
- Return type:
None