§
    ¹³Ùg  ã                  óÄ   — d Z ddlmZ ddlmZ ddlmZmZmZ ddl	Z
ddlmZmZ eedf         Z	 e G d„ d	e¦  «        ¦   «         Z G d
„ de¦  «        Zdd„Zdd„Zdd„ZdS )z+
Array shape related classes and functions
é    )Úannotations)ÚIterable)ÚProtocolÚUnionÚruntime_checkableN)Ú	ArrayLikeÚNDArrayzIterable[ShapeInput]c                  óZ   — e Zd ZdZed	d„¦   «         Zed
d„¦   «         Zed
d„¦   «         ZdS )ÚShapeda%  Protocol that defines what it means to be a shaped object.

    Note that static type checkers will classify ``numpy.ndarray`` as being :class:`Shaped`.
    Moreover, since this protocol is runtime-checkable, we will even have
    ``isinstance(<numpy.ndarray instance>, Shaped) == True``.
    Úreturnútuple[int, ...]c                ó    — t          d¦  «        ‚)zThe array shape of this object.z7A `Shaped` protocol must implement the `shape` property©ÚNotImplementedError©Úselfs    úX/granary/edev/quantum/lib/python3.11/site-packages/qiskit/primitives/containers/shape.pyÚshapezShaped.shape%   s   € õ "Ð"[Ñ\Ô\Ð\ó    Úintc                ó    — t          d¦  «        ‚)z.The number of array dimensions of this object.z6A `Shaped` protocol must implement the `ndim` propertyr   r   s    r   ÚndimzShaped.ndim*   ó   € õ "Ð"ZÑ[Ô[Ð[r   c                ó    — t          d¦  «        ‚)zVThe total dimension of this object, i.e. the product of the entries of :attr:`~shape`.z6A `Shaped` protocol must implement the `size` propertyr   r   s    r   ÚsizezShaped.size/   r   r   N)r   r   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r   © r   r   r   r      sŒ   € € € € € ðð ð ð]ð ]ð ]ñ „Xð]ð ð\ð \ð \ñ „Xð\ð ð\ð \ð \ñ „Xð\ð \ð \r   r   c                  óf   — e Zd ZU dZded<   d„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	dS )	ÚShapedMixinzXMixin class to create :class:`~Shaped` types by only providing :attr:`_shape` attribute.r   Ú_shapec                ó@   — t          | ¦  «        j        › d| j        › d�S )Nz(<z>))Útyper   r   r   s    r   Ú__repr__zShapedMixin.__repr__:   s$   € Ý�t‘*”*Ô%Ð7Ð7¨¬Ð7Ð7Ð7Ð7r   c                ó   — | j         S ©N)r$   r   s    r   r   zShapedMixin.shape=   s
   € àŒ{Ðr   c                ó*   — t          | j        ¦  «        S r)   )Úlenr$   r   s    r   r   zShapedMixin.ndimA   s   € å�4”;ÑÔÐr   c                ó\   — t          t          j        | j        t           ¬¦  «        ¦  «        S )N)Údtype)r   ÚnpÚprodr$   r   s    r   r   zShapedMixin.sizeE   s!   € å•2”7˜4œ;­cÐ2Ñ2Ô2Ñ3Ô3Ð3r   N)
r   r   r   r   Ú__annotations__r'   r    r   r   r   r!   r   r   r#   r#   5   sˆ   € € € € € € ØbÐbàÐÐÑð8ð 8ð 8ð ðð ñ „Xðð ð ð  ñ „Xð ð ð4ð 4ñ „Xð4ð 4ð 4r   r#   ÚarrúArrayLike | Shapedr   úNDArray | Shapedc                óX   — t          | t          ¦  «        r| S t          j        | ¦  «        S )a  Coerce the input into an object with a shape attribute.

    Copies are avoided.

    Args:
        arr: The object to coerce.

    Returns:
        Something that is :class:`~Shaped`, and always ``numpy.ndarray`` if the input is not
        already :class:`~Shaped`.
    )Ú
isinstancer   r.   Úasarray)r1   s    r   Úarray_coercer7   J   s)   € õ �#•vÑÔð Øˆ
ÝŒ:�c‰?Œ?Ðr   ÚargÚ
ShapeInputúIterable[int]c              #  ó6  K  — | D ]“}	 t          |t          ¦  «        rt          |¦  «        E d{V —† n8t          |¦  «        |k    rt          |¦  «        V — nt	          d|› d�¦  «        ‚Œg# t
          t          f$ r}t	          d|› d�¦  «        |‚d}~ww xY wdS )a  
    Yield one integer at a time.

    Args:
        arg: Integers or iterables of integers, possibly nested, to be yielded.

    Yields:
        The provided integers in depth-first recursive order.

    Raises:
        ValueError: If an input is not an iterable or an integer.
    Nz	Expected z to be iterable or an integer.)r5   r   Ú_flatten_to_intsr   Ú
ValueErrorÚ	TypeErrorÚRecursionError)r8   ÚitemÚexs      r   r<   r<   [   sã   è è € ð ð 	Wð 	Wˆð	WÝ˜$¥Ñ)Ô)ð SÝ+¨DÑ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ð1Ý�T‘”˜dÒ"Ð"Ý˜$‘i”i����å Ð!Q¨TÐ!QÐ!QÐ!QÑRÔRÐRøøÝ�>Ð*ð 	Wð 	Wð 	WÝÐM¨ÐMÐMÐMÑNÔNÐTVÐVøøøøð	Wøøøð	Wð 	Ws   ˆA#A,Á,BÁ=BÂBÚshapesr   c                 ó:   — t          t          | ¦  «        ¦  «        S )a%  
    Flatten the input into a single tuple of integers, preserving order.

    Args:
        shapes: Integers or iterables of integers, possibly nested.

    Returns:
        A tuple of integers.

    Raises:
        ValueError: If some member of ``shapes`` is not an integer or iterable.
    )Útupler<   )rB   s    r   Úshape_tuplerE   t   s   € õ Õ! &Ñ)Ô)Ñ*Ô*Ð*r   )r1   r2   r   r3   )r8   r9   r   r:   )rB   r9   r   r   )r   Ú
__future__r   Úcollections.abcr   Útypingr   r   r   Únumpyr.   Únumpy.typingr   r	   r   r9   r   r#   r7   r<   rE   r!   r   r   ú<module>rK      s=  ððð ð #Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5à Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +à�3Ð.Ð.Ô/€
Ø 4ð ð\ð \ð \ð \ð \ˆXñ \ô \ñ Ôð\ð04ð 4ð 4ð 4ð 4�&ñ 4ô 4ð 4ð*ð ð ð ð"Wð Wð Wð Wð2+ð +ð +ð +ð +ð +r   