Skip to content

Commit 97a66dd

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

File tree

17 files changed

+91
-74
lines changed

17 files changed

+91
-74
lines changed

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+
]

python/sdist/amici/importers/petab/v1/conditions.py renamed to python/sdist/amici/sim/sundials/petab/v1/_conditions.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@
1919
TIME,
2020
)
2121

22-
from amici.sim.sundials import (
23-
AmiciModel,
24-
ExpData,
25-
parameter_scaling_from_int_vector,
26-
)
27-
28-
from .parameter_mapping import (
22+
from amici.importers.petab.v1.parameter_mapping import (
2923
ParameterMapping,
3024
ParameterMappingForCondition,
3125
petab_to_amici_scale,
3226
scale_parameters_dict,
3327
unscale_parameters_dict,
3428
)
35-
from .util import get_states_in_condition_table
29+
from amici.importers.petab.v1.util import get_states_in_condition_table
30+
from amici.sim.sundials import (
31+
AmiciModel,
32+
ExpData,
33+
parameter_scaling_from_int_vector,
34+
)
3635

3736
logger = logging.getLogger(__name__)
3837

python/sdist/amici/importers/petab/v1/petab_problem.py renamed to python/sdist/amici/sim/sundials/petab/v1/_petab_problem.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
from petab.v1.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID
1010

1111
import amici
12-
13-
from .conditions import create_edatas, fill_in_parameters
14-
from .parameter_mapping import create_parameter_mapping
12+
from amici.importers.petab.v1.parameter_mapping import create_parameter_mapping
13+
from amici.sim.sundials.petab.v1._conditions import (
14+
create_edatas,
15+
fill_in_parameters,
16+
)
1517

1618

1719
class PetabProblem:

python/sdist/amici/importers/petab/v1/simulations.py renamed to python/sdist/amici/sim/sundials/petab/v1/_simulations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
from petab.v1.C import * # noqa: F403
1818

1919
import amici
20+
from amici.importers.petab.v1.parameter_mapping import (
21+
ParameterMapping,
22+
create_parameter_mapping,
23+
)
2024
from amici.logging import get_logger, log_execution_time
2125
from amici.sim.sundials import (
2226
AMICI_SUCCESS,
@@ -27,15 +31,10 @@
2731
SensitivityOrder,
2832
run_simulations,
2933
)
30-
31-
from .conditions import (
34+
from amici.sim.sundials.petab.v1._conditions import (
3235
create_edatas,
3336
fill_in_parameters,
3437
)
35-
from .parameter_mapping import (
36-
ParameterMapping,
37-
create_parameter_mapping,
38-
)
3938

4039
logger = get_logger(__name__)
4140

0 commit comments

Comments
 (0)