From 08380ce50038d098df96a06485afed6aaf86f736 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 | 10 +++++++--- 1 file changed, 7 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..49c0401e86 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,11 @@ 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 +715,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