
    {	iM                         S r SSKrSSKrSSKrSSKJrJrJrJrJ	r	  SSK
rSSKJr  SSKJr  \\\R                  4   r " S S5      r " S S	5      r " S
 S5      rS\4S jrg)z
Aer backend properties
    N)AnyIterableTupleUnionDict)apply_prefix)Targetc                   @    \ rS rSrSrS r\S 5       rS rS r	S r
Srg	)
Nduv   zwClass representing name-date-unit-value

Attributes:
    date: date.
    name: name.
    unit: unit.
    value: value.
c                 4    Xl         X l        X0l        X@l        g)zInitialize a new name-date-unit-value object

Args:
    date (datetime.datetime): Date field
    name (str): Name field
    unit (str): Nduv unit
    value (float): The value of the Nduv
Ndatenameunitvalue)selfr   r   r   r   s        _/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_aer/backends/backendproperties.py__init__Nduv.__init__%   s     			
    c                     U " S0 UD6$ )a  Create a new Nduv object from a dictionary.

Args:
    data (dict): A dictionary representing the Nduv to create.
                 It will be in the same format as output by
                 :func:`to_dict`.

Returns:
    Nduv: The Nduv from the input dictionary.
 r   )clsdatas     r   	from_dictNduv.from_dict3   s     {T{r   c                 d    U R                   U R                  U R                  U R                  S.nU$ )znReturn a dictionary format representation of the object.

Returns:
    dict: The dictionary form of the Nduv.
r   r   )r   out_dicts     r   to_dictNduv.to_dictA   s.     IIIIIIZZ	
 r   c                 t    [        U[        5      (       a#  U R                  5       UR                  5       :X  a  ggNTF)
isinstancer   r    r   others     r   __eq__Nduv.__eq__O   s)    eT""||~0r   c           	          S[        U R                  5       SU R                   SU R                   SU R                   S3	$ )NzNduv(z, ))reprr   r   r   r   )r   s    r   __repr__Nduv.__repr__U   s8    tDII'r$))BtyykDJJ<qQQr   r   N)__name__
__module____qualname____firstlineno____doc__r   classmethodr   r    r'   r,   __static_attributes__r   r   r   r   r      s0      Rr   r   c                   D    \ rS rSrSr0 rS rS r\S 5       r	S r
S rSrg	)
GatePropertiesY   ztClass representing a gate's properties

Attributes:
    qubits: qubits.
    gate: gate.
    parameters: parameters.
c                 l    0 U l         Xl        X l        X0l        U R                   R	                  U5        g)a  Initialize a new :class:`GateProperties` object

Args:
    qubits (list): A list of integers representing qubits
    gate (str): The gates name
    parameters (list): List of :class:`Nduv` objects for the
        name-date-unit-value for the gate
    kwargs: Optional additional fields
N)_dataqubitsgate
parametersupdate)r   r:   r;   r<   kwargss        r   r   GateProperties.__init__d   s,     
	$

&!r   c                 f     U R                   U   $ ! [         a  n[        SU S35      UeS nAff = fNz
Attribute z is not definedr9   KeyErrorAttributeErrorr   r   exs      r   __getattr__GateProperties.__getattr__t   ?    	M::d## 	M :dV?!CD"L	M    
0+0c                     0 nUR                  5        H6  u  p4US:X  a'  [        [        [        R                  U5      5      X#'   M2  XBU'   M8     U " S0 UD6$ )a  Create a new Gate object from a dictionary.

Args:
    data (dict): A dictionary representing the Gate to create.
                 It will be in the same format as output by
                 :func:`to_dict`.

Returns:
    GateProperties: The Nduv from the input dictionary.
r<   r   )itemslistmapr   r   )r   r   in_datakeyr   s        r   r   GateProperties.from_dictz   sO     **,JCl"#C$>?$	 '
 ~W~r   c                     0 nU R                   US'   U R                  US'   U R                   Vs/ s H  o"R                  5       PM     snUS'   UR	                  U R
                  5        U$ s  snf )zuReturn a dictionary format representation of the BackendStatus.

Returns:
    dict: The dictionary form of the Gate.
r:   r;   r<   )r:   r;   r<   r    r=   r9   )r   r   xs      r   r    GateProperties.to_dict   sa     ![[997;!G!))+!G

# "Hs   A+c                 t    [        U[        5      (       a#  U R                  5       UR                  5       :X  a  ggr#   )r$   r6   r    r%   s     r   r'   GateProperties.__eq__   s)    e^,,||~0r   )r9   r;   r<   r:   N)r.   r/   r0   r1   r2   r9   r   rG   r3   r   r    r'   r4   r   r   r   r6   r6   Y   s7     E" M  &r   r6   c                      \ rS rSrSr0 rS rS r\S 5       r	S r
S r  S S	\S
\\\\   4   S\S\\\\S4   \\\4   4   \\\4   \4   4S jjrS rS rS!S	\S
\\\\   4   S\4S jjrS	\S
\\\\   4   S\4S jrS	\S
\\\\   4   S\4S jr S!S\S\S\\\\4   \4   4S jjrS\S\4S jrS\S\4S jrS\S\4S jrS\S\4S jrS\S\4S jr S\S\4S jr!S\S\S\4S jr"Sr#g)"AerBackendProperties   zClass representing Aer backend properties

This holds backend properties measured by the provider. All properties
which are provided optionally. These properties may describe qubits, gates,
or other general properties of the backend.
c                 h   0 U l         Xl        X l        [        U[        5      (       a  [
        R                  R                  U5      nX0l        X`l	        X@l
        XPl        0 U l        [        U5       H]  u  p0 n
U	 HP  nU R                  UR                  UR                   5      nXR"                  4XR$                  '   XR                  U'   MR     M_     0 U l        U H  nUR(                  U R&                  ;  a  0 U R&                  UR(                  '   0 n
UR*                   HB  nU R                  UR                  UR                   5      nXR"                  4XR$                  '   MD     XR&                  UR(                     [-        UR                  5      '   M     U R                   R/                  U5        g)a  Initialize a BackendProperties instance.

Args:
    backend_name (str): Backend name.
    backend_version (str): Backend version in the form X.Y.Z.
    last_update_date (datetime.datetime or str): Last date/time that a property was
        updated. If specified as a ``str``, it must be in ISO format.
    qubits (list): System qubit parameters as a list of lists of
                   :class:`Nduv` objects
    gates (list): System gate parameters as a list of :class:`GateProperties`
                  objects
    general (list): General parameters as a list of :class:`Nduv`
                    objects
    kwargs: optional additional fields
N)r9   backend_namebackend_versionr$   strdateutilparserisoparselast_update_dategeneralr:   gates_qubits	enumerate_apply_prefixr   r   r   r   _gatesr;   r<   tupler=   )r   r[   r\   ra   r:   rc   rb   r>   qubitpropsformatted_propspropr   r;   params                  r   r   AerBackendProperties.__init__   sZ   $ 
(.&,,'778HI 0
%f-LE O**4::tyyA.3YY-?		*&5U#  . Dyy+)+DII& O**5;;

C/4jj.A

+ ) :IKK		"5#56  	

&!r   c                 f     U R                   U   $ ! [         a  n[        SU S35      UeS nAff = frA   rB   rE   s      r   rG    AerBackendProperties.__getattr__   rI   rJ   c                 B   [         R                   " U5      nUR                  S5      nUR                  S5      nUR                  S5      n/ nUR                  S5       HC  n/ nU H'  n	UR                  [        R	                  U	5      5        M)     UR                  U5        ME     UR                  S5       V
s/ s H  n
[
        R	                  U
5      PM     nn
UR                  S5       V
s/ s H  n
[        R	                  U
5      PM     nn
U " X4XVX40 UD6$ s  sn
f s  sn
f )a#  Create a new BackendProperties object from a dictionary.

Args:
    data (dict): A dictionary representing the BackendProperties to create.  It will be in
        the same format as output by :meth:`to_dict`.

Returns:
    BackendProperties: The BackendProperties from the input dictionary.
r[   r\   ra   r:   rc   rb   )copypopappendr   r   r6   )r   r   rO   r[   r\   ra   r:   ri   nduvsnduvrS   rc   rb   s                r   r   AerBackendProperties.from_dict   s     ))D/{{>2!++&78";;'9:[[*EET^^D12 MM% 	 +
 7>kk'6JK6J))!,6JK.5kk).DE.D4>>!$.DE+;U
W^
 	
 LEs   7D+Dc                    U R                   U R                  U R                  S.n/ US'   U R                   HA  n/ nU H"  nUR	                  UR                  5       5        M$     US   R	                  U5        MC     U R                   Vs/ s H  oUR                  5       PM     snUS'   U R                   Vs/ s H  oUR                  5       PM     snUS'   UR                  U R                  5        U$ s  snf s  snf )zReturn a dictionary format representation of the BackendProperties.

Returns:
    dict: The dictionary form of the BackendProperties.
)r[   r\   ra   r:   rc   rb   )
r[   r\   ra   r:   rt   r    rc   rb   r=   r9   )r   r   ri   qubit_propsitemrS   s         r   r    AerBackendProperties.to_dict   s     !--#33 $ 5 5

  [[EK""4<<>2 X%%k2	 !
 37**=*QYY[*=48LLALqyy{LA

# >As   	C26C7c                 t    [        U[        5      (       a#  U R                  5       UR                  5       :X  a  ggr#   )r$   rX   r    r%   s     r   r'   AerBackendProperties.__eq__  s*    e122||~0r   Nr;   r:   r   return.c                     U R                   U   nUb3  [        U[        5      (       a  U4nU[        U5         nU(       a  XC   nU$ U(       a  [	        SU SU 35      e U$ ! [
         a  n[	        SU 35      UeSnAff = f)a  
Return the property of the given gate.

Args:
    gate: Name of the gate.
    qubits: The qubit to find the property for.
    name: Optionally used to specify which gate property to return.

Returns:
    Gate property as a tuple of the value and the time it was measured.

Raises:
    ValueError: If the property is not found or name is
                          specified but qubit is not.
NzProvide qubits to get z of z(Could not find the desired property for )rg   r$   intrh   
ValueErrorrC   )r   r;   r:   r   resultrF   s         r   gate_property"AerBackendProperties.gate_property  s    2	X[[&F!fc**$YFf.#\F
 	  #9$tD6!JKK    	XGvNOUWW	Xs   AA" A" "
B ,A;;B c                     / nU R                    H,  nU R                  U5      (       a  M  UR                  U5        M.     U$ )zReturn a list of faulty qubits.)rd   is_qubit_operationalrt   )r   faultyri   s      r   faulty_qubits"AerBackendProperties.faulty_qubits@  s9    \\E,,U33e$ " r   c                     / nU R                    HA  nU R                  UR                  UR                  5      (       a  M0  UR	                  U5        MC     U$ )zReturn a list of faulty gates.)rc   is_gate_operationalr;   r:   rt   )r   r   r;   s      r   faulty_gates!AerBackendProperties.faulty_gatesH  sC    JJD++DIIt{{CCd#  r   c                 T    U R                  X5      nSU;   a  [        US   S   5      $ g)z
Return the operational status of the given gate.

Args:
    gate: Name of the gate.
    qubits: The qubit to find the operational status for.

Returns:
    bool: Operational status of the given gate. True if the gate is operational,
    False otherwise.
operationalr   T)r   bool)r   r;   r:   
propertiess       r   r   (AerBackendProperties.is_gate_operationalP  s4     ''5
J&
=1!455r   c                 ,    U R                  XS5      S   $ )z
Return gate error estimates from backend properties.

Args:
    gate: The gate for which to get the error.
    qubits: The specific qubits for the gate.

Returns:
    Gate error of the given gate and qubit(s).

gate_errorr   r   r   r;   r:   s      r   r   AerBackendProperties.gate_errora  s     !!$=a@@r   c                 ,    U R                  XS5      S   $ )z
Return the duration of the gate in units of seconds.

Args:
    gate: The gate for which to get the duration.
    qubits: The specific qubits for the gate.

Returns:
    Gate length of the given gate and qubit(s).
gate_lengthr   r   r   s      r   r    AerBackendProperties.gate_lengthn  s     !!$>qAAr   ri   c                      U R                   U   nUb  X2   nU$ ! [         a)  nU(       a  SU-   S-   OSn[        SU SU S35      UeSnAff = f)a3  
Return the property of the given qubit.

Args:
    qubit: The property to look for.
    name: Optionally used to specify within the hierarchy which property to return.

Returns:
    Qubit property as a tuple of the value and the time it was measured.

Raises:
    ValueError: If the property is not found.
Nzy ''ieszCouldn't find the propertz for qubit .)rd   rC   r   )r   ri   r   r   rF   formatted_names         r   qubit_property#AerBackendProperties.qubit_property{  sp    *	\\%(F   	37UT\C/UN+N+;;ugQO	s    
A$AAc                 ,    U R                  US5      S   $ )z
Return the T1 time of the given qubit.

Args:
    qubit: Qubit for which to return the T1 time of.

Returns:
    T1 time of the given qubit.
T1r   r   r   ri   s     r   t1AerBackendProperties.t1       ""5$/22r   c                 ,    U R                  US5      S   $ )z
Return the T2 time of the given qubit.

Args:
    qubit: Qubit for which to return the T2 time of.

Returns:
    T2 time of the given qubit.
T2r   r   r   s     r   t2AerBackendProperties.t2  r   r   c                 ,    U R                  US5      S   $ )z
Return the frequency of the given qubit.

Args:
    qubit: Qubit for which to return frequency of.

Returns:
    Frequency of the given qubit.
	frequencyr   r   r   s     r   r   AerBackendProperties.frequency  s     ""5+6q99r   c                 ,    U R                  US5      S   $ )z
Return the readout error of the given qubit.

Args:
    qubit: Qubit for which to return the readout error of.

Return:
    Readout error of the given qubit.
readout_errorr   r   r   s     r   r   "AerBackendProperties.readout_error  s     ""5/:1==r   c                 ,    U R                  US5      S   $ )z
Return the readout length [sec] of the given qubit.

Args:
    qubit: Qubit for which to return the readout length of.

Return:
    Readout length of the given qubit.
readout_lengthr   r   r   s     r   r   #AerBackendProperties.readout_length  s     ""5*:;A>>r   c                 T    U R                  U5      nSU;   a  [        US   S   5      $ g)z
Return the operational status of the given qubit.

Args:
    qubit: Qubit for which to return operational status of.

Returns:
    Operational status of the given qubit.
r   r   T)r   r   )r   ri   r   s      r   r   )AerBackendProperties.is_qubit_operational  s4     ((/
J&
=1!455r   r   r   c                 \     [        X5      $ ! [         a  n[        SU 35      UeSnAff = f)z
Given a SI unit prefix and value, apply the prefix to convert to
standard SI unit.

Args:
    value: The number to apply prefix to.
    unit: String prefix.

Returns:
    Converted value.

Raises:
    ValueError: If the units aren't recognized.
zCould not understand units: N)r   	Exceptionr   )r   r   r   rF   s       r   rf   "AerBackendProperties._apply_prefix  s:    	L,, 	L;D6BCK	Ls   
 
+&+)	r9   rg   rd   r[   r\   rc   rb   ra   r:   )NNN)$r.   r/   r0   r1   r2   r9   r   rG   r3   r   r    r'   r]   r   r   r   r   r   	PropertyTr   r   r   r   r   floatr   r   r   r   r   r   r   r   r   rf   r4   r   r   r   rX   rX      s    E-"^M 
 
6, -1	%% c8C=()% 	%
 
U38_d3	>223S)^	
%N U3;M5N Z^ "As AE#x}2D,E A% AB BU33E-F B5 B    
S)^	
	@
3 
3 
3
3 
3 
3
:s 
:u 
:
>3 
>5 
>
?C 
?E 
?# $ L5 L L Lr   rX   targetc                    SSS/ S.n/ n/ nU R                  5        GH  u  pEUS:w  Ga:  UR                  5        GH"  u  pg/ n[        USS5      bU  UR                  [        R                  R	                  [        R
                  R                  5      SSUR                  S.5        [        US	S5      bU  UR                  [        R                  R	                  [        R
                  R                  5      S
SUR                  S.5        U(       d  M  UR                  U[        U5      UUSR                  U V	s/ s H  n	[        U	5      PM     sn	5      -   S.5        GM%     GMG  0 n
U R                  b%  [        U R                  5       V	s0 s H  oS_M     n
n	UR                  5        H  u  pgUc  M
  US   n/ n[        US	S5      bU  UR                  [        R                  R	                  [        R
                  R                  5      SSUR                  S.5        [        USS5      bU  UR                  [        R                  R	                  [        R
                  R                  5      SSUR                  S.5        U(       d  0 n
  OXU'   M     U
(       d  GM  [        S U
R                  5        5       5      (       d  GM  [        U R                  5       Vs/ s H  oU   PM	     nnGM     U(       d  U(       aU  X!S'   X1S'   [         R"                  " 5          [         R$                  " S[&        S9  [(        R+                  U5      sSSS5        $ gs  sn	f s  sn	f s  snf ! , (       d  f       g= f)zYConvert a :class:`qiskit.transpiler.Target` into a legacy :class:`~.AerBackendProperties` N)r[   r\   ra   rb   measuredurationr   sr   errorr   _)r;   r:   r<   r   r   r   r   c              3   (   #    U  H  oS Lv   M
     g 7fr   r   ).0rS   s     r   	<genexpr>/target_to_backend_properties.<locals>.<genexpr>D  s     "O:NQD=:Ns   rc   r:   ignore)category)rL   getattrrt   datetimenowtimezoneutcr   r   rM   joinr]   
num_qubitsrangeallvalueswarningscatch_warningsfilterwarningsDeprecationWarningrX   r   )r   properties_dictrc   r:   r;   
qargs_listqargsrj   property_listrS   ry   ri   
props_listis                 r   target_to_backend_propertiesr     s	     	'O EF"LLN9 * 0 0 2 "5*d3?!(($,$5$5$9$9(:K:K:O:O$P$1$'%*^^	 5'40<!(($,$5$5$9$9(:K:K:O:O$P$0$&%*[[	 !=LL$(&*5k*7$(388U4KUSVU4K+L$L	+ !3< +-K  ,05f6G6G0HI0H1$w0HI * 0 0 2=a
5'40<%%$,$5$5$9$9(:K:K:O:O$P$3$&%*[[	 5*d3?%%$,$5$5$9$9(:K:K:O:O$P$4$'%*^^	 ""$K%/E"5 !36 {s"O+:L:L:N"OOO278I8I2JK2JQa.2JK +@ #( $*!$$&##H7IJ'11/B '&
 Y 5L J: L '&s   7M	MM.M""
M0)r2   rr   r   r   typingr   r   r   r   r   dateutil.parserr^   qiskit.utils.unitsr   qiskit.transpiler.targetr	   r   r   r6   rX   r   r   r   r   <module>r      sr       4 4  + + #x((()	;R ;R|F FRVL VLr
S Sr   