§
    º³ÙgL!  ã                   óv   — d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	  G d„ d¦  «        Z
 G d„ d	¦  «        ZdS )
z7Schema and helper models for schema-conformant Results.é    N)ÚMeasReturnTypeÚ	MeasLevel)ÚQobjExperimentHeader)ÚQiskitErrorc                   ó>   — e Zd ZdZ	 dd„Zd„ Zd„ Zed„ ¦   «         ZdS )ÚExperimentResultDataz)Class representing experiment result dataNc                 óü  — g | _         |�!| j                              d¦  «         || _        |�!| j                              d¦  «         || _        |�!| j                              d¦  «         || _        |�!| j                              d¦  «         || _        |�!| j                              d¦  «         || _        |                     ¦   «         D ]0\  }}t          | ||¦  «         | j                              |¦  «         Œ1dS )a.  Initialize an ExperimentalResult Data class

        Args:
            counts (dict): A dictionary where the keys are the result in
                hexadecimal as string of the format "0xff" and the value
                is the number of counts for that result
            snapshots (dict): A dictionary where the key is the snapshot
                slot and the value is a dictionary of the snapshots for
                that slot.
            memory (list): A list of results per shot if the run had
                memory enabled
            statevector (list or numpy.array): A list or numpy array of the
                statevector result
            unitary (list or numpy.array): A list or numpy array of the
                unitary result
            kwargs (any): additional data key-value pairs.
        NÚcountsÚ	snapshotsÚmemoryÚstatevectorÚunitary)	Ú_data_attributesÚappendr
   r   r   r   r   ÚitemsÚsetattr)	Úselfr
   r   r   r   r   ÚkwargsÚkeyÚvalues	            úJ/granary/edev/quantum/lib/python3.11/site-packages/qiskit/result/models.pyÚ__init__zExperimentResultData.__init__   s  € ð( !#ˆÔØÐØÔ!×(Ò(¨Ñ2Ô2Ð2Ø ˆDŒKØÐ ØÔ!×(Ò(¨Ñ5Ô5Ð5Ø&ˆDŒNØÐØÔ!×(Ò(¨Ñ2Ô2Ð2Ø ˆDŒKØÐ"ØÔ!×(Ò(¨Ñ7Ô7Ð7Ø*ˆDÔØÐØÔ!×(Ò(¨Ñ3Ô3Ð3Ø"ˆDŒLØ Ÿ,š,™.œ.ð 	.ð 	.‰JˆC�Ý�D˜#˜uÑ%Ô%Ð%ØÔ!×(Ò(¨Ñ-Ô-Ð-Ð-ð	.ð 	.ó    c           	      óœ   — g }| j         D ]*}|                     |› dt          | |¦  «        › �¦  «         Œ+dd                     |¦  «        › d�S )Nú=zExperimentResultData(ú, ú))r   r   ÚgetattrÚjoin)r   Ústring_listÚfields      r   Ú__repr__zExperimentResultData.__repr__B   sg   € ØˆØÔ*ð 	Bð 	BˆEØ×Ò %Ð@Ð@­'°$¸Ñ*>Ô*>Ð@Ð@ÑAÔAÐAÐAØ@ t§y¢y°Ñ'=Ô'=Ð@Ð@Ð@Ð@r   c                 óD   — i }| j         D ]}t          | |¦  «        ||<   Œ|S )z¢Return a dictionary format representation of the ExperimentResultData

        Returns:
            dict: The dictionary form of the ExperimentResultData
        )r   r   )r   Úout_dictr!   s      r   Úto_dictzExperimentResultData.to_dictH   s5   € ð ˆØÔ*ð 	3ð 	3ˆEÝ% d¨EÑ2Ô2ˆH�U‰OˆOØˆr   c                 ó:   — t          j         |¦  «        } | di |¤ŽS )a«  Create a new ExperimentResultData object from a dictionary.

        Args:
            data (dict): A dictionary representing the ExperimentResultData to
                         create. It will be in the same format as output by
                         :meth:`to_dict`
        Returns:
            ExperimentResultData: The ``ExperimentResultData`` object from the
                                  input dictionary.
        © )Úcopy)ÚclsÚdataÚin_datas      r   Ú	from_dictzExperimentResultData.from_dictS   s#   € õ ”)˜D‘/”/ˆØˆsˆ~ˆ~�Wˆ~ˆ~Ðr   )NNNNN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r"   r%   Úclassmethodr,   r'   r   r   r   r      sr   € € € € € Ø3Ð3ð SWð&.ð &.ð &.ð &.ðPAð Að Að	ð 	ð 	ð ðð ñ „[ðð ð r   r   c                   óZ   — e Zd ZdZi Zej        ddddfd„Zd„ Zd„ Z	d„ Z
ed„ ¦   «         ZdS )ÚExperimentResultaA  Class representing an Experiment Result.

    Attributes:
        shots (int or tuple): the starting and ending shot for this data.
        success (bool): if true, we can trust results for this experiment.
        data (ExperimentResultData): results information.
        meas_level (int): Measurement result level.
    Nc	                 ó  — i | _         || _        || _        || _        || _        |�|| _        |�|| _        |�|| _        |�,|t          t          ¦  «        vrt          d¦  «        ‚|| _        | j                              |	¦  «         dS )ad  Initialize an ExperimentResult object.

        Args:
            shots(int or tuple): if an integer the number of shots or if a
                tuple the starting and ending shot for this data
            success (bool): True if the experiment was successful
            data (ExperimentResultData): The data for the experiment's
                result
            meas_level (int): Measurement result level
            status (str): The status of the experiment
            seed (int): The seed used for simulation (if run on a simulator)
            meas_return (str): The type of measurement returned
            header (qiskit.qobj.QobjExperimentHeader): A free form dictionary
                header for the experiment
            kwargs: Arbitrary extra fields

        Raises:
            QiskitError: If meas_return or meas_level are not valid values
        Nz %s not a valid meas_return value)Ú	_metadataÚshotsÚsuccessr*   Ú
meas_levelÚheaderÚstatusÚseedÚlistr   r   Úmeas_returnÚupdate)
r   r6   r7   r*   r8   r:   r;   r=   r9   r   s
             r   r   zExperimentResult.__init__o   sš   € ð> ˆŒØˆŒ
ØˆŒØˆŒ	Ø$ˆŒØÐØ ˆDŒKØÐØ ˆDŒKØÐØˆDŒIØÐ"Ø¥$¥~Ñ"6Ô"6Ð6Ð6Ý!Ð"DÑEÔEÐEØ*ˆDÔØŒ×Ò˜fÑ%Ô%Ð%Ð%Ð%r   c                 óæ  — d| j         › d| j        › d| j        › d| j        › �}t	          | d¦  «        r|d| j        › �z  }t	          | d¦  «        r|d| j        › �z  }t	          | d	¦  «        r|d
| j        › �z  }t	          | d¦  «        r|d| j        › �z  }| j	         
                    ¦   «         D ];\  }}t          |t          ¦  «        rd|› d�}nt          |¦  «        }|d|› d|› �z  }Œ<|dz  }|S )NzExperimentResult(shots=z
, success=z, meas_level=z, data=r9   z	, header=r:   z	, status=r;   z, seed=r=   z, meas_return=ú'r   r   r   )r6   r7   r8   r*   Úhasattrr9   r:   r;   r=   r5   r   Ú
isinstanceÚstrÚrepr)r   Úoutr   r   Ú	value_strs        r   r"   zExperimentResult.__repr__Ÿ   s]  € ð? d¤jð ?ð ?¸D¼Lð ?ð ?Øœ?ð?ð ?Ø37´9ð?ð ?ð 	õ �4˜Ñ"Ô"ð 	-ØÐ,˜tœ{Ð,Ð,Ñ,ˆCÝ�4˜Ñ"Ô"ð 	-ØÐ,˜tœ{Ð,Ð,Ñ,ˆCÝ�4˜Ñ Ô ð 	)ØÐ(˜TœYÐ(Ð(Ñ(ˆCÝ�4˜Ñ'Ô'ð 	7ØÐ6 DÔ$4Ð6Ð6Ñ6ˆCØœ.×.Ò.Ñ0Ô0ð 	*ð 	*‰JˆC�Ý˜%¥Ñ%Ô%ð (Ø( ˜L˜L˜L�	�	å  ™KœK�	ØÐ)˜Ð)Ð)˜iÐ)Ð)Ñ)ˆCˆCØˆs‰
ˆØˆ
r   c                 ój   — 	 | j         |         S # t          $ r}t          d|› d�¦  «        |‚d }~ww xY w)Nz
Attribute z is not defined)r5   ÚKeyErrorÚAttributeError)r   ÚnameÚexs      r   Ú__getattr__zExperimentResult.__getattr__µ   sT   € ð	MØ”> $Ô'Ð'øÝð 	Mð 	Mð 	MÝ Ð!C¨dÐ!CÐ!CÐ!CÑDÔDÈ"ÐLøøøøð	Møøøs   ‚ �
2™-­2c                 óˆ  — | j         | j        | j                             ¦   «         | j        dœ}t          | d¦  «        r| j                             ¦   «         |d<   t          | d¦  «        r
| j        |d<   t          | d¦  «        r
| j        |d<   t          | d¦  «        r
| j	        |d<   | 
                    | j        ¦  «         |S )zšReturn a dictionary format representation of the ExperimentResult

        Returns:
            dict: The dictionary form of the ExperimentResult
        )r6   r7   r*   r8   r9   r:   r;   r=   )r6   r7   r*   r%   r8   rA   r9   r:   r;   r=   r>   r5   )r   r$   s     r   r%   zExperimentResult.to_dict»   sÐ   € ð ”ZØ”|Ø”I×%Ò%Ñ'Ô'Øœ/ð	
ð 
ˆõ �4˜Ñ"Ô"ð 	7Ø!%¤×!4Ò!4Ñ!6Ô!6ˆH�XÑÝ�4˜Ñ"Ô"ð 	-Ø!%¤ˆH�XÑÝ�4˜Ñ Ô ð 	)Ø#œyˆH�VÑÝ�4˜Ñ'Ô'ð 	7Ø&*Ô&6ˆH�]Ñ#Ø�Š˜œÑ'Ô'Ð'Øˆr   c                 óØ  — t          j         |¦  «        }t                               |                     d¦  «        ¦  «        }d|v rqt	          j        ¦   «         5  t	          j        dt          d¬¦  «         t          j        |                     d¦  «        ¦  «        |d<   ddd¦  «         n# 1 swxY w Y   |                     d¦  «        }|                     d¦  «        } | |||fi |¤ŽS )	a˜  Create a new ExperimentResult object from a dictionary.

        Args:
            data (dict): A dictionary representing the ExperimentResult to
                         create. It will be in the same format as output by
                         :meth:`to_dict`

        Returns:
            ExperimentResult: The ``ExperimentResult`` object from the input
                              dictionary.
        r*   r9   ÚignoreÚqiskit)ÚcategoryÚmoduleNr6   r7   )	r(   r   r,   ÚpopÚwarningsÚcatch_warningsÚfilterwarningsÚDeprecationWarningr   )r)   r*   r+   Údata_objr6   r7   s         r   r,   zExperimentResult.from_dictÒ   s+  € õ ”)˜D‘/”/ˆÝ'×1Ò1°'·+²+¸fÑ2EÔ2EÑFÔFˆØ�wÐÐÝÔ(Ñ*Ô*ð Zð ZåÔ'¨Õ;MÐV^Ð_Ñ_Ô_Ð_Ý$8Ô$BÀ7Ç;Â;ÈxÑCXÔCXÑ$YÔ$Y�˜Ñ!ðZð Zð Zñ Zô Zð Zð Zð Zð Zð Zð Zøøøð Zð Zð Zð Zð —’˜GÑ$Ô$ˆØ—+’+˜iÑ(Ô(ˆàˆs�5˜' 8Ð7Ð7¨wÐ7Ð7Ð7s   ÁAB,Â,B0Â3B0)r-   r.   r/   r0   r5   r   Ú
CLASSIFIEDr   r"   rL   r%   r1   r,   r'   r   r   r3   r3   c   s™   € € € € € ðð ð €Ið Ô'ØØØØð.&ð .&ð .&ð .&ð`ð ð ð,Mð Mð Mðð ð ð. ð8ð 8ñ „[ð8ð 8ð 8r   r3   )r0   r(   rT   Úqiskit.qobj.utilsr   r   Úqiskit.qobjr   Úqiskit.exceptionsr   r   r3   r'   r   r   ú<module>r]      sÈ   ðð >Ð =à €€€Ø €€€à 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø )Ð )Ð )Ð )Ð )Ð )ðIð Ið Ið Ið Iñ Iô Ið IðXG8ð G8ð G8ð G8ð G8ñ G8ô G8ð G8ð G8ð G8r   