CircuitIterator
- class CircuitIterator(circuit, start=(0, 0), end=None, qudits_or_region=None, exclude=False, reverse=False, and_cycles=False)[source]
Bases:
Iterator[Operation|tuple[int,Operation]]A CircuitIterator iterates through a circuit in a simulation order.
- __init__(circuit, start=(0, 0), end=None, qudits_or_region=None, exclude=False, reverse=False, and_cycles=False)[source]
Construct a CircuitIterator.
- Parameters:
circuit (
Circuit) – The circuit to iterate through.start (
tuple[int,int] |CircuitPoint) – Only iterate through points greater than or equal to start. Defaults to start at the beginning of the circuit. (Default: (0, 0))end (
tuple[int,int] |CircuitPoint|None) – Only iterate through points less than or equal to this. If left as None, iterates until the end of the circuit. (Default: None)qudits_or_region (
Mapping[int,tuple[int,int] |CycleInterval] |CircuitRegion|Sequence[int] |None) – Determines the way the circuit is iterated. If a region is given, then iterate through operations in the region. If a sequence of qudit indices is given, then only iterate the operations touching those qudits. If left as None, then iterate through the entire circuit in simulation order. (Default: None)exclude (
bool) – If iterating through a region or only some qudits and exclude is true, then do not yield operations that are only partially in the region or on the desired qudits. This may result in a sequence of operations that does not occur in simulation order in the circuit. (Default: False)reverse (
bool) – Reverse the ordering. If true, then end acts as start and vice versa. (Default: False)and_cycles (
bool) – If true, in addition to the operation, return the cycle index where it was found. (Default: False)
Methods