
    z	i                        S r SSKJr  SSKJrJrJrJrJr  SSK	r
SSKJrJrJr  SS jr " S S	\5      r S     SS
 jjrg)z,
Dataclass tools for data namespaces (bins)
    )annotations)Any	ItemsViewIterableKeysView
ValuesViewN   )ShapedMixin
ShapeInputshape_tuplec                    [        U [        R                  5      (       a  SU R                   SU R                   S3$ [        U 5      $ )z-Helper function for :meth:`DataBin.__repr__`.znp.ndarray(<shape=z, dtype=z>))
isinstancenpndarrayshapedtyperepr)values    _/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/primitives/containers/data_bin.py_value_reprr      s:    %$$#EKK=RHH;    c                     ^  \ rS rSrSrSr\" 1 Sk5      rSS.SU 4S jjj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S jr\SS j5       r\SS j5       r\SS j5       rSrU =r$ )DataBin    a  Namespace for storing data.

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

    import numpy as np
    from qiskit.primitives import DataBin, BitArray

    data = DataBin(
        alpha=BitArray.from_samples(["0010"]),
        beta=np.array([1.2])
    )

    print("alpha data:", data.alpha)
    print("beta data:", data.beta)

.. code-block::

    alpha data: BitArray(<shape=(), num_shots=1, num_bits=2>)
    beta data: [1.2]

)_data_shape>   keysndimsizer   itemsr   _SHAPEr   values_FIELDS_FIELD_TYPES_RESTRICTED_NAMES r   c                 > U R                   R                  U5      (       d2  [        U R                   R                  U5      5      n[	        SU 35      e[
        TU ]  nU" S[        U5      5        U" SU5        [        U R                  5      nUR                  5        H3  u  pg[        USU5      SU U:w  a  [	        SU SU S35      eU" Xg5        M5     [
        TU ]1  5         g)	av  
Args:
    data: Name/value data to place in the data bin.
    shape: The leading shape common to all entries in the data bin. This defaults to
        the trivial leading shape of ``()`` that is compatible with all objects.

Raises:
    ValueError: If a name overlaps with a method name on this class.
    ValueError: If some value is inconsistent with the provided shape.
z&Cannot assign with these field names: r   r   r   NzThe value of 'z' does not lead with the shape .)r%   
isdisjointsortedintersection
ValueErrorsuper__setattr__r   lenr   r    getattr__init__)	selfr   data	bad_names_setattrr   namer   	__class__s	           r   r2   DataBin.__init__L   s     %%0066t55BB4HIIEi[QRR7&;u-.$4;;::<KDugu-et4= >$7VW\V]]^!_``T! (
 	r   c                ,    [        U R                  5      $ N)r0   r   r3   s    r   __len__DataBin.__len__g   s    4::r   c           	     $   U R                  5        VVs/ s H  u  pU S[        U5       3PM     nnnU R                  (       a  UR                  SU R                   35        [        U 5      R                   SSR                  U5       S3$ s  snnf )N=zshape=(z, ))r    r   r   appendr   type__name__join)r3   r7   valvalss       r   __repr__DataBin.__repr__j   sz    >BjjlKl4&+c*+,lK99KK&-.t*%%&a		$'8:: Ls   Bc                f     U R                   U   $ ! [         a  n[        SU S35      UeS nAff = f)NzKey (z") does not exist in this data bin.)r   KeyError)r3   keyexs      r   __getitem__DataBin.__getitem__p   s@    	T::c?" 	TU3%'IJKQSS	Ts    
0+0c                    XR                   ;   $ r;   )r   )r3   rM   s     r   __contains__DataBin.__contains__v   s    jj  r   c                ,    [        U R                  5      $ r;   )iterr   r<   s    r   __iter__DataBin.__iter__y   s    DJJr   c                6    U R                   R                  5       $ )zReturn a view of field names.)r   r   r<   s    r   r   DataBin.keys|   s    zz  r   c                6    U R                   R                  5       $ )zReturn a view of values.)r   r"   r<   s    r   r"   DataBin.values   s    zz  ""r   c                6    U R                   R                  5       $ )z'Return a view of field names and values)r   r    r<   s    r   r    DataBin.items   s    zz!!r   c                ,    [        U R                  5      $ r;   )tupler   r<   s    r   r#   DataBin._FIELDS   s    TZZ  r   c                P    [        [        [        U R                  5       5      5      $ r;   )r_   maprD   r"   r<   s    r   r$   DataBin._FIELD_TYPES   s    St{{}-..r   c                    U R                   $ r;   r'   r<   s    r   r!   DataBin._SHAPE   s    zzr   )r   r   )rM   strreturnr   )rM   rf   rg   bool)rg   zIterable[str])rg   zKeysView[str])rg   zValuesView[Any])rg   zItemsView[str, Any])rg   ztuple[str, ...])rg   ztuple[Any, ...])rg   ztuple[int, ...])rE   
__module____qualname____firstlineno____doc__	__slots__	frozensetr%   r2   r=   rI   rO   rR   rV   r   r"   r    propertyr#   r$   r!   __static_attributes____classcell__)r8   s   @r   r   r       s    0 $I!	
" /1  6;T! !#" ! ! / /  r   r   c                    [         $ )a/  Return the :class:`~DataBin` type.

.. note::
    This class used to return a subclass of :class:`~DataBin`. However, that caused confusion
    and didn't have a useful purpose. Several internal projects made use of this internal
    function prior to qiskit 1.1. This function will be removed once these internal projects
    have made the appropriate changes.

Args:
    fields: Tuples ``(name, type)`` specifying the attributes of the returned class.
    shape: The intended shape of every attribute of this class.

Returns:
    The :class:`DataBin` type.
)r   )fieldsr   s     r   make_data_binrt      s	    $ Nr   )r   r   rg   rf   r;   )rs   zIterable[tuple[str, type]]r   ztuple[int, ...] | Nonerg   ztype[DataBin])rl   
__future__r   typingr   r   r   r   r   numpyr   r   r
   r   r   r   r   rt   r&   r   r   <module>rx      sV    # A A  7 7vk vv IM&/Er   