def _obs_vals_from_measurements(
    bitstrings: np.ndarray,
    qubit_to_index: Mapping[cirq.Qid, int],
    observable: cirq.PauliString,
    atol: float,
):
    """Multiply together bitstrings to get observed values of operators."""
    idxs = [qubit_to_index[q] for q in observable.keys()]
    # Make sure any unit8's coming in get a sign. eigenvalues will be +- 1.
    # Select the columns we need for this observable
    selected_bitstrings = np.asarray(bitstrings[:, idxs], dtype=np.int8)
    # Transform bits to eigenvalues; ie (+1, -1)
    selected_obsstrings = 1 - 2 * selected_bitstrings
    coeff = _check_and_get_real_coef(observable, atol=atol)
    obs_vals = coeff * np.prod(selected_obsstrings, axis=1)
    return obs_vals
Multiply together bitstrings to get observed values of operators.
cirq-core/cirq/work/observable_measurement_data.py