
    z	i                     >    S r SSKrSSKJr  SSKJr   " S S\5      rg)zQExtend the dag with virtual qubits that are in layout but not in the circuit yet.    N)TransformationPass)TranspilerErrorc                       \ rS rSrSrS rSrg)EnlargeWithAncilla   a+  Extend the dag with virtual qubits that are in layout but not in the circuit yet.

Extend the DAG circuit with new virtual qubits (ancilla) that are specified
in the layout, but not present in the circuit. Which qubits to add are
previously allocated in the ``layout`` property, by a previous pass.
c           
         U R                   S   nU R                   S   nUc  [        S5      eUR                  5        Vs1 s H$  oDUR                  R	                  5       ;  d  M"  UiM&     nnU HT  nUb=  UR                  [        U[        R                  " UR                  5       5      5      5        UR                  U5        MV     X0R                   S'   U$ s  snf )zRun the EnlargeWithAncilla pass on `dag`.

Args:
    dag (DAGCircuit): DAG to extend.

Returns:
    DAGCircuit: An extended DAG.

Raises:
    TranspilerError: If there is no layout in the property set or not set at init time.
layoutoriginal_qubit_indicesz2EnlargeWithAncilla requires property_set["layout"])property_setr   get_registersqregsvaluesupdatezip	itertoolscount
num_qubitsadd_qreg)selfdagr	   qubit_indicesreg	new_qregsqregs          n/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/layout/enlarge_with_ancilla.pyrunEnlargeWithAncilla.run   s     ""8,))*BC>!"VWW$*$8$8$:\$:SIYIYI[>[S$:	\D($$Sys~~?O/P%QRLL 
 7D23
 ]s   !C$C N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r       r   r   r      s    r%   r   )r#   r   qiskit.transpiler.basepassesr   qiskit.transpiler.exceptionsr   r   r   r%   r   <module>r(      s!    X  ; 8"+ "r%   