
    z	i                         S r SSK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  SS	KJr  \R$                  " \R&                  " S
\S95       " S S\	5      5       rg)z)
Delay instruction (for circuit module).
    N)exprtypes)CircuitError)Instruction)Gate)_utils)ParameterExpression)StandardInstructionType   dtypec                     ^  \ rS rSrSr\R                  rSU 4S jjr\	S 5       r
\R                  rSS\4S jjr\S 5       r\R"                  S 5       r\S	 5       r\R"                  S
 5       rS\R(                  4S jrS rS rS rSrU =r$ )Delay   z=Do nothing and just delay/wait/idle for a specified duration.c                 X   > U R                  X5      u  ol        [        TU ]  SSSU/S9  g)a;  
Args:
    duration: the length of time of the duration. If this is an
        :class:`~.expr.Expr`, it must be a constant expression of type
        :class:`~.types.Duration` and the ``unit`` parameter should be
        omitted (or MUST be "expr" if it is specified).
    unit: the unit of the duration, if ``duration`` is a numeric
        value. Must be ``"dt"``, an SI-prefixed seconds unit, or "expr".

Raises:
    CircuitError: A ``duration`` expression was specified with a resolved
        type that is not timing-based, or the ``unit`` was improperly specified.
delay   r   paramsN)_validate_arguments_unitsuper__init__)selfdurationunit	__class__s      N/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/delay.pyr   Delay.__init__!   s2      $77G*!Qz:    c                 j   [        U [        R                  5      (       au  Ub  US:w  a  [        S5      eU R                  R
                  [        R                  La  [        SU R                   S35      eU R                  (       d  [        S5      eSnX4$ Uc  SnX4$ US;  a  [        SU S	35      eX4$ )
Nr   z@Argument 'unit' must not be specified for a duration expression.zExpression of type 'z' is not valid for 'duration'.&Duration expressions must be constant.dt>   sr#   msnspsusUnknown unit  is specified.)	
isinstancer   Exprr   typekindr   Durationconst)r   r   s     r   r   Delay._validate_arguments2   s     h		**DFN"V  }}!!7"*8==/9WX  >>"#KLLD
 ~	 \D ~ <<tfNCDD~r    	annotatedc                     U $ )zSpecial case. Return self. )r   r2   s     r   inverseDelay.inverseJ   s    r    c                     U R                   $ )z8The unit for the duration of the delay in :attr`.params`)r   r   s    r   r   
Delay.unitN   s     zzr    c                 :    US;  a  [        SU S35      eXl        g )N>   r$   r#   r%   r&   r'   r(   r)   r*   )r   r   )r   values     r   r   r9   S   s$    ;;ug^DEE
r    c                      U R                   S   $ )zGet the duration of this delay.r   r   r8   s    r   r   Delay.durationY   s     {{1~r    c                     U/U l         g)zSet the duration of this delay.Nr   )r   r   s     r   r   r=   ^   s      jr    returnc                 (    U R                  [        S9$ )zReturn a Numpy.array for the unitary matrix. This has been
added to enable simulation without making delay a full Gate type.

Returns:
    np.ndarray: matrix representation.
r   )	__array__complexr8   s    r   	to_matrixDelay.to_matrixc   s     ~~G~,,r    c                     [        U[        5      =(       a1    U R                  UR                  :H  =(       a    U R                  U5      $ N)r+   r   r   _compare_parameters)r   others     r   __eq__Delay.__eq__l   s4    ue$dejj)@dTE]E]^cEd	
r    c                 n    U R                   R                   SU R                  S    SU R                   S3$ )z2Return the official string representing the delay.z
(duration=r   z[unit=z]))r   __name__r   r   r8   s    r   __repr__Delay.__repr__q   s4    ..))**T[[^4DF499+UWXXr    c                    [        U[        5      (       a  US:  a  [        SU 35      eU$ [        U[        5      (       aC  US:  a  [        SU 35      eU R                  S:X  a  [        U5      nX:w  a  [        S5      eU$ U$ [        U[
        R                  5      (       a^  UR                  R                  [        R                  La  [        SUR                   S35      eUR                  (       d  [        S5      eU$ [        U[        5      (       a  [        UR                  5      S:  a  U$ UR                  5       (       d  [        SU R                    35      e[        U5      nUS:  a  [        SU 35      eU R"                  S:X  a+  [        U5      n[%        X4-
  5      nUS	:  a  [        S
5      eU$ U$ [        S[        U5       SU R                    S35      e)zPDelay parameter (i.e. duration) must be Expr, int, float or ParameterExpression.r   z7Duration for Delay instruction must be positive. Found r#   z+Integer duration is expected for 'dt' unit.zExpression duration of type 'z' is not valid.r"   z/Bound parameter expression is complex in delay gV瞯<z8Integer parameter is required for duration in 'dt' unit.zInvalid param type z for delay .)r+   intr   floatr   r   r,   r-   r.   r   r/   r0   r	   len
parametersis_realnamer   abs)r   	parameterparameter_intfvalivalrounding_errors         r   validate_parameterDelay.validate_parameterv   s   i%%1}"Mi[Y  	5))1}"Mi[Y  zzT! #I-&'TUU$$	499--~~""%..8"%B9>>BRRa#bcc??"#KLL	#6779''(1,  $$&&"%TUYU^U^T_#`aa#Dax"%\]a\b#cddyyD 9~!$T[!1!E)&'abbK!4T)_4E[QUQZQZP[[\]^^r    )r   r   rF   )F)rL   
__module____qualname____firstlineno____doc__r
   r   _standard_instruction_typer   staticmethodr   r   broadcast_argumentsboolr5   propertyr   setterr   npndarrayrC   rI   rM   r]   __static_attributes____classcell__)r   s   @r   r   r      s    G!8!>!>;"  * 22    
[[ 
   __! !-2:: -

Y
)_ )_r    r   )rb   numpyri   qiskit.circuit.classicalr   r   qiskit.circuit.exceptionsr   qiskit.circuit.instructionr   qiskit.circuit.gater   qiskit.circuitr   "qiskit.circuit.parameterexpressionr	   qiskit._accelerate.circuitr
   with_gate_arrayeyerB   r   r4   r    r   <module>rw      s[     0 2 2 $ ! B > q01C_K C_ 2C_r    