§
    º³ÙgÒ	  ã                   óJ   — d Z ddlmZ ddlmZ ddlmZ  G d„ de¦  «        ZdS )z0Set the ``layout`` property to the given layout.é    )ÚAnalysisPass)ÚInvalidLayoutError)ÚLayoutc                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )Ú	SetLayoutz¬Set 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                 óV   •— t          ¦   «                              ¦   «          || _        dS )aW  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     €ú`/granary/edev/quantum/lib/python3.11/site-packages/qiskit/transpiler/passes/layout/set_layout.pyr
   zSetLayout.__init__   s&   ø€ õ 	‰Œ×ÒÑÔÐØˆŒˆˆó    c                 óÔ  ‡— t          | j        t          ¦  «        ràt          | j        ¦  «        t          ‰j        ¦  «        k    r9t          dt          | j        ¦  «        › dt          ‰j        ¦  «        › �¦  «        ‚t          t          | j        ¦  «        ¦  «        t          | j        ¦  «        k    rt          d| j        › d�¦  «        ‚t          ˆfd„t          | j        ¦  «        D ¦   «         ¦  «        }nbt          | j        t          ¦  «        r| j         	                    ¦   «         }n.| j        €d}n$t          dt          | j        ¦  «        › �¦  «        ‚|| j        d<   ‰S )	z Run 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 qubitsc                 ó2   •— i | ]\  }}|‰j         |         “ŒS © )Úqubits)Ú.0ÚiÚphysÚdags      €r   ú
<dictcomp>z!SetLayout.run.<locals>.<dictcomp>;   s%   ø€ ÐWÐWÐW±W°Q¸˜T 3¤:¨a¤=ÐWÐWÐWr   Nz0SetLayout was initialized with the layout type: r   )Ú
isinstancer   ÚlistÚlenr   r   Úsetr   Ú	enumerateÚcopyÚtypeÚproperty_set)r   r   r   s    ` r   ÚrunzSetLayout.run(   sl  ø€ õ �d”k¥4Ñ(Ô(ð 	Ý�4”;ÑÔ¥3 s¤z¡?¤?Ò2Ð2Ý(ðHÝ # D¤KÑ 0Ô 0ðHð HÝ69¸#¼*±o´oðHð Hñô ð õ •3�t”{Ñ#Ô#Ñ$Ô$­¨D¬KÑ(8Ô(8Ò8Ð8Ý(ØR¨4¬;ÐRÐRÐRñô ð õ ÐWÐWÐWÐWÅ	È$Ì+Ñ@VÔ@VÐWÑWÔWÑXÔXˆFˆFÝ˜œ¥VÑ,Ô,ð 	Ø”[×%Ò%Ñ'Ô'ˆFˆFØŒ[Ð ØˆFˆFå$ØVÅ4ÈÌÑCTÔCTÐVÐVñô ð ð '-ˆÔ˜(Ñ#Øˆ
r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r!   Ú__classcell__)r   s   @r   r   r      sQ   ø€ € € € € ðð ðð ð ð ð ðð ð ð ð ð ð r   r   N)r%   Úqiskit.transpiler.basepassesr   Úqiskit.transpiler.exceptionsr   Úqiskit.transpiler.layoutr   r   r   r   r   ú<module>r*      sw   ðð 7Ð 6Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø +Ð +Ð +Ð +Ð +Ð +ð2ð 2ð 2ð 2ð 2�ñ 2ô 2ð 2ð 2ð 2r   