
    i                        S r SSKJr  SSKrSSKJr  SSKJrJr  SSKr	SSK
Jr  \\S4   r  " S S \R                  5      rg)ExecutionSpan    )annotationsN)datetime)IterableTuple.c                  :   \ rS rSrSrSS jr\R                  SS j5       rSS jr	SS jr
\SS j5       r\\R                  SS j5       5       r\SS	 j5       r\SS
 j5       r\SS j5       r\R                  SS j5       rSS jr\R                  SS j5       rSrg)r      a  Abstract parent for classes that store an execution time span for a subset of job data.

A pub is said to have dependence on an execution span if the corresponding execution includes
data that forms any part of the pub's results.

Execution spans are equality checkable, and they implement a comparison operator based on
the tuple ``(start, stop)``, so can be sorted.

Args:
    start: The start time of the span, in UTC.
    stop: The stop time of the span, in UTC.
c                    Xl         X l        g N_start_stop)selfstartstops      j/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/execution_span/execution_span.py__init__ExecutionSpan.__init__-   s    
    c                    g r    r   others     r   __eq__ExecutionSpan.__eq__1   s    r   c                d    U R                   U R                  4UR                   UR                  4:  $ r   )r   r   r   s     r   __lt__ExecutionSpan.__lt__5   s'    

DII&%++uzz)BBBr   c                    SU R                   S S3SU R                  S S3SU R                   3/n[        U 5      R                   SSR                  U5       S3$ )	Nzstart='z%Y-%m-%d %H:%M:%S'zstop='zsize=z(<z, z>))r   r   sizetype__name__join)r   attrss     r   __repr__ExecutionSpan.__repr__8   si    djj!2315TYY013DII;

 t*%%&b5)9(:"==r   c                P    U R                   U R                  -
  R                  5       $ )z&The duration of this span, in seconds.)r   r   total_secondsr   s    r   durationExecutionSpan.duration@   s      		DJJ&5577r   c                    g)z=Which pubs, by index, have dependence on this execution span.Nr   r*   s    r   pub_idxsExecutionSpan.pub_idxsE       r   c                    U R                   $ )z#The start time of the span, in UTC.)r   r*   s    r   r   ExecutionSpan.startJ   s     {{r   c                    U R                   $ )z"The stop time of the span, in UTC.)r   r*   s    r   r   ExecutionSpan.stopO   s     zzr   c                B   ^  [        U 4S jT R                   5       5      $ )a  The total number of results with dependence on this execution span, across all pubs.

This attribute is equivalent to the sum of the elements of all present :meth:`mask`\s.
For sampler results, it represents the total number of shots with dependence on this
execution span.

Combine this attribute with :meth:`filter_by_pub` to find the size of some particular pub:

.. code:: python

    span.filter_by_pub(2).size

c              3  b   >#    U  H$  nTR                  U5      R                  5       v   M&     g 7fr   )masksum).0pub_idxr   s     r   	<genexpr>%ExecutionSpan.size.<locals>.<genexpr>c   s&     I=499W%))++=s   ,/)r8   r.   r*   s   `r   r!   ExecutionSpan.sizeT   s     I4==IIIr   c                    g)a  Return an array-valued mask specifying which parts of a pub result depend on this span.

Args:
    pub_idx: The index of the pub to return a mask for.

Returns:
    An array with the same shape as the pub data.

Raises:
    KeyError: if the pub is not included in the span
Nr   r   r:   s     r   r7   ExecutionSpan.maske   r0   r   c                    [        U[        5      (       a  U1O
[        U5      nUR                  U R                  5      (       + $ )zReturn whether the pub with the given index has data with dependence on this span.

Args:
    pub_idx: One or more pub indices from the original primitive call.

Returns:
    Whether there is dependence on this span.
)
isinstanceintset
isdisjointr.   r?   s     r   contains_pubExecutionSpan.contains_pubs   s5      *'3777)S\%%dmm444r   c                    g)a  Return a new span whose slices are filtered to the provided pub indices.

For example, if this span contains slice information for pubs with indices 1, 3, 4 and
``[1, 4]`` is provided, then the span returned by this method will contain slice information
for only those two indices, but be identical otherwise.

Args:
    pub_idx: One or more pub indices from the original primitive call.

Returns:
    A new filtered span.
Nr   r?   s     r   filter_by_pubExecutionSpan.filter_by_pub   r0   r   r   N)r   r   r   r   )r   objectreturnbool)r   r   rL   rM   )rL   str)rL   float)rL   z	list[int])rL   r   )rL   rC   )r:   rC   rL   znpt.NDArray[np.bool_])r:   int | Iterable[int]rL   rM   )r:   rP   rL   z'ExecutionSpan')r#   
__module____qualname____firstlineno____doc__r   abcabstractmethodr   r   r&   propertyr+   r.   r   r   r!   r7   rF   rI   __static_attributes__r   r   r   r   r      s     	 C> 8 8 L  L     J J  	 
5 	 r   )rT   
__future__r   rU   r   typingr   r   numpynpnumpy.typingnptrC   	ShapeTypeABCr   r   r   r   <module>ra      s@     " 
  "  
 #s(O	 5mCGG mr   