# Path: openfermioncirq/experiments/hfvqe/objective.py
# def get_matrix_of_eigs(w: np.ndarray) -> np.ndarray:
#     def __init__(self, hamiltonian: InteractionOperator, num_electrons: int):
#     def rdms_from_opdm_aa(self, opdm_aa):
#     def energy_from_opdm(self, opdm_aa: np.ndarray) -> float:
#     def global_gradient_opdm(self, params: np.ndarray,
#                               alpha_opdm: np.ndarray):
# def generate_hamiltonian(one_body_integrals: np.ndarray,
#                          two_body_integrals: np.ndarray,
#                          constant: float,
#                          EQ_TOLERANCE: Optional[float]=1.0E-12):
# class RestrictedHartreeFockObjective():
#             Y = rhf_params_to_matrix(grad_params,
#                                      len(self.occ) + len(self.virt),
#                                      self.occ, self.virt)


from typing import List, Optional
from openfermioncirq.experiments.hfvqe.objective import rhf_params_to_matrix
import cirq
import numpy as np
import scipy as sp
import openfermioncirq.experiments.hfvqe.circuits as ccc
import openfermioncirq.experiments.hfvqe.analysis as cca
import openfermioncirq.experiments.hfvqe.util as ccu
                 post_selection: Optional[bool] = True,
                 purification: Optional[bool] = True,
                 clean_xxyy: Optional[bool] = True,
                 verbose: Optional[bool] = False):
        self.qubits = qubits
        self.constant = constant
        self.one_body_integrals = one_body_integrals
        self.two_body_integrals = two_body_integrals
        self.num_electrons = num_electrons
        self.sampler = sampler
        self.num_samples = num_samples
        self.post_selection = post_selection
        self.purification = purification
        self.clean_xxyy = clean_xxyy
        self.num_qubits = len(self.qubits)
        self.verbose = verbose  # type: bool

        self._last_noisy_opdm = None

        norbs = len(self.qubits)
        self.occ = list(range(num_electrons))
        self.virt = list(range(num_electrons, norbs))
        self.nocc = len(self.occ)
        self.nvirt = len(self.virt)
        self.clean_xxyy = clean_xxyy

    def calculate_data(self, parameters):
        if len(parameters.shape) == 2:  # testpragma: no cover
            u = parameters
        else:

# Path: openfermioncirq/experiments/hfvqe/objective.py
# def get_matrix_of_eigs(w: np.ndarray) -> np.ndarray:
#     def __init__(self, hamiltonian: InteractionOperator, num_electrons: int):
#     def rdms_from_opdm_aa(self, opdm_aa):
#     def energy_from_opdm(self, opdm_aa: np.ndarray) -> float:
#     def global_gradient_opdm(self, params: np.ndarray,
#                               alpha_opdm: np.ndarray):
# def generate_hamiltonian(one_body_integrals: np.ndarray,
#                          two_body_integrals: np.ndarray,
#                          constant: float,
#                          EQ_TOLERANCE: Optional[float]=1.0E-12):
# class RestrictedHartreeFockObjective():
#             Y = rhf_params_to_matrix(grad_params,
#                                      len(self.occ) + len(self.virt),
#                                      self.occ, self.virt)


# Path: openfermioncirq/experiments/hfvqe/opdm_functionals.py
from typing import List, Optional
from openfermioncirq.experiments.hfvqe.objective import rhf_params_to_matrix
import cirq
import numpy as np
import scipy as sp
import openfermioncirq.experiments.hfvqe.circuits as ccc
import openfermioncirq.experiments.hfvqe.analysis as cca
import openfermioncirq.experiments.hfvqe.util as ccu

                 post_selection: Optional[bool] = True,
                 purification: Optional[bool] = True,
                 clean_xxyy: Optional[bool] = True,
                 verbose: Optional[bool] = False):
        self.qubits = qubits
        self.constant = constant
        self.one_body_integrals = one_body_integrals
        self.two_body_integrals = two_body_integrals
        self.num_electrons = num_electrons
        self.sampler = sampler
        self.num_samples = num_samples
        self.post_selection = post_selection
        self.purification = purification
        self.clean_xxyy = clean_xxyy
        self.num_qubits = len(self.qubits)
        self.verbose = verbose  # type: bool

        self._last_noisy_opdm = None

        norbs = len(self.qubits)
        self.occ = list(range(num_electrons))
        self.virt = list(range(num_electrons, norbs))
        self.nocc = len(self.occ)
        self.nvirt = len(self.virt)
        self.clean_xxyy = clean_xxyy

    def calculate_data(self, parameters):
        if len(parameters.shape) == 2:  # testpragma: no cover
            u = parameters
        else:

            u = sp.linalg.expm(rhf_params_to_matrix(parameters,