Skip to content

Commit

Permalink
fix(frontend-python): approx rounding test regression due to simulati…
Browse files Browse the repository at this point in the history
…on fix
  • Loading branch information
rudy-6-4 committed Sep 2, 2024
1 parent 2afc3d2 commit 08380ce
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,16 +703,20 @@ def function(x):
# check it's better even with bad conf
assert circuit_approx.complexity < circuit_exact.complexity

testset = range(*inputset)
# avoiding overflows
if signed:
testset = [-(2 ** (accumulator_precision - 1)), 2 ** (accumulator_precision - 1) - 2**lsbs_to_remove]
else:
testset = [0, 2**accumulator_precision - 2**lsbs_to_remove]

nb_error = 0
for x in testset:
approx = circuit_approx.encrypt_run_decrypt(x)
approx_simu = circuit_approx.simulate(x)
exact = circuit_exact.simulate(x)
assert abs(approx_simu - exact) <= 1
assert abs(approx_simu - approx) <= 1
delta = abs(approx - approx_simu)
assert abs(approx - exact) <= 1
delta = abs(approx - exact)
assert delta <= 1
nb_error += delta > 0

Expand Down

0 comments on commit 08380ce

Please sign in to comment.