Skip to content

Commit

Permalink
fix: Handle division 0 error
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed May 14, 2024
1 parent aad9f40 commit c9fbe07
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ def compute_chsh(frequencies, basis, i):
chsh += (-1) ** (int(outcome[0]) + int(outcome[1])) * freq[outcome][i]
aux += 1
nshots = sum(freq[x][i] for x in freq)
return chsh / nshots
try:
return chsh / nshots
except ZeroDivisionError:
return 0

0 comments on commit c9fbe07

Please sign in to comment.