tqecd.utils.iter_stim_circuit_by_moments#

iter_stim_circuit_by_moments(circuit: Circuit) Iterator[Circuit | CircuitRepeatBlock][source]#

Iterate over the stim.Circuit by moments.

A moment in a stim.Circuit is a sequence of instructions between two TICK instructions. Note that we always consider a stim.CircuitRepeatBlock as a single moment.

Parameters:

circuit – The circuit to iterate over.

Yields:

A stim.Circuit or a stim.CircuitRepeatBlock instance.

Invariants:
  • All the instructions of the provided circuit (even TICK ones) are eventually yielded by the generator returned by this function.

  • In the yield items, TICK instructions can only appear at the end of a stim.Circuit or within the body of a stim.CircuitRepeatBlock.