
    z	i                     n    S r SSKJr  SSKJr  SSKJrJrJr  SSK	J
r
  SSKJr  SSKJr   " S	 S
\5      rg)z0Padding pass to insert Delay to the empty slots.    )Qubit)Delay)
DAGCircuitDAGNode
DAGOutNode)Target)InstructionDurations   )BasePaddingc                   h   ^  \ rS rSrSr   SS\S\S\4U 4S jjjrS\	S\
S	\S
\S\S\4S jrSrU =r$ )PadDelay   u/  Padding idle time with Delay instructions.

Consecutive delays will be merged in the output of this pass.

.. plot::
   :include-source:
   :nofigs:

    from qiskit import QuantumCircuit
    from qiskit.transpiler import InstructionDurations

    durations = InstructionDurations([("x", None, 160), ("cx", None, 800)])

    qc = QuantumCircuit(2)
    qc.delay(100, 0)
    qc.x(1)
    qc.cx(0, 1)

The ASAP-scheduled circuit output may become

.. code-block:: text

         ┌────────────────┐
    q_0: ┤ Delay(160[dt]) ├──■──
         └─────┬───┬──────┘┌─┴─┐
    q_1: ──────┤ X ├───────┤ X ├
               └───┘       └───┘

Note that the additional idle time of 60dt on the ``q_0`` wire coming from the duration difference
between ``Delay`` of 100dt (``q_0``) and ``XGate`` of 160 dt (``q_1``) is absorbed in
the delay instruction on the ``q_0`` wire, i.e. in total 160 dt.

See :class:`BasePadding` pass for details.
fill_very_endtarget	durationsc                 ,   > [         TU ]  X#S9  Xl        g)a;  Create new padding delay pass.

Args:
    fill_very_end: Set ``True`` to fill the end of circuit with delay.
    target: The :class:`~.Target` representing the target backend.
        If it is supplied and does not support delay instruction on a qubit,
        padding passes do not pad any idle time of the qubit.
)r   r   N)super__init__r   )selfr   r   r   	__class__s       o/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/scheduling/padding/pad_delay.pyr   PadDelay.__init__<   s     	<*    dagqubitt_startt_end	next_node	prev_nodec                     U R                   (       d  [        U[        5      (       a  g XC-
  nU R                  X[	        XqR
                  5      U5        g )N)r   
isinstancer   _apply_scheduled_opr   _unit)r   r   r   r   r   r   r   time_intervals           r   _padPadDelay._padM   s?     !!jJ&G&G  u]II/NPUVr   )r   )TNN)__name__
__module____qualname____firstlineno____doc__boolr   r	   r   r   r   intr   r%   __static_attributes____classcell__)r   s   @r   r   r      s    !J #*.	++ + (	+ +"WW W 	W
 W W W Wr   r   N)r+   qiskit.circuitr   qiskit.circuit.delayr   qiskit.dagcircuitr   r   r   qiskit.transpiler.targetr   'qiskit.transpiler.instruction_durationsr	   base_paddingr   r    r   r   <module>r7      s/    7   & = = + H %BW{ BWr   