Circuit.straighten

Circuit.straighten(region)[source]

Push gates back so the region has a single starting cycle.

Parameters:

region (CircuitRegionLike) – The region to straighten.

Returns:

Statistics on how gates where moved to straighten this region. The first return value is the straightened region. The second integer return value is the net number of new cycles inserted at region.min_cycle. The last return value is the shadow region, or the portion of the middle region which did not move. See the Notes for more info.

Return type:

(tuple[CircuitRegion, int, CircuitRegion])

Raises:

ValueError – If the region is invalid, see circuit.check_region.

Notes

When isolating a region, the circuit is divided into three parts by region.min_cycle and region.max_min_cycle. The left region is left unchanged and the right region potentially moves to the right. Gates in the middle can either be moved to the right or left unchanged depending on their location. The last return value describes the cycle-qudits that did not move from the middle portion.