Skip to content

DependenceGraph

from tensorsig.offset_coded_signatures.quotients import DependenceGraph

Make distinct channels commute unless their pair is an allowed edge.

Channel indices are zero-based. Self-interactions are always retained and therefore need not be listed.

Source code in src/tensorsig/offset_coded_signatures/_lie_quotients/rules.py
def __init__(self, edges: Iterable[Sequence[int]] = ()) -> None:
    normalized: set[tuple[int, int]] = set()
    for edge in edges:
        if len(edge) != 2:
            raise ValueError("DependenceGraph edges must contain two channels.")
        left, right = edge
        if (
            not isinstance(left, int)
            or isinstance(left, bool)
            or not isinstance(right, int)
            or isinstance(right, bool)
        ):
            raise TypeError("DependenceGraph channel indices must be integers.")
        if left < 0 or right < 0:
            raise ValueError(
                "DependenceGraph channel indices must be non-negative."
            )
        if left == right:
            continue
        normalized.add((min(left, right), max(left, right)))
    object.__setattr__(self, "edges", frozenset(normalized))