ó
    {	i  ã                   óš   • S r SSKJrJrJrJrJr  SSKJrJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJr  SS	KJrJr  \\\\	4   r " S
 S\5      rg)z
Local noise addition pass.
é    )ÚOptionalÚUnionÚSequenceÚCallableÚIterable)ÚInstructionÚQuantumCircuit)Ú
DAGCircuit)Úcircuit_to_dag)ÚTransformationPass)ÚTranspilerErroré   )ÚQuantumErrorÚReadoutErrorc            	       ó†   ^ • \ rS rSrSr  SS\\\\   /\	\
   4   S\	\\\\   4      S\4U 4S jjjrS\S\4S	 jrS
rU =r$ )ÚLocalNoisePassé   a  Transpiler pass to insert noise into a circuit.

The noise in this pass is defined by a noise function or callable with signature

.. code:: python

        def func(
            inst: Instruction,
            qubits: Optional[List[int]] = None
        ) -> InstructionLike:

For every instance of one of the reference instructions in a circuit the
supplied function is called on that instruction and the returned noise
is added to the circuit. This noise can depend on properties of the
instruction it is called on (for example parameters or duration) to
allow inserting parameterized noise models.

Several methods for adding the constructed errors to circuits are supported
and can be set by using the ``method`` kwarg. The supported methods are

* ``"append"``: add the return of the callable after the instruction.
* ``"prepend"``: add the return of the callable before the instruction.
* ``"replace"``: replace the instruction with the return of the callable.
    If the return is None, the instruction will be removed.

ÚfuncÚop_typesÚmethodc                 ó6  >• US;  a  [        SU S35      e[        U[        5      (       a  U4n[        TU ]  5         Xl        U(       a  [        U5      O	[        5       U l        X0l        [        S U R                   5       5      (       d  [        SU S35      eg)a½  Initialize noise pass.

Args:
    func: noise function `func(inst, qubits) -> InstructionLike`.
    op_types: Optional, single or list of instruction types to apply the
        noise function to. If None the noise function will be
        applied to all instructions in the circuit.
    method: method for inserting noise. Allow methods are
        'append', 'prepend', 'replace'.
Raises:
    TranspilerError: if an invalid option is specified.
>   ÚappendÚprependÚreplacezInvalid method: z-, it must be "append", "prepend" or "replace"c              3   óB   #   • U  H  n[        U[        5      v •  M     g 7f)N)Ú
isinstanceÚtype)Ú.0Úops     Úb/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_aer/noise/passes/local_noise_pass.pyÚ	<genexpr>Ú*LocalNoisePass.__init__.<locals>.<genexpr>S   s   é € Ð<²)¨B”:˜b¤$×'Ð'²)ùs   ‚zInvalid ops: 'z8', expecting single or list of operation types (or None)N)
r   r   r   ÚsuperÚ__init__Ú_funcÚtupleÚ_opsÚ_methodÚall)Úselfr   r   r   Ú	__class__s       €r    r$   ÚLocalNoisePass.__init__7   s˜   ø€ ð$ Ð9Ó9Ü!Ø" 6 (Ð*WÐXóð ô h¤×%Ñ%Ø {ˆHÜ‰ÑÔØŒ
Þ'/”E˜(”O´U³WˆŒ	ØŒÜÑ<°$·)²)Ó<×<Ñ<Ü!Ø   
Ð*bÐcóð ð =ó    ÚdagÚreturnc           	      óê  • [        UR                  5       VVs0 s H  u  p#X2_M	     nnnUR                  5        GH‹  nU R                  (       a'  [	        UR
                  U R                  5      (       d  M<  UR                   Vs/ s H  odU   PM	     nnU R                  UR
                  U5      nUc#  U R                  S:X  a  UR                  U5        Mœ  [	        U[        5      (       a  [        S5      e[        5       n	U	R                  UR                  5        U	R                  UR                  5        U R                  S:X  a/  U	R!                  UR
                  UR                  UR                  S9  [	        U["        [$        45      (       d   UR'                  5       nUR*                  S:”  a  [        S5      eUR,                  [/        UR                  5      :w  a;  [        S	UR,                   S
[/        UR                  5       SUR0                   35      e[	        U["        5      (       a-  U	R3                  [5        U5      [7        UR                  5      S9  OU	R!                  X…R                  S9  U R                  S:X  a/  U	R!                  UR
                  UR                  UR                  S9  UR9                  XY5        GMŽ     U$ s  snnf s  snf ! [(         a  n
[        S5      U
eSn
A
ff = f)z¦Run the LocalNoisePass pass on `dag`.
Args:
    dag: DAG to be changed.
Returns:
    A changed DAG.
Raises:
    TranspilerError: if generated operation is not valid.
Nr   z0Insertions of ReadoutError is not yet supported.r   )ÚqargsÚcargszDFunction must return an object implementing 'to_instruction' method.r   z,Noise must be an instruction without clbits.z!Number of qubits of generated op z != z that of a reference op )Úqubits)r1   r   )Ú	enumerater3   Útopological_op_nodesr'   r   r   r1   r%   r(   Úremove_op_noder   r   r
   Ú
add_qubitsÚ
add_clbitsr2   Úapply_operation_backr	   r   Úto_instructionÚAttributeErrorÚ
num_clbitsÚ
num_qubitsÚlenÚnameÚcomposer   ÚlistÚsubstitute_node_with_dag)r*   r.   ÚidxÚqubitÚqubit_indicesÚnodeÚqr3   Únew_opÚnew_dagÚatt_errs              r    ÚrunÚLocalNoisePass.runX   sy  € ô 7@ÀÇ
Á
Ô6KÔLÒ6K©
¨˜šÑ6KˆÑLØ×,Ñ,×.ˆDØyy¤¨D¯G©G°T·Y±Y×!?Ñ!?Ùà04·
²
Ó;²
¨1 AÔ&±
ˆFÐ;Ø—Z‘Z §¡¨Ó0ˆFà‰~à—<‘< 9Ó,Ø×&Ñ& tÔ,Ùä˜&¤,×/Ñ/Ü%Ð&XÓYÐYô !“lˆGØ×Ñ˜tŸz™zÔ*Ø×Ñ˜tŸz™zÔ*ð |‰|˜xÓ'Ø×,Ñ,¨T¯W©W¸D¿J¹JÈdÏjÉjÐ,ÑYô ˜f¤~´{Ð&C×DÑDð#Ø#×2Ñ2Ó4Fð × Ñ  1Ó$Ü%Ð&TÓUÐUð × Ñ ¤C¨¯
©
£OÓ3Ü%Ø7¸×8IÑ8IÐ7JÈ$Ü˜4Ÿ:™:“Ð'Ð'?ÀÇ	Á	¸{ðLóð ô ˜&¤.×1Ñ1ð —‘Ü" 6Ó*´4¸¿
¹
Ó3Cð  ò ð
 ×,Ñ,¨V¿:¹:Ð,ÑFð |‰|˜yÓ(Ø×,Ñ,¨T¯W©W¸D¿J¹JÈdÏjÉjÐ,ÑYà×(Ñ(¨×7ñy /ð| ˆ
ùó Mùò
 <øô4 &ó #Ü)Ø^óà"ð#ûð#ús#   ™KÂKÆKË
K2Ë!K-Ë-K2)r%   r(   r'   )Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   Úintr   ÚInstructionLiker   r   r   Ústrr$   r
   rK   Ú__static_attributes__Ú__classcell__)r+   s   @r    r   r      s~   ø† ñð< ;?Øñ	à˜ X¨c¡]Ð3°X¸oÑ5NÐNÑOðð ˜5  x°¡~Ð!5Ñ6Ñ7ðð ÷	ð ðBHzð H j÷ Hò Hr-   r   N)rQ   Útypingr   r   r   r   r   Úqiskit.circuitr   r	   Úqiskit.dagcircuitr
   Úqiskit.convertersr   Úqiskit.transpilerr   Úqiskit.transpiler.exceptionsr   Úerrorsr   r   rS   r   © r-   r    Ú<module>r_      sE   ðñ÷ AÕ @ç 6Ý (Ý ,Ý 0Ý 8ß /à˜ \°>ÐAÑB€ôEÐ'õ Er-   