Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem ID and output in benchmark collection tests #2570

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/benchmark-models/benchmark_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Elowitz_Nature2000:
t_adj: 0.11
note: benchmark collection reference value matches up to sign when applying log10-correction +sum(log(meas*log(10))) / 2

Fiedler_BMC2016:
Fiedler_BMCSystBiol2016:
llh: 58.58390161681
t_sim: 0.005
t_fwd: 0.05
Expand Down
29 changes: 20 additions & 9 deletions tests/benchmark-models/test_petab_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@
from petab.v1.visualize import plot_problem


logger = get_logger(f"amici.{__name__}", logging.WARNING)
# Enable various debug output
debug = False

logger = get_logger(
f"amici.{__name__}", logging.DEBUG if debug else logging.INFO
)

script_dir = Path(__file__).parent.absolute()
repo_root = script_dir.parent.parent
benchmark_outdir = repo_root / "test_bmc"
debug_path = script_dir / "debug"
if debug:
debug_path.mkdir(exist_ok=True, parents=True)

# reference values for simulation times and log-likelihoods
references_yaml = script_dir / "benchmark_models.yaml"
Expand Down Expand Up @@ -225,12 +233,6 @@ class GradientCheckSettings:
)


debug = False
if debug:
debug_path = Path(__file__).parent / "debug"
debug_path.mkdir(exist_ok=True, parents=True)


@pytest.fixture(scope="session", params=problems, ids=problems)
def benchmark_problem(request):
"""Fixture providing model and PEtab problem for a problem from
Expand Down Expand Up @@ -570,9 +572,18 @@ def assert_gradient_check_success(
df["rtol_success"] = df["rel_diff"] <= rtol
max_adiff = df["abs_diff"].max()
max_rdiff = df["rel_diff"].max()
with pd.option_context("display.max_columns", None, "display.width", None):

success_fail = "succeeded" if check_result.success else "failed"
with pd.option_context(
"display.max_columns",
None,
"display.width",
None,
"display.max_rows",
None,
):
message = (
f"Gradient check failed:\n{df}\n\n"
f"Gradient check {success_fail}:\n{df}\n\n"
f"Maximum absolute difference: {max_adiff} (tolerance: {atol})\n"
f"Maximum relative difference: {max_rdiff} (tolerance: {rtol})"
)
Expand Down
Loading