
    z	i.                     F    S r SSKJr  SSKJrJr  SSKJr   " S S\5      rg)z;Check if a DAG circuit is already mapped to a coupling map.    )AnalysisPass)Target_FakeTarget)	check_mapc                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )CheckMap   aS  Check if a DAG circuit is already mapped to a coupling map.

Check if a DAGCircuit is mapped to ``coupling_map`` by checking that all
2-qubit interactions are laid out to be on adjacent qubits in the global coupling
map of the device, setting the property set field (either specified with ``property_set_field``
or the default ``is_swap_mapped``) to ``True`` or ``False`` accordingly. Note this does not
validate directionality of the connectivity between  qubits. If you need to check gates are
implemented in a native direction for a target use the :class:`~.CheckGateDirection` pass
instead.
c                 B  > [         TU ]  5         Uc  SU l        OX l        [        U[        5      (       aG  [        U[
        5      (       a+  [        R                  " SS/UR                  5       S9U l        O#Xl        O[        R                  " SS/US9U l        SU l	        g)aR  CheckMap initializer.

Args:
    coupling_map (Union[CouplingMap, Target]): Directed graph representing a coupling map.
    property_set_field (str): An optional string to specify the property set field to
        store the result of the check. If not provided the result is stored in
        the property set field ``"is_swap_mapped"``.
Nis_swap_mappeducx)coupling_map)
super__init__property_set_field
isinstancer   r   from_configurationbuild_coupling_map_target_qargs)selfr   r   	__class__s      b/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/utils/check_map.pyr   CheckMap.__init__    s     	%&6D#&8#lF++,44%88$Kl.M.M.O   ,!44c4[|\DL    c                    U R                   R                  b+  [        S U R                   R                   5       5      (       d  SU R                  U R                  '   g[
        R
                  " XR                   5      nUc  SU R                  U R                  '   gSU R                  U R                  '   US    SUR                  US   S       SUR                  US   S       S	3U R                  S
'   g)zRun the CheckMap pass on `dag`.

If ``dag`` is mapped to the configured :class:`.Target`, the property whose name is
specified in ``self.property_set_field`` is set to ``True`` (or to ``False`` otherwise).

Args:
    dag (DAGCircuit): DAG to map.
Nc              3   F   #    U  H  oc  M  [        U5      S:H  v   M     g 7f)N   )len).0xs     r   	<genexpr>CheckMap.run.<locals>.<genexpr>B   s      1
!3AKCFaK!3s   !!TFr   (   z, z) failedcheck_map_msg)r   qargsanyproperty_setr   r   qubits)r   dagress      r   runCheckMap.run9   s     <<%S 1
!%!3!31
 .
 .
 :>Dd556!!#||4;9=Dd5565:$1121vha

3q6!9-.bCF1I1F0GxP 	/*r   )r   r   r   )N)	__name__
__module____qualname____firstlineno____doc__r   r-   __static_attributes____classcell__)r   s   @r   r   r      s    	2
 
r   r   N)	r3   qiskit.transpiler.basepassesr   qiskit.transpiler.targetr   r   qiskit._accelerater   r    r   r   <module>r:      s     B 5 8 (:
| :
r   