Skip to content

Commit 2b1c961

Browse files
docs(topology): add runnable invocation examples (#1251)
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
1 parent 4c68e48 commit 2b1c961

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/jacobian/domains/topology/operations.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,21 @@ def _integral_homology(
505505
"facets": [["a", "b"], ["b", "c"], ["a", "c"]],
506506
}
507507

508+
_CANONICAL_CIRCLE = {
509+
"vertices": ["a", "b", "c"],
510+
"maximal_simplices": [["a", "b"], ["a", "c"], ["b", "c"]],
511+
"faces_by_dimension": [
512+
{"dimension": 0, "faces": [["a"], ["b"], ["c"]]},
513+
{"dimension": 1, "faces": [["a", "b"], ["a", "c"], ["b", "c"]]},
514+
],
515+
"dimension": 1,
516+
"f_vector": [3, 3],
517+
"closure_size": 6,
518+
"complex_digest": (
519+
"sha256:6f797991bac967e2a8e572707df487061655df0f094cbde0f52f82c5401fc043"
520+
),
521+
}
522+
508523
type TopologyOperation = (
509524
InstalledOperation[
510525
SimplicialComplexRequest, SimplicialComplexCanonicalizationResult
@@ -566,6 +581,17 @@ def _integral_homology(
566581
"boundary-matrix",
567582
"exact",
568583
),
584+
invocation_examples=(
585+
example(
586+
"circle_integer_chain_complex",
587+
"Construct the oriented integer boundary matrices of a circle.",
588+
{
589+
"complex": _CANONICAL_CIRCLE,
590+
"coefficient_ring": "INTEGER",
591+
"convention": "UNREDUCED",
592+
},
593+
),
594+
),
569595
version="4",
570596
)
571597
),
@@ -588,6 +614,17 @@ def _integral_homology(
588614
"prime-field",
589615
"exact",
590616
),
617+
invocation_examples=(
618+
example(
619+
"circle_homology_mod_two",
620+
"Compute H_0 and H_1 over F_2 for a triangle boundary.",
621+
{
622+
"complex": _CANONICAL_CIRCLE,
623+
"prime": 2,
624+
"convention": "UNREDUCED",
625+
},
626+
),
627+
),
591628
version="4",
592629
)
593630
),

tests/domain/topology/test_topology_capabilities.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ def topology_services(tmp_path: Path) -> Iterator[DomainTestServices]:
2222
yield services
2323

2424

25+
def test_every_topology_operation_advertises_an_executable_example(
26+
topology_services: DomainTestServices,
27+
) -> None:
28+
bundle = build_topology_bundle()
29+
30+
for operation in bundle.capabilities:
31+
spec = operation.spec
32+
assert spec.invocation_examples, spec.operation_id
33+
example = spec.invocation_examples[0]
34+
result = topology_services.core.capabilities.invoke(
35+
CapabilityRequest(
36+
capability_id=spec.operation_id,
37+
input=example.input,
38+
)
39+
)
40+
41+
assert result.execution.status is ExecutionStatus.COMPLETED, (
42+
spec.operation_id,
43+
result.diagnostics,
44+
)
45+
46+
2547
_CIRCLE = {
2648
"vertices": ["a", "b", "c"],
2749
"facets": [["a", "b"], ["b", "c"], ["a", "c"]],

0 commit comments

Comments
 (0)