find_unique_box_instructions

samplomatic.utils.find_unique_box_instructions(instructions: Iterable[CircuitInstruction], undress_boxes: bool = True, normalize_annotations: Callable[[Iterable[Annotation]], list[Annotation]] | None = None) list[CircuitInstruction][source]

Return instructions that contains unique boxes.

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 instructions that contains unique boxes. 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 unique instructions.