§
    º³Ùgy  ã                  ój   — d Z ddlmZ ddlmZ ddlZddlmZ ddl	m
Z
 ddlmZ  G d„ d	e
¦  «        ZdS )
z:A pulse that is described by complex-valued sample points.é    )Úannotations)ÚAnyN)Ú
PulseError)ÚPulse)Údeprecate_pulse_funcc                  óš   ‡ — e Zd ZdZe	 	 	 ddˆ fd„¦   «         Zedd„¦   «         Zdd d„Zd!d„Z	ed"d„¦   «         Z
d#ˆ fd„Zd$d„Zd%d„Zˆ xZS )&ÚWaveformz†A pulse specified completely by complex-valued samples; each sample is played for the
    duration of the backend cycle-time, dt.
    NçH¯¼šò×z>Úsamplesúnp.ndarray | list[complex]Únameú
str | NoneÚepsilonÚfloatÚlimit_amplitudeúbool | Nonec                óð   •— t          ¦   «                              t          |¦  «        ||¬¦  «         t          j        |t          j        ¬¦  «        }|| _        |                      ||¬¦  «        | _        dS )a  Create new sample pulse command.

        Args:
            samples: Complex array of the samples in the pulse envelope.
            name: Unique name to identify the pulse.
            epsilon: Pulse sample norm tolerance for clipping.
                If any sample's norm exceeds unity by less than or equal to epsilon
                it will be clipped to unit norm. If the sample
                norm is greater than 1+epsilon an error will be raised.
            limit_amplitude: Passed to parent Pulse
        )Údurationr   r   ©Údtype)r   N)	ÚsuperÚ__init__ÚlenÚnpÚasarrayÚ
complex128r   Ú_clipÚ_samples)Úselfr   r   r   r   Ú	__class__s        €úS/granary/edev/quantum/lib/python3.11/site-packages/qiskit/pulse/library/waveform.pyr   zWaveform.__init__   sb   ø€ õ( 	‰Œ×Ò¥# g¡,¤,°TÈ?ÐÑ[Ô[Ð[Ý”*˜W­B¬MÐ:Ñ:Ô:ˆØˆŒØŸ
š
 7°G˜
Ñ<Ô<ˆŒˆˆó    Úreturnú
np.ndarrayc                ó   — | j         S )zReturn sample values.)r   ©r   s    r!   r   zWaveform.samples6   s   € ð Œ}Ðr"   c                óÈ  — t          j        |¦  «        }|dk    |d|z   k    z  }t          j        |¦  «        rãt          j        |¦  «        }t          j        ||         ¦  «        }t          j        d|z  t           j        ¬¦  «        }t          j        |¦  «        }|dk    }	t          j        |	¦  «        rHt          j        |	¦  «        }
d|z
  t          j        d||
         z  t           j        ¬¦  «        z  }|||
<   |||<   t          j        |¦  «        ||<   t          j        |dk    ¦  «        r.| j        r't          j        |¦  «        }t          d|› d�¦  «        ‚|S )a´  If samples are within epsilon of unit norm, clip sample by reducing norm by (1-epsilon).

        If difference is greater than epsilon error is raised.

        Args:
            samples: Complex array of the samples in the pulse envelope.
            epsilon: Pulse sample norm tolerance for clipping.
                If any sample's norm exceeds unity by less than or equal to epsilon
                it will be clipped to unit norm. If the sample
                norm is greater than 1+epsilon an error will be raised.

        Returns:
            Clipped pulse samples.

        Raises:
            PulseError: If there exists a pulse sample with a norm greater than 1+epsilon.
        g      ð?y              ð?r   é   z Pulse contains sample with norm zP greater than 1+epsilon. This can be overruled by setting Pulse.limit_amplitude.)
r   ÚabsÚanyÚargwhereÚangleÚexpr   Ú_limit_amplitudeÚmaxr   )r   r   r   Úsamples_normÚto_clipÚ
clip_whereÚ
clip_angleÚclipped_samplesÚclipped_sample_normsÚto_clip_epsilonÚclip_where_epsilonÚclipped_samples_epsilonÚamps                r!   r   zWaveform._clip;   sz  € õ$ ”v˜g‘”ˆØ #Ò%¨,¸#À¹-Ò*GÑHˆåŒ6�'‰?Œ?ð 	?åœ WÑ-Ô-ˆJÝœ '¨*Ô"5Ñ6Ô6ˆJÝ œf R¨*¡_½B¼MÐJÑJÔJˆOõ $&¤6¨/Ñ#:Ô#:Ð Ø2°SÒ8ˆOÝŒv�oÑ&Ô&ð NÝ%'¤[°Ñ%AÔ%AÐ"Ø+,¨w©;½"¼&Ø˜Ð$6Ô7Ñ7½r¼}ð;ñ ;ô ;ñ +Ð'ð 7N�Ð 2Ñ3ð #2ˆG�JÑÝ')¤v¨oÑ'>Ô'>ˆL˜Ñ$åŒ6�, Ò$Ñ%Ô%ð 	¨$Ô*?ð 	Ý”&˜Ñ&Ô&ˆCÝðK°3ð Kð Kð Kñô ð ð
 ˆr"   Úboolc                ó   — dS )z1Return True iff the instruction is parameterized.F© r&   s    r!   Úis_parameterizedzWaveform.is_parameterizedn   s   € àˆur"   údict[str, Any]c                ó   — i S )z6Return a dictionary containing the pulse's parameters.r<   r&   s    r!   Ú
parameterszWaveform.parametersr   s	   € ð ˆ	r"   ÚotherÚobjectc                ó   •— t          |t          ¦  «        st          S t          ¦   «                              |¦  «        o@| j        j        |j        j        k    o&t          j        | j        |j        d| j	        ¬¦  «        S )Nr   )ÚrtolÚatol)
Ú
isinstancer	   ÚNotImplementedr   Ú__eq__r   Úshaper   Úallcloser   )r   rA   r    s     €r!   rH   zWaveform.__eq__w   sm   ø€ Ý˜%¥Ñ*Ô*ð 	"Ý!Ð!å‰GŒG�NŠN˜5Ñ!Ô!ð TØ”Ô" e¤mÔ&9Ò9ðTå”˜DœL¨%¬-¸aÀdÄlÐSÑSÔSð	
r"   Úintc                óN   — t          | j                             ¦   «         ¦  «        S )N)Úhashr   Útobytesr&   s    r!   Ú__hash__zWaveform.__hash__€   s   € Ý�D”L×(Ò(Ñ*Ô*Ñ+Ô+Ð+r"   Ústrc                óè   — t          j        ¦   «         }t          j        d¬¦  «         t          j        di |¤Ž | j        �d| j        › d�nd}| j        j        › dt          | j        ¦  «        › |› d�S )	Né2   )Ú	thresholdz, name='ú'Ú ú(ú)r<   )r   Úget_printoptionsÚset_printoptionsr   r    Ú__name__Úreprr   )r   ÚoptÚ	name_reprs      r!   Ú__repr__zWaveform.__repr__ƒ   s…   € ÝÔ!Ñ#Ô#ˆÝ
Ô bÐ)Ñ)Ô)Ð)Ý
ÔÐ"Ð"˜cÐ"Ð"Ð"Ø/3¬yÐ/DÐ+˜tœyÐ+Ð+Ð+Ð+È"ˆ	Ø”.Ô)ÐLÐL­D°´Ñ,>Ô,>ÐLÀ	ÐLÐLÐLÐLr"   )Nr
   N)r   r   r   r   r   r   r   r   )r#   r$   )r
   )r   r$   r   r   r#   r$   )r#   r:   )r#   r>   )rA   rB   r#   r:   )r#   rK   )r#   rP   )rZ   Ú
__module__Ú__qualname__Ú__doc__r   r   Úpropertyr   r   r=   r@   rH   rO   r^   Ú__classcell__)r    s   @r!   r	   r	      s   ø€ € € € € ðð ð ð  ØØ'+ð=ð =ð =ð =ð =ð =ñ Ôð=ð0 ðð ð ñ „Xðð1ð 1ð 1ð 1ð 1ðfð ð ð ð ðð ð ñ „Xðð
ð 
ð 
ð 
ð 
ð 
ð,ð ,ð ,ð ,ðMð Mð Mð Mð Mð Mð Mð Mr"   r	   )ra   Ú
__future__r   Útypingr   Únumpyr   Úqiskit.pulse.exceptionsr   Úqiskit.pulse.library.pulser   Úqiskit.utils.deprecate_pulser   r	   r<   r"   r!   ú<module>rj      s¼   ðð AÐ @Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø =Ð =Ð =Ð =Ð =Ð =ðpMð pMð pMð pMð pMˆuñ pMô pMð pMð pMð pMr"   