Skip to content

Commit

Permalink
Fix benchmark collection gradient check
Browse files Browse the repository at this point in the history
* Fix instance vs class attribute for step sizes
* Only flatten problems where necessary
  • Loading branch information
dweindl committed Oct 23, 2024
1 parent a20447a commit 502aaaf
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tests/benchmark-models/test_petab_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from amici.petab.petab_import import import_petab_problem
import benchmark_models_petab
from collections import defaultdict
from dataclasses import dataclass
from dataclasses import dataclass, field
from amici import SensitivityMethod
from petab.v1.lint import measurement_table_has_timepoint_specific_mappings
from fiddy import MethodId, get_derivative
from fiddy.derivative_check import NumpyIsCloseDerivativeCheck
from fiddy.extensions.amici import simulate_petab_to_cached_functions
Expand Down Expand Up @@ -58,14 +59,16 @@ class GradientCheckSettings:
atol_consistency: float = 1e-5
rtol_consistency: float = 1e-1
# Step sizes for finite difference gradient checks.
step_sizes = [
1e-1,
5e-2,
1e-2,
1e-3,
1e-4,
1e-5,
]
step_sizes: list[float] = field(
default_factory=lambda: [
1e-1,
5e-2,
1e-2,
1e-3,
1e-4,
1e-5,
]
)
rng_seed: int = 0
ss_sensitivity_mode: amici.SteadyStateSensitivityMode = (
amici.SteadyStateSensitivityMode.integrateIfNewtonFails
Expand Down Expand Up @@ -176,7 +179,10 @@ def test_benchmark_gradient(model, scale, sensitivity_method, request):
pytest.skip()

petab_problem = benchmark_models_petab.get_problem(model)
petab.flatten_timepoint_specific_output_overrides(petab_problem)
if measurement_table_has_timepoint_specific_mappings(
petab_problem.measurement_df,
):
petab.flatten_timepoint_specific_output_overrides(petab_problem)

# Only compute gradient for estimated parameters.
parameter_ids = petab_problem.x_free_ids
Expand Down

0 comments on commit 502aaaf

Please sign in to comment.