Skip to content

Commit

Permalink
improved Error message for MP2 initialization in UCCSD (pySCf current…
Browse files Browse the repository at this point in the history
…ly required) (#322)

* improved Error message for MP2 initialization if pyscf is not found
  • Loading branch information
JamesB-1qbit authored Jun 27, 2023
1 parent 226b1fa commit 334abe9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tangelo/toolboxes/ansatz_generator/uccsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ def _compute_mp2_params(self):
"""

if not is_package_installed("pyscf"):
raise ValueError(f"pyscf is required for MP2 initial parameters in {self.__class__.__name__}.")
supported_initial_var_params = self.supported_initial_var_params.copy()
supported_initial_var_params.remove("mp2")
raise ValueError(f"PySCF is required for MP2 initial parameters in {self.__class__.__name__}.\n"
f"Other supported keywords for initializing variational parameters are {supported_initial_var_params}. "
f"An array of floats of length {self.n_var_params} can also be provided.\n"
f"The above keywords or array can also be provided to variational algorithms through the 'initial_var_params' keyword.")

# Import here to solve an AttributeError: partially initialized module
# tangelo.toolboxes.ansatz_generator' has no attribute 'UCCSD'
Expand Down

0 comments on commit 334abe9

Please sign in to comment.