§
    ¹³ÙgÂ  ã            	      óî   — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
ZddlmZ dd	lmZmZ dd
lmZmZ ddlmZ dgZ G d„ de¦  «        Ze	eeeef         eeeef         eeeeef         f         ZdS )z
Estimator Pub class
é    )Úannotations)ÚReal)ÚMapping)ÚTupleÚUnionN)ÚQuantumCircuité   )ÚBindingsArrayÚBindingsArrayLike)ÚObservablesArrayÚObservablesArrayLike)ÚShapedMixinÚEstimatorPubLikec                  ó°   ‡ — e Zd ZdZdZ	 	 	 ddˆ fd„Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Z	edd„¦   «         Z
ed d!d„¦   «         Zd„ Zˆ xZS )"ÚEstimatorPubaG  Primitive Unified Bloc for any Estimator primitive.

    An estimator pub is essentially a tuple ``(circuit, observables, parameter_values, precision)``.

    If precision is provided this should be used for the target precision of an
    estimator, if ``precision=None`` the estimator will determine the target precision.
    )Ú_circuitÚ_observablesÚ_parameter_valuesÚ
_precisionÚ_shapeNTÚcircuitr   Úobservablesr   Úparameter_valuesúBindingsArray | NoneÚ	precisionúfloat | NoneÚvalidateÚboolc                ó¦  •— t          ¦   «                              ¦   «          || _        || _        |pt	          ¦   «         | _        || _        	 t          j        | j	        j
        | j        j
        ¦  «        | _        n=# t          $ r0}t          d| j	        j
        › d| j        j
        › d�¦  «        |‚d}~ww xY w|r|                      ¦   «          dS dS )a@  Initialize an estimator pub.

        Args:
            circuit: A quantum circuit.
            observables: An observables array.
            parameter_values: A bindings array, if the circuit is parametric.
            precision: An optional target precision for expectation value estimates.
            validate: Whether to validate arguments during initialization.

        Raises:
            ValueError: If the ``observables`` and ``parameter_values`` are not broadcastable, that
                is, if their shapes, when right-aligned, do not agree or equal 1.
        zThe observables shape z  and the parameter values shape z are not broadcastable.N)ÚsuperÚ__init__r   r   r
   r   r   ÚnpÚbroadcast_shapesr   Úshaper   r   Ú
ValueErrorr   )Úselfr   r   r   r   r   ÚexÚ	__class__s          €ú`/granary/edev/quantum/lib/python3.11/site-packages/qiskit/primitives/containers/estimator_pub.pyr!   zEstimatorPub.__init__/   sù   ø€ õ* 	‰Œ×ÒÑÔÐØˆŒØ'ˆÔØ!1Ð!Dµ]±_´_ˆÔØ#ˆŒð	åÔ-¨dÔ.>Ô.DÀdÔF[ÔFaÑbÔbˆDŒKˆKøÝð 	ð 	ð 	Ýð_¨Ô)9Ô)?ð _ð _Ø*.Ô*?Ô*Eð_ð _ð _ñô ð ðøøøøð	øøøð ð 	Ø�MŠM‰OŒOˆOˆOˆOð	ð 	s   Á.A< Á<
B6Â+B1Â1B6Úreturnc                ó   — | j         S )zA quantum circuit.)r   ©r&   s    r)   r   zEstimatorPub.circuitW   s   € ð Œ}Ðó    c                ó   — | j         S )zAn observables array.)r   r,   s    r)   r   zEstimatorPub.observables\   s   € ð Ô Ð r-   r
   c                ó   — | j         S )zA bindings array.)r   r,   s    r)   r   zEstimatorPub.parameter_valuesa   s   € ð Ô%Ð%r-   c                ó   — | j         S )z@The target precision for expectation value estimates (optional).)r   r,   s    r)   r   zEstimatorPub.precisionf   s   € ð ŒÐr-   Úpubr   c                óf  — |�Jt          |t          ¦  «        s t          dt          |¦  «        › d�¦  «        ‚|dk     rt	          d¦  «        ‚t          |t
          ¦  «        r*|j        €!|� | |j        |j        |j	        |d¬¦  «        S |S t          |t          ¦  «        r t	          dt          |¦  «        › d	�¦  «        ‚t          |¦  «        d
vr t	          dt          |¦  «        › d�¦  «        ‚|d         }t          j        |d         ¦  «        }t          |¦  «        dk    rW|d         �O|d         }t          |t          t          f¦  «        st!          |j        ¦  «        |i}t          j        |¦  «        }nd}t          |¦  «        dk    r|d         �|d         } | ||||d¬¦  «        S )a?  Coerce :class:`~.EstimatorPubLike` into :class:`~.EstimatorPub`.

        Args:
            pub: A compatible object for coercion.
            precision: an optional default precision to use if not
                       already specified by the pub-like object.

        Returns:
            An estimator pub.
        Nú%precision must be a real number, not ú.r   zprecision must be non-negativeF)r   r   r   r   r   z)An invalid Estimator pub-like was given (zÀ). If you want to run a single pub, you need to wrap it with `[]` like `estimator.run([(circuit, observables, param_values)])` instead of `estimator.run((circuit, observables, param_values))`.)é   é   é   z0The length of pub must be 2, 3 or 4, but length z
 is given.r	   r5   r6   T)Ú
isinstancer   Ú	TypeErrorÚtyper%   r   r   r   r   r   r   Úlenr   Úcoercer
   r   ÚtupleÚ
parameters)Úclsr1   r   r   r   Úvaluesr   s          r)   r<   zEstimatorPub.coercek   sö  € ð Ð Ý˜i­Ñ.Ô.ð \ÝÐ ZÍÈYÉÌÐ ZÐ ZÐ ZÑ[Ô[Ð[Ø˜1Š}ˆ}Ý Ð!AÑBÔBÐBÝ�c�<Ñ(Ô(ð 		ØŒ}Ð$¨Ð)>Ø�sØœKØ #¤Ø%(Ô%9Ø'Ø"ðñ ô ð ð ˆJå�c�>Ñ*Ô*ð 	ÝðT½DÀ¹I¼Ið Tð Tð Tñô ð õ ˆs‰8Œ8˜9Ð$Ð$ÝØWÅ3ÀsÁ8Ä8ÐWÐWÐWñô ð ð �a”&ˆÝ&Ô-¨c°!¬fÑ5Ô5ˆåˆs‰8Œ8�aŠ<ˆ<˜C œFÐ.Ø˜”VˆFÝ˜f¥}µgÐ&>Ñ?Ô?ð =Ý Ô 2Ñ3Ô3°VÐ<�Ý,Ô3°FÑ;Ô;ÐÐà#Ðåˆs‰8Œ8�aŠ<ˆ<˜C œFÐ.Ø˜AœˆIàˆsØØ#Ø-ØØð
ñ 
ô 
ð 	
r-   c           
     óê  — t          | j        t          ¦  «        st          d¦  «        ‚| j                             ¦   «          | j                             ¦   «          | j        �Yt          | j        t          ¦  «        s%t          dt          | j        ¦  «        › d�¦  «        ‚| j        dk     rt          d¦  «        ‚t          j        | j        ¦  «        D ]a\  }}t          t          t          |¦  «        ¦  «        ¦  «        }| j        j        |k    r#t          d| j        j        › d|› d	|› d
�¦  «        ‚Œb| j        j        }|| j        j        k    r t          d|› d| j        j        › d�¦  «        ‚dS )zValidate the pub.zcircuit must be QuantumCircuit.Nr3   r4   r   zprecision must be non-negative.z%The number of qubits of the circuit (z-) does not match the number of qubits of the z-th observable (z).zThe number of values (z+) does not match the number of parameters (z) for the circuit.)r8   r   r   r9   r   r   r   r   r   r:   r%   r"   Úndenumerater;   ÚnextÚiterÚ
num_qubitsÚnum_parameters)r&   ÚiÚ
observablerE   rF   s        r)   r   zEstimatorPub.validateª   s´  € å˜$œ,­Ñ7Ô7ð 	?ÝÐ=Ñ>Ô>Ð>àÔ×!Ò!Ñ#Ô#Ð#ØÔ×&Ò&Ñ(Ô(Ð(àŒ>Ð%Ý˜dœn­dÑ3Ô3ð aÝÐ _ÍÈTÌ^ÑH\ÔH\Ð _Ð _Ð _Ñ`Ô`Ð`ØŒ~ Ò!Ð!Ý Ð!BÑCÔCÐCõ  œ^¨DÔ,<Ñ=Ô=ð 	ð 	‰MˆAˆzÝ�T¥$ zÑ"2Ô"2Ñ3Ô3Ñ4Ô4ˆJØŒ|Ô&¨*Ò4Ð4Ý ð_¸D¼LÔ<Sð _ð _Ø=>ð_ð _ØPZð_ð _ð _ñô ð ð 5ð Ô.Ô=ˆØ˜Tœ\Ô8Ò8Ð8Ýð]¨ð ]ð ]Ø-1¬\Ô-Hð]ð ]ð ]ñô ð ð 9Ð8r-   )NNT)
r   r   r   r   r   r   r   r   r   r   )r*   r   )r*   r   )r*   r
   )r*   r   )N)r1   r   r   r   r*   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r!   Úpropertyr   r   r   r   Úclassmethodr<   r   Ú__classcell__)r(   s   @r)   r   r   $   s  ø€ € € € € ðð ð Z€Ið 26Ø"&Øð&ð &ð &ð &ð &ð &ð &ðP ðð ð ñ „Xðð ð!ð !ð !ñ „Xð!ð ð&ð &ð &ñ „Xð&ð ðð ð ñ „Xðð ð<
ð <
ð <
ð <
ñ „[ð<
ð|ð ð ð ð ð ð r-   r   )rL   Ú
__future__r   Únumbersr   Úcollections.abcr   Útypingr   r   Únumpyr"   Úqiskitr   Úbindings_arrayr
   r   Úobservables_arrayr   r   r$   r   Ú__all__r   r   © r-   r)   ú<module>r[      sN  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ð Ð à Ð Ð Ð à !Ð !Ð !Ð !Ð !Ð !à <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ Ð Ð Ð Ð Ð ð Ð
€ðcð cð cð cð c�;ñ cô cð cðL ØØ	ˆ.Ð.Ð
.Ô/Ø	ˆ.Ð.Ð0AÐ
AÔBØ	ˆ.Ð.Ð0AÀ4Ð
GÔHðJôÐ ðð r-   