
    z	i{                        S r SSKJr  SSKrSSKJrJr  SSKJr  SSK	J
r
  \R                  (       a  SSKJr  SSKJr   " S	 S
\\5      rg)z5Container to encapsulate all control flow operations.    )annotationsN)ABCabstractmethod)Instruction)CircuitError)QuantumCircuit)exprc                  r   ^  \ rS rSrSrU 4S jr\\S	S j5       5       r\S
S j5       r	SS jr
SS jrSrU =r$ )ControlFlowOp   zAbstract class to encapsulate all control flow operations.

All subclasses of :class:`ControlFlowOp` have an internal attribute,
:attr:`~ControlFlowOp.blocks`, which exposes the inner subcircuits used in the different blocks
of the control flow.
c                   > [         TU ]  " U0 UD6  U R                   H  nUR                  (       d  M  [	        S5      e   g )Nz2control-flow blocks cannot contain input variables)super__init__blocksnum_input_varsr   )selfargskwargsblock	__class__s       a/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/controlflow/control_flow.pyr   ControlFlowOp.__init__$   s;    $)&)[[E###"#WXX !    c                    g)zsTuple of :class:`.QuantumCircuit`\ s which may be executed as part of the
execution of this :class:`ControlFlowOp`.N )r   s    r   r   ControlFlowOp.blocks*       r   c                    g)a  Return a new version of this control-flow operations with the :attr:`blocks` mapped to
the given new ones.

Typically this is used in a workflow such as::

    existing_op = ...

    def map_block(block: QuantumCircuit) -> QuantumCircuit:
        new_block = block.copy_empty_like()
        # ... do something to `new_block` ...
        return new_block

    new_op = existing_op.replace_blocks(
        map_block(block) for block in existing_op.blocks
    )

It is the caller's responsibility to ensure that the mapped blocks are defined over a
unified set of circuit resources, much like constructing a :class:`ControlFlowOp` using its
default constructor.

Args:
    blocks: the new subcircuit blocks to use.

Returns:
    New :class:`ControlFlowOp` with replaced blocks.
Nr   )r   r   s     r   replace_blocksControlFlowOp.replace_blocks0   r   r   c              #     #    [        5       nU R                   H6  nUR                  5        H  nX1;  d  M
  UR                  U5        Uv   M!     M8     g7f)zSGet an iterator over the unique captured variables in all blocks of this construct.N)setr   iter_captured_varsadd)r   seenr   vars       r   r#    ControlFlowOp.iter_captured_varsM   sB     u[[E//1?HHSMI 2 !
   0AAc              #     #    [        5       nU R                   H6  nUR                  5        H  nX1;  d  M
  UR                  U5        Uv   M!     M8     g7f)z[Get an iterator over the unique captured stretch variables in all blocks of this
construct.N)r"   r   iter_captured_stretchesr$   )r   r%   r   stretchs       r   r*   %ControlFlowOp.iter_captured_stretchesV   sF      u[[E 88:&HHW%!M ; !r(   r   )returnztuple[QuantumCircuit, ...])r   ztyping.Iterable[QuantumCircuit]r-   r   )r-   ztyping.Iterable[expr.Var])r-   ztyping.Iterable[expr.Stretch])__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   r#   r*   __static_attributes____classcell__)r   s   @r   r   r      sM    Y 5  5  8" "r   r   )r2   
__future__r   typingabcr   r   qiskit.circuit.instructionr   qiskit.circuit.exceptionsr   TYPE_CHECKINGqiskit.circuitr   qiskit.circuit.classicalr	   r   r   r   r   <module>r>      s8    8 "  # 2 2	--B"K B"r   