§
    º³Ùgc  ã                  óˆ  — d Z ddlm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 dd	lmZ  G d
„ de¬¦  «        Z G d„ dee¬¦  «        Z G d„ dee¬¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )a4  
.. _pulse-channels:

=======================================
Channels (:mod:`qiskit.pulse.channels`)
=======================================

Pulse is meant to be agnostic to the underlying hardware implementation, while still allowing
low-level control. Therefore, our signal channels are  *virtual* hardware channels. The backend
which executes our programs is responsible for mapping these virtual channels to the proper
physical channel within the quantum control hardware.

Channels are characterized by their type and their index.  Channels include:

* transmit channels, which should subclass ``PulseChannel``
* receive channels, such as :class:`AcquireChannel`
* non-signal "channels" such as :class:`SnapshotChannel`, :class:`MemorySlot` and
  :class:`RegisterChannel`.

Novel channel types can often utilize the :class:`ControlChannel`, but if this is not sufficient,
new channel types can be created. Then, they must be supported in the PulseQobj schema and the
assembler.  Channels are characterized by their type and their index. See each channel type below to
learn more.

.. autosummary::
   :toctree: ../stubs/

   DriveChannel
   MeasureChannel
   AcquireChannel
   ControlChannel
   RegisterSlot
   MemorySlot
   SnapshotChannel

All channels are children of the same abstract base class:

.. autoclass:: Channel
é    )Úannotations)ÚABCMeta)ÚAnyN)Ú	Parameter)ÚParameterExpression)Ú
PulseError)Údeprecate_pulse_funcc                  ó¸   ‡ — e Zd ZU dZdZded<   	 ˆ fd„Zedd„¦   «         Ze	dd„¦   «         Z
dd„Ze	dd„¦   «         Zdd„Ze	dd„¦   «         Zd„ Zd d„Zd„ Zˆ xZS )!ÚChannelaÄ  Base class of channels. Channels provide a Qiskit-side label for typical quantum control
    hardware signal channels. The final label -> physical channel mapping is the responsibility
    of the hardware backend. For instance, ``DriveChannel(0)`` holds instructions which the backend
    should map to the signal line driving gate operations on the qubit labeled (indexed) 0.

    When serialized channels are identified by their serialized name ``<prefix><index>``.
    The type of the channel is interpreted from the prefix,
    and the index often (but not always) maps to the qubit index.
    All concrete channel classes must have a ``prefix`` class attribute
    (and instances of that class have an index attribute). Base classes which have
    ``prefix`` set to ``None`` are prevented from being instantiated.

    To implement a new channel inherit from :class:`Channel` and provide a unique string identifier
    for the ``prefix`` class attribute.
    Nz
str | NoneÚprefixc                ór   •— | j         €t          d¦  «        ‚t          ¦   «                              | ¦  «        S )NzTCannot instantiate abstract channel. See Channel documentation for more information.)r   ÚNotImplementedErrorÚsuperÚ__new__)ÚclsÚargsÚkwargsÚ	__class__s      €úK/granary/edev/quantum/lib/python3.11/site-packages/qiskit/pulse/channels.pyr   zChannel.__new__U   s;   ø€ ØŒ:ÐÝ%ðBñô ð õ
 ‰wŒw�Š˜sÑ#Ô#Ð#ó    ÚindexÚintc                ó>   — |                       |¦  «         || _        dS )zKChannel class.

        Args:
            index: Index of channel.
        N)Ú_validate_indexÚ_index©Úselfr   s     r   Ú__init__zChannel.__init__^   s#   € ð 	×Ò˜UÑ#Ô#Ð#ØˆŒˆˆr   Úreturnúint | ParameterExpressionc                ó   — | j         S )z÷Return the index of this channel. The index is a label for a control signal line
        typically mapped trivially to a qubit index. For instance, ``DriveChannel(0)`` labels
        the signal line driving the qubit labeled with index 0.
        )r   ©r   s    r   r   zChannel.indexh   s   € ð Œ{Ðr   r   ÚNonec                ó<  — t          |t          ¦  «        r	|j        rdS t          |t          ¦  «        r2t          |¦  «        }|                     ¦   «         rt          |¦  «        }t          |t
          t          j        f¦  «        r|dk     rt          d¦  «        ‚dS )zÀRaise a PulseError if the channel index is invalid, namely, if it's not a positive
        integer.

        Raises:
            PulseError: If ``index`` is not a nonnegative integer.
        Nr   z+Channel index must be a nonnegative integer)	Ú
isinstancer   Ú
parametersÚfloatÚ
is_integerr   ÚnpÚintegerr   r   s     r   r   zChannel._validate_indexp   sœ   € õ �eÕ0Ñ1Ô1ð 	#°eÔ6Fð 	#àˆFÝ˜Õ2Ñ3Ô3ð 	#Ý˜%‘L”LˆEØ×ÒÑ!Ô!ð #Ý˜E™
œ
�å˜%¥#¥r¤zÐ!2Ñ3Ô3ð 	L°u¸q²y°yÝÐJÑKÔKÐKð 8A°yr   úset[Parameter]c                ój   — t          | j        t          ¦  «        r| j        j        S t	          ¦   «         S )z-Parameters which determine the channel index.)r%   r   r   r&   Úsetr"   s    r   r&   zChannel.parameters‚   s-   € õ �d”jÕ"5Ñ6Ô6ð 	)Ø”:Ô(Ð(Ý‰uŒuˆr   Úboolc                ó6   — t          | j        t          ¦  «        S )z-Return True iff the channel is parameterized.)r%   r   r   r"   s    r   Úis_parameterizedzChannel.is_parameterized‰   s   € å˜$œ*Õ&9Ñ:Ô:Ð:r   Ústrc                ó,   — | j         j        › | j        › �S )zRReturn the shorthand alias for this channel, which is based on its type and index.)r   r   r   r"   s    r   ÚnamezChannel.name�   s   € ð ”.Ô'Ð6¨¬Ð6Ð6Ð6r   c                ó0   — | j         j        › d| j        › d�S )Nú(ú))r   Ú__name__r   r"   s    r   Ú__repr__zChannel.__repr__’   s    € Ø”.Ô)Ð:Ð:¨D¬KÐ:Ð:Ð:Ð:r   ÚotherÚobjectc                ó–   — t          |t          ¦  «        st          S t          | ¦  «        t          |¦  «        u o| j        |j        k    S )zðReturn True iff self and other are equal, specifically, iff they have the same type
        and the same index.

        Args:
            other: The channel to compare to this channel.

        Returns:
            True iff equal.
        )r%   r   ÚNotImplementedÚtyper   )r   r9   s     r   Ú__eq__zChannel.__eq__•   sA   € õ ˜%¥Ñ)Ô)ð 	"Ý!Ð!Ý�D‰zŒz�T %™[œ[Ð(ÐH¨T¬[¸E¼LÒ-HÐHr   c                óH   — t          t          | ¦  «        | j        f¦  «        S )N)Úhashr=   r   r"   s    r   Ú__hash__zChannel.__hash__£   s   € Ý•T˜$‘Z”Z ¤Ð-Ñ.Ô.Ð.r   )r   r   )r   r    )r   r   r   r#   )r   r+   )r   r.   )r   r1   )r9   r:   r   r.   )r7   Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r	   r   Úpropertyr   r   r&   r0   r3   r8   r>   rA   Ú__classcell__©r   s   @r   r   r   @   s=  ø€ € € € € € ðð ð  €FÐÐÐÑØHð$ð $ð $ð $ð $ð ðð ð ñ Ôðð ðð ð ñ „XððLð Lð Lð Lð$ ðð ð ñ „Xðð;ð ;ð ;ð ;ð ð7ð 7ð 7ñ „Xð7ð;ð ;ð ;ðIð Ið Ið Ið/ð /ð /ð /ð /ð /ð /r   r   )Ú	metaclassc                  ó   — e Zd ZdZdS )ÚPulseChannelzHBase class of transmit Channels. Pulses can be played on these channels.N©r7   rB   rC   rD   © r   r   rK   rK   §   s   € € € € € ØRÐRà€Dr   rK   c                  ó   — e Zd ZdZdS )ÚClassicalIOChannelzVBase class of classical IO channels. These cannot have instructions scheduled on them.NrL   rM   r   r   rO   rO   ­   s   € € € € € Ø`Ð`à€Dr   rO   c                  ó   — e Zd ZdZdZdS )ÚDriveChannelzFDrive channels transmit signals to qubits which enact gate operations.ÚdN©r7   rB   rC   rD   r   rM   r   r   rQ   rQ   ³   s   € € € € € ØPÐPà€F€F€Fr   rQ   c                  ó   — e Zd ZdZdZdS )ÚMeasureChannelzBMeasure channels transmit measurement stimulus pulses for readout.ÚmNrS   rM   r   r   rU   rU   ¹   s   € € € € € ØLÐLà€F€F€Fr   rU   c                  ó   — e Zd ZdZdZdS )ÚControlChannelzÕControl channels provide supplementary control over the qubit to the drive channel.
    These are often associated with multi-qubit gate operations. They may not map trivially
    to a particular qubit index.
    ÚuNrS   rM   r   r   rX   rX   ¿   s   € € € € € ðð ð
 €F€F€Fr   rX   c                  ó   — e Zd ZdZdZdS )ÚAcquireChannelz*Acquire channels are used to collect data.ÚaNrS   rM   r   r   r[   r[   È   s   € € € € € Ø4Ð4à€F€F€Fr   r[   c                  ó&   ‡ — e Zd ZdZdZˆ fd„Zˆ xZS )ÚSnapshotChannelzBSnapshot channels are used to specify instructions for simulators.Úsc                óJ   •— t          ¦   «                              d¦  «         dS )zCreate new snapshot channel.r   N)r   r   )r   r   s    €r   r   zSnapshotChannel.__init__Ó   s!   ø€ å‰Œ×Ò˜ÑÔÐÐÐr   )r7   rB   rC   rD   r   r   rG   rH   s   @r   r^   r^   Î   sC   ø€ € € € € ØLÐLà€Fðð ð ð ð ð ð ð ð r   r^   c                  ó   — e Zd ZdZdZdS )Ú
MemorySlotz8Memory slot channels represent classical memory storage.rV   NrS   rM   r   r   rb   rb   Ø   s   € € € € € ØBÐBà€F€F€Fr   rb   c                  ó   — e Zd ZdZdZdS )ÚRegisterSlotzgClassical resister slot channels represent classical registers (low-latency classical
    memory).
    ÚcNrS   rM   r   r   rd   rd   Þ   s   € € € € € ðð ð €F€F€Fr   rd   )rD   Ú
__future__r   Úabcr   Útypingr   Únumpyr)   Úqiskit.circuitr   Ú"qiskit.circuit.parameterexpressionr   Úqiskit.pulse.exceptionsr   Úqiskit.utils.deprecate_pulser	   r   rK   rO   rQ   rU   rX   r[   r^   rb   rd   rM   r   r   ú<module>rn      sj  ðð&ð &ðN #Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð à $Ð $Ð $Ð $Ð $Ð $Ø BÐ BÐ BÐ BÐ BÐ BØ .Ð .Ð .Ð .Ð .Ð .Ø =Ð =Ð =Ð =Ð =Ð =ðd/ð d/ð d/ð d/ð d/˜ð d/ñ d/ô d/ð d/ðN	ð 	ð 	ð 	ð 	�7 gð 	ñ 	ô 	ð 	ð	ð 	ð 	ð 	ð 	˜¨Gð 	ñ 	ô 	ð 	ðð ð ð ð �<ñ ô ð ðð ð ð ð �\ñ ô ð ðð ð ð ð �\ñ ô ð ðð ð ð ð �Wñ ô ð ðð ð ð ð Ð(ñ ô ð ðð ð ð ð Ð#ñ ô ð ðð ð ð ð Ð%ñ ô ð ð ð r   