Skip to content

Commit

Permalink
Merge pull request #1360 from qiboteam/log_entropies
Browse files Browse the repository at this point in the history
Fix value of the spectrum returned in the `quantum_info.entropies.von_neumann_entropy`
  • Loading branch information
renatomello authored Jun 17, 2024
2 parents 0d86ec5 + 8f2d00f commit 70901d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/qibo/quantum_info/entropies.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def von_neumann_entropy(

if purity(state) == 1.0:
if return_spectrum:
return 0.0, backend.cast([1.0], dtype=float)
return 0.0, backend.cast([0.0], dtype=float)

return 0.0

Expand Down
2 changes: 1 addition & 1 deletion tests/test_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_entropy_in_circuit(backend, density_matrix, base):
values = [backend.to_numpy(x) for x in entropy]
backend.assert_allclose(values, target, atol=PRECISION_TOL)

target_spectrum = [1.0] + list([0, 0, np.log(2), np.log(2)] / np.log(base))
target_spectrum = [0.0] + list([0, 0, np.log(2), np.log(2)] / np.log(base))
entropy_spectrum = np.ravel(np.concatenate(entropy.spectrum)).tolist()
backend.assert_allclose(entropy_spectrum, target_spectrum, atol=PRECISION_TOL)

Expand Down

0 comments on commit 70901d5

Please sign in to comment.