From 30c5bbd5b556627281ffb8ce47ba96e4dadbfbc5 Mon Sep 17 00:00:00 2001 From: Abdulla Alhajri Date: Thu, 13 Jun 2024 14:54:25 +0400 Subject: [PATCH 1/3] changed the value of the spectrum returned in the von neumann entropy for pure states from 1 to 0 --- src/qibo/quantum_info/entropies.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qibo/quantum_info/entropies.py b/src/qibo/quantum_info/entropies.py index 3d4e7ac027..842fa82e47 100644 --- a/src/qibo/quantum_info/entropies.py +++ b/src/qibo/quantum_info/entropies.py @@ -1,4 +1,4 @@ -"""Submodule with entropy measures.""" +""Submodule with entropy measures.""" from typing import Union @@ -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 From d4dfb3192a35ad996ed7000b4c6ab79811f6cf4b Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Thu, 13 Jun 2024 15:09:07 +0400 Subject: [PATCH 2/3] fix lint issue --- src/qibo/quantum_info/entropies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/entropies.py b/src/qibo/quantum_info/entropies.py index 842fa82e47..d6499e15dc 100644 --- a/src/qibo/quantum_info/entropies.py +++ b/src/qibo/quantum_info/entropies.py @@ -1,4 +1,4 @@ -""Submodule with entropy measures.""" +"""Submodule with entropy measures.""" from typing import Union From 6a13965381c79593f67fb1492f001aa477f0a2dd Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Fri, 14 Jun 2024 08:31:24 +0400 Subject: [PATCH 3/3] fix test --- tests/test_callbacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)