Skip to content

Commit c338c32

Browse files
committed
Move petab v1 simulation code to amici.sim...
Related to #3041.
1 parent a8dfd6e commit c338c32

File tree

22 files changed

+105
-83
lines changed

22 files changed

+105
-83
lines changed

doc/examples/example_errors.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
" import_model_module,\n",
3030
")\n",
3131
"from amici.importers.petab.v1 import (\n",
32-
" EDATAS,\n",
33-
" RDATAS,\n",
3432
" import_petab_problem,\n",
35-
" simulate_petab,\n",
3633
")\n",
3734
"from amici.sim.sundials import (\n",
3835
" AMICI_SUCCESS,\n",
@@ -44,6 +41,11 @@
4441
" simulation_status_to_str,\n",
4542
" unscale_parameter,\n",
4643
")\n",
44+
"from amici.sim.sundials.petab.v1 import (\n",
45+
" EDATAS,\n",
46+
" RDATAS,\n",
47+
" simulate_petab,\n",
48+
")\n",
4749
"from amici.sim.sundials.plotting import plot_jacobian, plot_state_trajectories\n",
4850
"from petab.v1.sbml import get_sbml_model\n",
4951
"\n",

doc/examples/example_jax/ExampleJax.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@
310310
"metadata": {},
311311
"outputs": [],
312312
"source": [
313-
"from amici.importers.petab.v1 import simulate_petab\n",
314313
"from amici.sim.sundials import SensitivityOrder\n",
314+
"from amici.sim.sundials.petab.v1 import simulate_petab\n",
315315
"\n",
316316
"amici_solver = amici_model.create_solver()\n",
317317
"amici_solver.set_sensitivity_order(SensitivityOrder.first)\n",

doc/examples/example_jax_petab/ExampleJaxPEtab.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@
565565
"metadata": {},
566566
"outputs": [],
567567
"source": [
568-
"from amici.importers.petab.v1 import simulate_petab\n",
569568
"from amici.sim.sundials import SensitivityMethod, SensitivityOrder\n",
569+
"from amici.sim.sundials.petab.v1 import simulate_petab\n",
570570
"\n",
571571
"# Import the PEtab problem as a standard AMICI model\n",
572572
"amici_model = import_petab_problem(\n",

doc/examples/example_petab/petab.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818
"outputs": [],
1919
"source": [
2020
"import petab\n",
21-
"from amici.importers.petab.v1 import (\n",
22-
" import_petab_problem,\n",
23-
" simulate_petab,\n",
24-
")\n",
25-
"from amici.importers.petab.v1.petab_problem import PetabProblem\n",
21+
"from amici.importers.petab.v1 import import_petab_problem\n",
2622
"from amici.sim.sundials import run_simulation\n",
23+
"from amici.sim.sundials.petab.v1 import PetabProblem, simulate_petab\n",
2724
"from amici.sim.sundials.plotting import plot_state_trajectories"
2825
]
2926
},

doc/python_modules.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@ AMICI Python API
1818
amici.importers.antimony
1919
amici.importers.petab
2020
amici.importers.petab.v1
21-
amici.importers.petab.v1.conditions
2221
amici.importers.petab.v1.import_helpers
2322
amici.importers.petab.v1.parameter_mapping
2423
amici.importers.petab.v1.petab_import
2524
amici.importers.petab.v1.pysb_import
2625
amici.importers.petab.v1.sbml_import
27-
amici.importers.petab.v1.simulations
28-
amici.importers.petab.v1.simulator
2926
amici.jax
3027
amici.exporters.sundials.de_export
3128
amici.sim.sundials
3229
amici.sim.sundials.plotting
3330
amici.sim.sundials.gradient_check
31+
amici.sim.sundials.petab.v1
3432
amici.logging
3533
amici.adapters.fiddy

python/sdist/amici/adapters/fiddy.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
from fiddy import CachedFunction, Type, fiddy_array
1818
from petab.v1.C import LIN, LOG, LOG10
1919

20-
import amici
21-
import amici.importers.petab.v1.simulations
2220
from amici.importers.petab import LLH, SLLH
23-
from amici.importers.petab.v1.conditions import create_edatas
2421
from amici.importers.petab.v1.parameter_mapping import create_parameter_mapping
2522
from amici.sim.sundials import (
2623
AmiciExpData,
@@ -31,6 +28,7 @@
3128
SensitivityOrder,
3229
run_simulation,
3330
)
31+
from amici.sim.sundials.petab.v1._conditions import create_edatas
3432

3533
if TYPE_CHECKING:
3634
from amici.importers.petab import PetabSimulator
@@ -297,7 +295,7 @@ def simulate_petab_to_cached_functions(
297295
**kwargs,
298296
) -> tuple[Type.FUNCTION, Type.FUNCTION]:
299297
"""
300-
Convert :func:`amici.petab.simulations.simulate_petab`
298+
Convert :func:`amici.sim.sundials.petab.v1.simulate_petab`
301299
(PEtab v1 simulations) to fiddy functions.
302300
303301
Note that all gradients are provided on linear scale. The correction from
@@ -333,7 +331,7 @@ def simulate_petab_to_cached_functions(
333331
free_parameter_ids = list(petab_problem.parameter_df.index)
334332

335333
if simulate_petab is None:
336-
simulate_petab = amici.importers.petab.v1.simulations.simulate_petab
334+
from amici.sim.sundials.petab.v1._simulations import simulate_petab
337335

338336
edatas = None
339337
if precreate_edatas:

python/sdist/amici/importers/petab/_petab_importer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@
2626
from amici.importers.utils import MeasurementChannel, amici_time_symbol
2727
from amici.logging import get_logger
2828
from amici.sim.sundials import SensitivityOrder
29+
from amici.sim.sundials.petab.v1._simulations import (
30+
EDATAS,
31+
LLH,
32+
RDATAS,
33+
RES,
34+
S2LLH,
35+
SLLH,
36+
SRES,
37+
)
2938

3039
from .v1.sbml_import import _add_global_parameter
31-
from .v1.simulations import EDATAS, LLH, RDATAS, RES, S2LLH, SLLH, SRES
3240

3341
if TYPE_CHECKING:
3442
import pysb

python/sdist/amici/importers/petab/v1/__init__.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,7 @@
55
PREEQ_INDICATOR_ID = "preequilibration_indicator"
66

77
from .petab_import import import_petab_problem
8-
from .simulations import (
9-
EDATAS,
10-
FIM,
11-
LLH,
12-
RDATAS,
13-
RES,
14-
S2LLH,
15-
SLLH,
16-
SRES,
17-
rdatas_to_measurement_df,
18-
rdatas_to_simulation_df,
19-
simulate_petab,
20-
)
218

229
__all__ = [
2310
"import_petab_problem",
24-
"simulate_petab",
25-
"rdatas_to_simulation_df",
26-
"rdatas_to_measurement_df",
27-
"LLH",
28-
"SLLH",
29-
"FIM",
30-
"S2LLH",
31-
"RES",
32-
"SRES",
33-
"RDATAS",
34-
"EDATAS",
3511
]

python/sdist/amici/sim/sundials/petab/__init__.py

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from ._conditions import create_edatas, create_parameterized_edatas
2+
from ._petab_problem import PetabProblem
3+
from ._simulations import (
4+
EDATAS,
5+
FIM,
6+
LLH,
7+
RDATAS,
8+
RES,
9+
S2LLH,
10+
SLLH,
11+
SRES,
12+
rdatas_to_measurement_df,
13+
rdatas_to_simulation_df,
14+
simulate_petab,
15+
)
16+
from ._simulator import PetabSimulator
17+
18+
__all__ = [
19+
"simulate_petab",
20+
"rdatas_to_simulation_df",
21+
"rdatas_to_measurement_df",
22+
"LLH",
23+
"SLLH",
24+
"FIM",
25+
"S2LLH",
26+
"RES",
27+
"SRES",
28+
"RDATAS",
29+
"EDATAS",
30+
"PetabProblem",
31+
"PetabSimulator",
32+
"create_edatas",
33+
"create_parameterized_edatas",
34+
]

0 commit comments

Comments
 (0)