
    z	i              	          S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
rSSKJr  SS	KJrJr  SS
KJrJr  SSKJr  S/r " S S\5      r\	\\\\4   \\\\4   \\\\\4   4   rg)z
Estimator Pub class
    )annotations)Real)Mapping)TupleUnionN)QuantumCircuit   )BindingsArrayBindingsArrayLike)ObservablesArrayObservablesArrayLike)ShapedMixinEstimatorPubLikec                     ^  \ rS rSrSrSr   S         SU 4S jjjr\SS j5       r\SS j5       r	\SS j5       r
\SS j5       r\SSS	 jj5       rS
 rSrU =r$ )EstimatorPub$   a7  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_shapec                  > [         TU ]  5         Xl        X l        U=(       d
    [	        5       U l        X@l         [        R                  " U R                  R                  U R                  R                  5      U l        U(       a  U R                  5         gg! [         a@  n[        SU R                  R                   SU R                  R                   S35      UeSnAff = f)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_shapesobservablesshapeparameter_valuesr   
ValueErrorvalidate)selfcircuitr   r   	precisionr!   ex	__class__s          d/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/primitives/containers/estimator_pub.pyr   EstimatorPub.__init__/   s    * 	'!1!D]_#	--d.>.>.D.DdF[F[FaFabDK MMO   	()9)9)?)?(@ A**.*?*?*E*E)FF]_ 	s   AB 
C"";CC"c                    U R                   $ )zA quantum circuit.)r   r"   s    r'   r#   EstimatorPub.circuitW   s     }}    c                    U R                   $ )zAn observables array.)r   r*   s    r'   r   EstimatorPub.observables\   s        r,   c                    U R                   $ )zA bindings array.)r   r*   s    r'   r   EstimatorPub.parameter_valuesa   s     %%%r,   c                    U R                   $ )z@The target precision for expectation value estimates (optional).)r   r*   s    r'   r$   EstimatorPub.precisionf   s     r,   c                   Ub>  [        U[        5      (       d  [        S[        U5       S35      eUS:  a  [	        S5      e[        U[
        5      (       a:  UR                  c+  Ub(  U " UR                  UR                  UR                  USS9$ U$ [        U[        5      (       a  [	        S[        U5       S	35      e[        U5      S
;  a  [	        S[        U5       S35      eUS   n[        R                  " US   5      n[        U5      S:  aT  US   bN  US   n[        U[        [        45      (       d  [!        UR"                  5      U0n[        R                  " U5      nOSn[        U5      S:  a  US   b  US   nU " UUUUSS9$ )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	   r6   r7   T)
isinstancer   	TypeErrortyper    r   r$   r#   r   r   r   lenr   coercer
   r   tuple
parameters)clspubr$   r#   r   valuesr   s          r'   r=   EstimatorPub.coercek   s     i.."GYGXXY Z[[1} !ABBc<((}}$)>KK #%(%9%9'"  Jc>**;DI; GT T  s89$B3s8*JW  a&&--c!f5s8a<CF.VFf}g&>?? 2 23V<,33F;#s8a<CF.AI#-
 	
r,   c           
     N   [        U R                  [        5      (       d  [        S5      eU R                  R                  5         U R                  R                  5         U R                  b\  [        U R                  [        5      (       d"  [        S[        U R                  5       S35      eU R                  S:  a  [        S5      e[        R                  " U R                  5       He  u  p[        [        [        U5      5      5      nU R                  R                   U:w  d  M>  [        SU R                  R                    SU S	U S
35      e   U R                  R"                  nX@R                  R"                  :w  a&  [        SU SU R                  R"                   S35      eg)zValidate the pub.zcircuit must be QuantumCircuit.Nr4   r5   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.)r9   r#   r   r:   r   r!   r   r$   r   r;   r    r   ndenumerater<   nextiter
num_qubitsnum_parameters)r"   i
observablerH   rI   s        r'   r!   EstimatorPub.validate   so   $,,77=>>!!#&&(>>%dnnd33"GT^^H\G]]^ _``~~! !BCC  ^^D,<,<=MAT$z"234J||&&*4 ;DLL<S<S;T U==>C?OPZ|[]_  > ..==\\888((8 9--1\\-H-H,II[]  9r,   )NNT)
r#   r   r   r   r   zBindingsArray | Noner$   float | Noner!   bool)returnr   )rO   r   )rO   r
   )rO   rM   )N)rA   r   r$   rM   rO   r   )__name__
__module____qualname____firstlineno____doc__	__slots__r   propertyr#   r   r   r$   classmethodr=   r!   __static_attributes____classcell__)r&   s   @r'   r   r   $   s     ZI 26"&&& && /	&
  & & &P   ! ! & &   <
 <
| r,   r   )rT   
__future__r   numbersr   collections.abcr   typingr   r   numpyr   qiskitr   bindings_arrayr
   r   observables_arrayr   r   r   r   __all__r   r    r,   r'   <module>rd      s    #  #   ! < E  
c; cL 	..
./	..0A
AB	..0A4
GHJ r,   