From b2a50d8155809a68020505f7333cc5107d691e04 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Wed, 12 Jun 2024 15:43:09 +0400 Subject: [PATCH] fix --- src/qibo/quantum_info/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qibo/quantum_info/utils.py b/src/qibo/quantum_info/utils.py index 13df6781d8..e47382cfa0 100644 --- a/src/qibo/quantum_info/utils.py +++ b/src/qibo/quantum_info/utils.py @@ -102,7 +102,12 @@ def hamming_distance( nbits = max(len(bitstring_1), len(bitstring_2)) - difference = abs(int(bitstring_1, 2) - int(bitstring_2, 2)) + bitstring_1 = "0" * (nbits - len(bitstring_1)) + bitstring_1 + bitstring_2 = "0" * (nbits - len(bitstring_2)) + bitstring_2 + + difference = np.abs( + np.array(list(bitstring_1), dtype=int) - np.array(list(bitstring_2), dtype=int) + ) return hamming_weight(f"{difference:{nbits}b}", return_indexes=return_indexes)