
    i-              
           S r SSKJrJrJrJrJr  SSKJr  SSK	J
r
   " S S5      r SS\\\      S\S	\\\\4      4S
 jjrS\S	\\\\4      4S jrg)zX
Utility class to represent an embedding of a set of qubits in a two-dimensional plane.
    )IterableListTupleUnionSequence)	BackendV2)CouplingMapc                       \ rS rSrSrS\\\\4      S\\\\\4      \	4   SS4S jr
\S\SS 4S	 j5       r\S\\\\4      4S
 j5       r\S\	4S j5       rSrg)	Embedding   aC  
A class to represent an embedding or arrangement of a set of qubits in a two-dimensional plane.

Args:
    coordinates: A list of coordinates in the form ``(row, column)`` that specify the qubits'
        location on the 2D plane.
    coupling_map: A coupling map specifying how the qubits in the embedding are connected.
coordinatescoupling_mapreturnNc                    ^ [        U5      m[        U4S jU 5       5      (       a  [        S5      eXl        [	        U[
        5      (       a  UU l        g [        U5      U l        g )Nc              3   J   >#    U  H  u  pUT:  =(       d    UT:  v   M     g 7f)N ).0q0q1
num_qubitss      ]/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/utils/embeddings.py	<genexpr>%Embedding.__init__.<locals>.<genexpr>(   s#     O,hrrJ1"z/1,s    #zInvalid coupling map.)lenany
ValueError_coordinates
isinstancer	   _coupling_map)selfr   r   r   s      @r   __init__Embedding.__init__"   sZ    
 %
O,OOO455'&|[AAL 	GRS_G` 	    backendc                     UR                   =n(       d  [        SUR                   S35      e [        UR                  5      nU " X25      $ ! [         a  n[        SUR                   S35      UeSnAff = f)aR  Generates an :class:`~.Embedding` object from a backend.

Args:
    backend: A backend to generate the :class:`~.Embedding` object from.

Returns:
    The embedding for the given backend.

Raises:
    ValueError: If the given backend has coupling map set to ``None``.
    ValueError: If the coordinates for the given backend are unknown.
zCoupling map for backend 'z' is unknown.z)Failed to fetch coordinates for backend 'z'.N)r   r   name_get_qubits_coordinatesr   )clsr$   r   r   errs        r   from_backendEmbedding.from_backend0   s     !( 4 4449',,}UVV	d1'2D2DEK ;--  	dHVXYZ`cc	ds   A 
A4A//A4c                     U R                   $ )z$
The coordinates in this embedding.
)r   r    s    r   r   Embedding.coordinatesG   s    
    r#   c                     U R                   $ )z%
The coupling map in this embedding.
)r   r-   s    r   r   Embedding.coupling_mapN   s    
 !!!r#   )r   r   )__name__
__module____qualname____firstlineno____doc__r   r   intr   r	   r!   classmethodr   r*   propertyr   r   __static_attributes__r   r#   r   r   r      s    
%S/*
 DsCx1;>?
 
	
 .9 . . ., !T%S/2 ! ! "k " "r#   r   rows	row_majorr   c                 z    / nSn[        U 5       H  u  p4U H
  nX#U4/-  nM     M     U(       d  [        US S9nU$ )a  Generate heavy hex coordinates for the given rows.

Args:
    rows: A sequence of rows, sorted from top to bottom. Rows are specified as an iterable of
        integers, where every integer represents a column index.
    row_major: Whether qubits should be labelled in row-major order (by ``x`` first and, in
        case of a tie, by ``y``) or in colum-major order.

Returns:
    A list of qubit coordinates, where list position corresponds with qubit index.
r   c                     U S   U S   4$ )N   r   r   )ps    r   <lambda>#_heavy_hex_coords.<locals>.<lambda>n   s    1qtr#   )key)	enumeratesorted)r:   r;   r   row_idxrowcol_idxs         r   _heavy_hex_coordsrH   V   sR     K G!$Gg.//K  (
 [.DEr#   r   c                    U S:X  a  / SQ$ U S:X  a#  [        S5      S/[        S5      /n[        U5      $ U S:X  a  / SQ$ U S:X  a*  S/[        S5      SS/[        SS	5      S//n[        US
5      $ U S:X  a  [        S5      /S-  n[        U5      $ U S:X  a,  SS/[        S5      / SQ[        SS5      SS//n[        US
5      $ U S:X  a0  [        SS5      SS	/[        S5      / SQ[        S5      /n[        US9$ U S:X  aF  [        S5      / SQ/n[        S5      SS	//n[        SS5      SS	//U-   U-   U-   U-   n[        US5      $ U S:X  aN  [        S5      / SQ/n[        S5      / SQ/U-   [        S5      / SQ/-   U-   [        SS5      /-   n[        US5      $ U S:X  aV  [        S5      / SQ/n[        S5      / SQ/n[        S5      / SQ/U-   U-   U-   U-   U-   [        SS5      /-   n[        US5      $ [        SU  S35      e) a  
Return a list of coordinates for drawing a set of qubits on a two-dimensional plane.

The coordinates are in the form ``(row, column)``.

If the coordinates are unknown, it returns an empty list.

Args:
    num_qubits: The number of qubits to return the coordinates from.

Returns:
    A list of coordinates for drawing a set of qubits on a two-dimensional plane.

Raises:
    ValueError: If the coordinates for a backend with ``num_qubit`` qubits are unknown.
   )r>   r   r   r>   r>   r>   r>      )rO   r>         r>      ))r   r   rL   )r   rO   )r   rQ   )r      )r   rJ   )r      )r>   rP   )r>   rT   )r>   rJ   )r>   rS   )r>   rQ   rN   rM   rK      rT   F   rS      
   )r>   rJ   	         rO   rY   )r   rS      )r:   5   TA   )rO   rT   rX      )rO   rT   rX      )r   rS   r\      r`   zCoordinates for z-qubit CPU are unknown.)rangerH   r   )r   r:   r1r2rs        r   r'   r'   s   sB   " Q77Qa1#uQx( &&R
 	
$ RU1X1vuQ{QC8 u--RazA~ &&RAb	9eArlQFC u--RaaVU1Xy%(C d++RAh	"AhAaaV$r)B.3b8 t,,R2Y
#b	9%)U2Y	,BBQF%PQSU,W t,,SBi(Bi'b	=)B.3b82=BeArl^S t,,
'
|3JK
LLr#   N)T)r5   typingr   r   r   r   r   qiskit.providers.backendr   qiskit.transpilerr	   r   r6   boolrH   r'   r   r#   r   <module>rj      s    : 9 . );" ;"~ 6:
8C=
!.2	%S/:LM LMU38_0E LMr#   