From e6ea195a5b34c0554a91cd993face7c55e9a676d Mon Sep 17 00:00:00 2001 From: rudy Date: Mon, 2 Sep 2024 15:49:51 +0200 Subject: [PATCH] fix(frontend-python): approx rounding test regression due to simulation fix --- .../tests/execution/test_round_bit_pattern.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontends/concrete-python/tests/execution/test_round_bit_pattern.py b/frontends/concrete-python/tests/execution/test_round_bit_pattern.py index deaf41031b..1134141842 100644 --- a/frontends/concrete-python/tests/execution/test_round_bit_pattern.py +++ b/frontends/concrete-python/tests/execution/test_round_bit_pattern.py @@ -703,7 +703,14 @@ 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: @@ -711,8 +718,8 @@ def function(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