diff --git a/src/qibo/quantum_info/entropies.py b/src/qibo/quantum_info/entropies.py index 3d4e7ac027..d6499e15dc 100644 --- a/src/qibo/quantum_info/entropies.py +++ b/src/qibo/quantum_info/entropies.py @@ -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 diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py index 5ff73f66a5..bf2ac7d2d0 100644 --- a/tests/test_callbacks.py +++ b/tests/test_callbacks.py @@ -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)