Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Oct 8, 2024
1 parent 99b6eba commit 65fcd0d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/benchmark-models/test_petab_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65fcd0d

Please sign in to comment.