You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "/..../site-packages/qiskit/circuit/library/evolved_operator_ansatz.py", line 109, in num_qubits
return self.operators.num_qubits
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'num_qubits'
What should happen?
It was expected to return True as the case with no qubit is handled well in QuantumCircuit and its subclasses. It was partially handled in the EvolvedOperatorAnsatz too. For example
Environment
What is happening?
If we set
operators
in EvolvedOperatorAnsatz to an empty list, it raises an unhandled exception and fails to create an object.This case can happen when we use UCCSD ansatz from qiskit_nature with a molecule that has no electrons.
How can we reproduce the issue?
Running the following code
raises the following error:
What should happen?
It was expected to return
True
as the case with no qubit is handled well inQuantumCircuit
and its subclasses. It was partially handled in theEvolvedOperatorAnsatz
too. For exampleqiskit/qiskit/circuit/library/n_local/evolved_operator_ansatz.py
Line 109 in d033e8a
shows the previous intention to handle this case. But it is not completely done so it raises an unhandled exception.
Any suggestions?
I'll create a pull request to discuss the proposed solution.
The text was updated successfully, but these errors were encountered: