samplomatic.utils

Utility functions.

Functions

deprecate_arg(name, *, since[, ...])

Return a decorator to indicate an argument has been deprecated in some way.

extend_annotations(circuit, *annotations)

Return a new circuit with the given annotations appended to every box.

filter_annotations(circuit, keep)

Return a new circuit keeping only annotations of the given type(s) on each box.

find_unique_box_instructions(instructions[, ...])

Return instructions that contains unique boxes.

get_annotation(box, annotation_type)

Return a box's first annotation of the given type(s).

map_annotations(circuit, fn)

Return a new circuit where each box's annotations are replaced by fn(annotations).

replace_annotations(circuit, fn)

Return a new circuit with annotations replaced according to a callable.

strip_annotations(circuit)

Return a new circuit with all annotations removed from every box.

unbox(circuit)

Return a circuit with all box operations inlined.

undress_box(box)

Return a box equivalent to box, stripped of the single-qubit gates on the dressing side.

validate_literals(*arg_names)

Return a decorator to validate function arguments against literal type annotations.

Classes

BoxKey(instruction)

An immutable snapshot of an instruction that owns a box, suitable for comparison and hashing.

FrozenDict(*args, **kwargs)

An immutable and hashable dictionary-like mapping.