
    z	i	                     B    S r SSKJr  SSKJr  SSKJr   " S S\5      rg)z0Set the ``layout`` property to the given layout.    )AnalysisPass)InvalidLayoutError)Layoutc                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )	SetLayout   zSet the ``layout`` property to the given layout.

This pass associates a physical qubit (int) to each virtual qubit
of the circuit (Qubit) in increasing order.
c                 .   > [         TU ]  5         Xl        g)a'  SetLayout initializer.

Args:
    layout (Layout or List[int]): the layout to set. It can be:

        * a :class:`Layout` instance: sets that layout.
        * a list of integers: takes the index in the list as the physical position in which the
          virtual qubit is going to be mapped.

N)super__init__layout)selfr   	__class__s     d/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/layout/set_layout.pyr   SetLayout.__init__   s     	    c           	      &   [        U R                  [        5      (       a  [        U R                  5      [        UR                  5      :w  a7  [        S[        U R                  5       S[        UR                  5       35      e[        [        U R                  5      5      [        U R                  5      :w  a  [        SU R                   S35      e[        [        U R                  5       VVs0 s H  u  p#X1R                  U   _M     snn5      nOk[        U R                  [        5      (       a  U R                  R                  5       nO1U R                  c  SnO![        S[        U R                  5       35      eX@R                  S'   U$ s  snnf )zxRun the SetLayout pass on ``dag``.

Args:
    dag (DAGCircuit): DAG to map.

Returns:
    DAGCircuit: the original DAG.
zDThe length of the layout is different than the size of the circuit: z <> zThe provided layout z contains duplicate qubitsNz0SetLayout was initialized with the layout type: r   )
isinstancer   listlenqubitsr   setr   	enumeratecopytypeproperty_set)r   dagiphysr   s        r   runSetLayout.run(   sD    dkk4((4;;3szz?2(  #DKK 01c#**o5FH  3t{{#$DKK(88(*4;;-7QR  	$++@VW@VWQT::a=0@VWXFV,,[[%%'F[[ F$B4CTBUV  '-(#
 Xs   .F
)r   )	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__)r   s   @r   r   r      s     r   r   N)r%   qiskit.transpiler.basepassesr   qiskit.transpiler.exceptionsr   qiskit.transpiler.layoutr   r    r   r   <module>r,      s    7 5 ; +2 2r   