§
    º³Ùg¢  ã                  ó2   — d Z ddlmZ ddlZddlmZ dd„ZdS )z=A collection of useful functions for post processing results.é    )ÚannotationsNé   )Úmake_dict_observableÚcountsÚdictÚ
observableúdict | np.ndarray | listÚreturnÚfloatc                óÔ   — t          |t          ¦  «        st          |¦  «        }d}t          |                      ¦   «         ¦  «        }| D ]}||v r|| |         ||         z  |z  z  }Œ|S )a«  Compute the mean value of an diagonal observable.

    Takes in a diagonal observable in dictionary, list or matrix format and then
    calculates the sum_i value(i) P(i) where value(i) is the value of the
    observable for state i.

    Args:
        counts (dict): a dict of outcomes from an experiment
        observable (dict or matrix or list): The observable to be averaged over.
        As an example, ZZ on qubits can be given as:
        * dict: {"00": 1, "11": 1, "01": -1, "10": -1}
        * matrix: [[1, 0, 0, 0], [0, -1, 0, 0, ], [0, 0, -1, 0], [0, 0, 0, 1]]
        * matrix diagonal (list): [1, -1, -1, 1]

    Returns:
        Double: Average of the observable
    r   )Ú
isinstancer   r   ÚsumÚvalues)r   r   ÚtempÚtotÚkeys        úZ/granary/edev/quantum/lib/python3.11/site-packages/qiskit/quantum_info/analysis/average.pyÚaverage_datar      sy   € õ$ �j¥$Ñ'Ô'ð 6Ý)¨*Ñ5Ô5ˆ
Ø€DÝ
ˆf�mŠm‰oŒoÑ
Ô
€CØð 8ð 8ˆØ�*ÐÐØ�F˜3”K *¨S¤/Ñ1°CÑ7Ñ7ˆDøØ€Kó    )r   r   r   r	   r
   r   )Ú__doc__Ú
__future__r   ÚnumpyÚnpÚmake_observabler   r   © r   r   ú<module>r      s\   ðð DÐ Cà "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1ðð ð ð ð ð r   