Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Jun 12, 2024
1 parent ebd6fb2 commit b2a50d8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/qibo/quantum_info/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b2a50d8

Please sign in to comment.