Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hea init bug #171

Merged
merged 19 commits into from
Jun 28, 2022
Merged
6 changes: 4 additions & 2 deletions tangelo/toolboxes/ansatz_generator/hea.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def __init__(self, molecule=None, mapping="jw", up_then_down=False,
n_layers=2, rot_type="euler", n_qubits=None, n_electrons=None,
reference_state="HF"):

if not (bool(molecule) ^ (bool(n_qubits) and (bool(n_electrons) | reference_state == "zero"))):
raise ValueError(f"A molecule OR qubit + electrons number must be provided when instantiating the HEA.")
if not (bool(molecule) ^ (bool(n_qubits) and (bool(n_electrons) | (reference_state == "zero")))):
raise ValueError(f"A molecule OR qubit + electrons number must be "
"provided when instantiating the HEA with the HF reference state. "
"For reference_state='zero', only the number of qubits is needed.")

if n_qubits:
self.n_qubits = n_qubits
Expand Down