Bug in SymbolicHamiltonian.expectation_from_samples
for Qibo 0.2.14
#1535
Labels
bug
Something isn't working
To Reproduce
The above code should simply give 1.0, but fails in Qibo 0.2.14. The error message:
I believe the problem is caused by the
qubit_map
argument inSymbolicHamiltonian.expectation_from_samples
.The documentation says that it should be a dictionary:
qibo/src/qibo/hamiltonians/hamiltonians.py
Line 638 in a518e99
But the default value is still a list:
qibo/src/qibo/hamiltonians/hamiltonians.py
Lines 651 to 652 in a518e99
while the code that checks the binary strings from the measurement frequencies will work if
qubit_map
is a dictionary (like{0: 0, 2:1}
for my example above)qibo/src/qibo/hamiltonians/hamiltonians.py
Line 664 in a518e99
Suggested fix
I would suggest keeping the
qubit_map
argument forSymbolicHamiltonian
as a list (just edit the docs) to keep it consistent across all the different Hamiltonians available, then just change the line above to* (-1) ** [state[qubit_map.index(q)] for q in qubits].count("1")
The text was updated successfully, but these errors were encountered: