
    i                        S r SSKJr  SSKJrJr  SSKJr  SSKr	SSK
JrJr  \S\\4   r\\\4   r " S S5      r " S	 S
5      rg)zA class to store Neat results.    )annotations)IterableUnion)	ArrayLikeN)	PubResultDataBinNeatPubResultc                      \ rS rSrSrSS j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rSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)r	      a!  A class to store the PUB results of :class:`.~Neat`.

It allows performing mathematical operations (``+``, ``-``, ``*``, ``/``, ``abs``, and ``**``)
with other objects of type :class:`.~NeatPubResultLike` and with scalars.

.. code::python

    from qiskit_ibm_runtime.debug_tools import NeatPubResult

    res = NeatPubResult([[1, 2], [3, 4]])

    # this returns NeatPubResult([[3, 4], [5, 6]])
    res + 2

    # this returns NeatPubResult([[3, 8], [15, 24]])
    res * (res + 2)

Args:
    vals: The values in this :class:`.~NeatPubResult`.
c                @    [         R                  " U[        S9U l        g )N)dtype)nparrayfloat_vals)selfvalss     e/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/debug_tools/neat_results.py__init__NeatPubResult.__init__2   s    XXd%0
    c                    U R                   $ )zThe values in this result.r   r   s    r   r   NeatPubResult.vals5   s     zzr   c                   [        U[        [        45      (       d  [        U[        5      (       a  UR                  nOk[        U[
        5      (       a  UR                  R                  nO?[        U[        5      (       a   UR                  nO[        SU SUR                   S35      e[        [        U R                  U 5      " U5      5      $ ! [         a    [        SU S35      ef = f)z]
Coerces ``other`` to a compatible format and applies ``op_name`` to ``self`` and ``other``.
zCannot apply operator 'zF' between 'NeatPubResult' and 'DataBin' that has no attribute ``evs``.z*' to objects of type 'NeatPubResult' and 'z'.)
isinstanceintr   r	   r   r   dataevsr   AttributeError
ValueError	__class__getattr)r   otherop_names      r   _coerced_operation NeatPubResult._coerced_operation:   s     %#u..%//

E9--

E7++!IIE !-gY 7(,  WTYY7)=eDEE & $1' ;: : s    C C)c                T    [        [        R                  " U R                  5      5      $ N)r	   r   absr   r   s    r   __abs__NeatPubResult.__abs__T   s    RVVDII.//r   c                &    U R                  US5      $ )N__add__r'   r   r%   s     r   r/   NeatPubResult.__add__W       &&ui88r   c                &    U R                  US5      $ )N__mul__r0   r1   s     r   r5   NeatPubResult.__mul__Z   r3   r   c                &    U R                  US5      $ )N__sub__r0   r1   s     r   r8   NeatPubResult.__sub__]   r3   r   c                &    U R                  US5      $ )N__truediv__r0   r1   s     r   r;   NeatPubResult.__truediv__`   s    &&um<<r   c                &    U R                  US5      $ )N__radd__r0   r1   s     r   r>   NeatPubResult.__radd__c       &&uj99r   c                &    U R                  US5      $ )N__rmul__r0   r1   s     r   rB   NeatPubResult.__rmul__f   r@   r   c                &    U R                  US5      $ )N__rsub__r0   r1   s     r   rE   NeatPubResult.__rsub__i   r@   r   c                &    U R                  US5      $ )N__rtruediv__r0   r1   s     r   rH   NeatPubResult.__rtruediv__l   s    &&un==r   c                2    [        U R                  U-  5      $ r*   )r	   r   )r   ps     r   __pow__NeatPubResult.__pow__o   s    TZZ]++r   c                4    S[        U R                  5       S3$ )NzNeatPubResult(vals=))reprr   r   s    r   __repr__NeatPubResult.__repr__r   s    $T$))_$5Q77r   r   N)r   r   returnNone)rS   z
np.ndarray)r%   $Union[ScalarLike, NeatPubResultLike]r&   strrS   r	   )rS   r	   )r%   rU   rS   r	   )rK   
ScalarLikerS   r	   rS   rV   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r'   r,   r/   r5   r8   r;   r>   rB   rE   rH   rL   rQ   __static_attributes__ r   r   r	   r	      sx    *1  F9FDGF	F40999=:::>,8r   c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)
NeatResultv   zA container for multiple :class:`~.NeatPubResult` objects.

Args:
    pub_results: An iterable of :class:`~.NeatPubResult` objects.
c                $    [        U5      U l        g r*   )list_pub_results)r   pub_resultss     r   r   NeatResult.__init__}   s     -r   c                     U R                   U   $ r*   rf   )r   indexs     r   __getitem__NeatResult.__getitem__   s      ''r   c                ,    [        U R                  5      $ r*   )lenrf   r   s    r   __len__NeatResult.__len__   s    4$$%%r   c                "    SU R                    S3$ )NzNeatResult(rO   rj   r   s    r   rQ   NeatResult.__repr__   s    T../q11r   c                ,    [        U R                  5      $ r*   )iterrf   r   s    r   __iter__NeatResult.__iter__   s    D%%&&r   rj   N)rg   Iterable[NeatPubResult]rS   rT   )rk   r   rS   r	   )rS   r   rX   )rS   rx   )rY   rZ   r[   r\   r]   r   rl   rp   rQ   rv   r_   r`   r   r   rb   rb   v   s     .(&2'r   rb   )r]   
__future__r   typingr   r   numpy.typingr   numpyr   qiskit.primitives.containersr   r   NeatPubResultLiker   r   rW   r	   rb   r`   r   r   <module>r      sR    % " " "  ; /9g=> 3:
W8 W8t' 'r   