From 65fcd0d4dff8f7d3679222cb382c5de716adf90d Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 8 Oct 2024 21:16:44 +0200 Subject: [PATCH] .. --- .../benchmark-models/test_petab_benchmark.py | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/benchmark-models/test_petab_benchmark.py b/tests/benchmark-models/test_petab_benchmark.py index 401be46199..23e67f0694 100644 --- a/tests/benchmark-models/test_petab_benchmark.py +++ b/tests/benchmark-models/test_petab_benchmark.py @@ -89,6 +89,13 @@ class GradientCheckSettings: settings["Giordano_Nature2020"] = GradientCheckSettings( atol_check=1e-6, rtol_check=1e-3, rng_seed=1 ) +settings["Weber_BMC2015"] = GradientCheckSettings( + atol_sim=1e-12, + rtol_sim=1e-12, + atol_check=1e-6, + rtol_check=1e-2, + rng_seed=1, +) def assert_gradient_check_success( @@ -115,8 +122,14 @@ def assert_gradient_check_success( df = check_result.df df["abs_diff"] = np.abs(df["expectation"] - df["test"]) df["rel_diff"] = df["abs_diff"] / np.abs(df["expectation"]) + max_adiff = df["abs_diff"].max() + max_rdiff = df["rel_diff"].max() with pd.option_context("display.max_columns", None, "display.width", None): - raise AssertionError(f"Gradient check failed:\n{df}") + raise AssertionError( + f"Gradient check failed:\n{df}\n\n" + f"Maximum absolute difference: {max_adiff}\n" + f"Maximum relative difference: {max_rdiff}" + ) @pytest.mark.filterwarnings( @@ -160,11 +173,7 @@ def test_benchmark_gradient(model, scale, sensitivity_method, request): pytest.skip() if ( - model - in ( - "Weber_BMC2015", - "Sneyd_PNAS2002", - ) + model in ("Sneyd_PNAS2002",) and sensitivity_method == SensitivityMethod.forward ): # FIXME @@ -209,7 +218,7 @@ def test_benchmark_gradient(model, scale, sensitivity_method, request): # cache=not debug, cache=False, ) - noise_level = 0.1 + noise_level = 0.05 np.random.seed(cur_settings.rng_seed) # find a point where the derivative can be computed