Skip to main content
IBM Quantum Platform

count_unique_box_instructions

samplomatic.utils.count_unique_box_instructions(instructions: Iterable[CircuitInstruction], undress_boxes: bool = True, normalize_annotations: Callable[[Iterable[Annotation]], list[Annotation]] | None = None) → list[tuple[CircuitInstruction, int]]

GitHub

Return unique box instructions and their number of occurrences.

This function iterates through the given instructions, identifying those that contain a BoxOp operation and comparing them based on their content and annotations. It returns a list of pairs of instructions that contains unique boxes and their counts. Optionally, it allows undressing the boxes before comparison, as well as normalizing their annotations to ignore irrelevant fields.

Parameters

  • instructions – The instructions to iterate through.
  • undress_boxes – Whether to call the undress_box() method on each box before comparison.
  • normalize_annotations – A callable mapping annotations to annotations, which is applied to the annotations of each box before comparison. If None, it discards every annotation that is not of type Twirl and InjectNoise, and it resets the modifier_ref field of InjectNoise annotations to the default value.

Returns

A list of tuples of unique instructions and their counts.

Was this page helpful?
Report a bug, typo, or request content on GitHub.