
    i-                    r    S r SSKJr  SSKJr  SSKJrJrJrJr  SSK	J
r
  \(       a  SSKJr   " S S 5      rg	)
ExecutionSpans    )annotations)datetime)overloadIterableIteratorTYPE_CHECKING   )ExecutionSpan)Figurec                     \ rS rSrSrSS jrSS jr\SS j5       r\SS j5       rSS jrSS jr	SS	 jr
SS
 jr\SS j5       r\SS j5       r\SS j5       r\SS j5       rSS jrS S!S jjr S"       S#S jjrSrg)$r      a8  A collection of timings for pub results.

This class is a list-like containing :class:`~.ExecutionSpan`\s, where each execution span
represents a time window of data collection, and contains a reference to exactly which of the
data were collected during the window.

.. code::python

    spans = sampler_job.result().metadata["execution"]["execution_spans"]

    for span in spans:
        print(span)

It is possible for distinct time windows to overlap. This is not because a QPU was performing
multiple executions at once, but is instead an artifact of certain classical processing
that may happen concurrently with quantum execution. The guarantee being made is that the
referenced data definitely occurred in the reported execution span, but not necessarily that
the limits of the time window are as tight as possible.
c                $    [        U5      U l        g N)list_spans)selfspanss     k/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/execution_span/execution_spans.py__init__ExecutionSpans.__init__/   s    5k    c                ,    [        U R                  5      $ r   )lenr   r   s    r   __len__ExecutionSpans.__len__2   s    4;;r   c                    g r    r   idxss     r   __getitem__ExecutionSpans.__getitem__5   s    7:r   c                    g r   r   r    s     r   r"   r#   8   s    HKr   c                   ^  [        U[        5      (       a  T R                  U   $ [        U[        5      (       a  [	        T R                  U   5      $ [	        U 4S jU 5       5      $ )Nc              3  B   >#    U  H  nTR                   U   v   M     g 7fr   r   ).0idxr   s     r   	<genexpr>-ExecutionSpans.__getitem__.<locals>.<genexpr>@   s     ?$3dkk#.$s   )
isinstanceintr   slicer   r    s   ` r   r"   r#   ;   sQ    dC  ;;t$$dE""!$++d"344?$???r   c                ,    [        U R                  5      $ r   )iterr   r   s    r   __iter__ExecutionSpans.__iter__B   s    DKK  r   c                4    S[        U R                  5       S3$ )NzExecutionSpans())reprr   r   s    r   __repr__ExecutionSpans.__repr__E   s     dkk!2 3155r   c                b    [        U[        5      =(       a    U R                  UR                  :H  $ r   )r,   r   r   )r   others     r   __eq__ExecutionSpans.__eq__H   s!    %0PT[[ELL5PPr   c                n    [        U  VVs1 s H  oR                    H  o"iM     M     snn5      $ s  snnf )zMWhich pubs, by index, have dependence on one or more execution spans present.)sortedpub_idxs)r   spanr)   s      r   r>   ExecutionSpans.pub_idxsK   s+     tEtt}}s}stEFFEs   1
c                &    [        S U  5       5      $ )z0The start time of the entire collection, in UTC.c              3  8   #    U  H  oR                   v   M     g 7fr   )startr(   r?   s     r   r*   'ExecutionSpans.start.<locals>.<genexpr>S   s     /$$::$   )minr   s    r   rC   ExecutionSpans.startP   s     /$///r   c                &    [        S U  5       5      $ )z/The stop time of the entire collection, in UTC.c              3  8   #    U  H  oR                   v   M     g 7fr   )stoprD   s     r   r*   &ExecutionSpans.stop.<locals>.<genexpr>X   s     .99rF   )maxr   s    r   rK   ExecutionSpans.stopU   s     ....r   c                P    U R                   U R                  -
  R                  5       $ )z2The total duration of this collection, in seconds.)rK   rC   total_secondsr   s    r   durationExecutionSpans.durationZ   s      		DJJ&5577r   c                .   ^ [        U4S jU  5       5      $ )zReturn a new set of spans where each one has been filtered to the specified pubs.

See also :meth:~.ExecutionSpan.filter_by_pub`.

Args:
    pub_idx: One or more pub indices to filter.
c              3  D   >#    U  H  oR                  T5      v   M     g 7fr   )filter_by_pub)r(   r?   pub_idxs     r   r*   /ExecutionSpans.filter_by_pub.<locals>.<genexpr>g   s     Kdd0099ds    )r   )r   rV   s    `r   rU   ExecutionSpans.filter_by_pub_   s     KdKKKr   c                b    U(       a  U O
[        U 5      nUR                  R                  5         U$ )a  Return the same execution spans, sorted.

Sorting is done by the :attr:`~.ExecutionSpan.start` timestamp of each execution span.

Args:
    inplace: Whether to sort this instance in place, or return a copy.

Returns:
    This instance if ``inplace``, a new instance otherwise, sorted.
)r   r   sort)r   inplaceobjs      r   rZ   ExecutionSpans.sorti   s%     d>$#7


r   Nc                    SSK Jn  U" XX1S9$ )a  Draw these execution spans.

.. note::
    To draw multiple sets of execution spans at once, for example coming from multiple
    jobs, consider calling :meth:`~qiskit_ibm_runtime.visualization.draw_execution_spans`
    directly.

Args:
    name: The name of this set of spans.
    normalize_y: Whether to display the y-axis units as a percentage of work
        complete, rather than cumulative shots completed.
    line_width: The thickness of line segments.

Returns:
    A plotly figure.
   )draw_execution_spans)normalize_y
line_widthnames)visualizationr`   )r   namera   rb   r`   s        r   drawExecutionSpans.drawx   s    ( 	9#j
 	
r   r'   )r   zIterable[ExecutionSpan])returnr-   )r!   r-   rh   r   )r!   zslice | list[int]rh   'ExecutionSpans')r!   zint | slice | list[int]rh   z ExecutionSpan | 'ExecutionSpans')rh   zIterator[ExecutionSpan])rh   str)r9   objectrh   bool)rh   z	list[int])rh   r   )rh   float)rV   zint | Iterable[int]rh   ri   )T)r[   rl   rh   ri   )NF   )re   rj   ra   rl   rb   r-   rh   PlotlyFigure)__name__
__module____qualname____firstlineno____doc__r   r   r   r"   r1   r6   r:   propertyr>   rC   rK   rQ   rU   rZ   rf   __static_attributes__r   r   r   r   r      s    ("  : :K K@!6Q G G 0 0 / / 8 8L  NO

-1
GJ
	
 
r   N)rt   
__future__r   r   typingr   r   r   r	   execution_spanr   plotly.graph_objectsr   ro   r   r   r   r   <module>r{      s+     "  > > );v
 v
r   