Skip to content

Commit

Permalink
Merge pull request #1153 from qiboteam/realexp
Browse files Browse the repository at this point in the history
Return real expectation values in `Hamiltonian.expectation_from_samples`
  • Loading branch information
MatteoRobbiati authored Jan 10, 2024
2 parents 2b7e4d8 + 351eff8 commit ea72695
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/qibo/hamiltonians/hamiltonians.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def expectation_from_samples(self, freq, qubit_map=None):
for i in qubit_map:
index += int(k[qubit_map.index(i)]) * 2 ** (size - 1 - i)
expval += obs[index, index] * counts[j]
return expval
return np.real(expval)

def eye(self, dim: Optional[int] = None):
"""Generate Identity matrix with dimension ``dim``"""
Expand Down

0 comments on commit ea72695

Please sign in to comment.