Skip to content
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
8 changes: 5 additions & 3 deletions doc/examples/example_errors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
" import_model_module,\n",
")\n",
"from amici.importers.petab.v1 import (\n",
" EDATAS,\n",
" RDATAS,\n",
" import_petab_problem,\n",
" simulate_petab,\n",
")\n",
"from amici.sim.sundials import (\n",
" AMICI_SUCCESS,\n",
Expand All @@ -44,6 +41,11 @@
" simulation_status_to_str,\n",
" unscale_parameter,\n",
")\n",
"from amici.sim.sundials.petab.v1 import (\n",
" EDATAS,\n",
" RDATAS,\n",
" simulate_petab,\n",
")\n",
"from amici.sim.sundials.plotting import plot_jacobian, plot_state_trajectories\n",
"from petab.v1.sbml import get_sbml_model\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/example_jax/ExampleJax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@
"metadata": {},
"outputs": [],
"source": [
"from amici.importers.petab.v1 import simulate_petab\n",
"from amici.sim.sundials import SensitivityOrder\n",
"from amici.sim.sundials.petab.v1 import simulate_petab\n",
"\n",
"amici_solver = amici_model.create_solver()\n",
"amici_solver.set_sensitivity_order(SensitivityOrder.first)\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/example_jax_petab/ExampleJaxPEtab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@
"metadata": {},
"outputs": [],
"source": [
"from amici.importers.petab.v1 import simulate_petab\n",
"from amici.sim.sundials import SensitivityMethod, SensitivityOrder\n",
"from amici.sim.sundials.petab.v1 import simulate_petab\n",
"\n",
"# Import the PEtab problem as a standard AMICI model\n",
"amici_model = import_petab_problem(\n",
Expand Down
7 changes: 2 additions & 5 deletions doc/examples/example_petab/petab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
"outputs": [],
"source": [
"import petab\n",
"from amici.importers.petab.v1 import (\n",
" import_petab_problem,\n",
" simulate_petab,\n",
")\n",
"from amici.importers.petab.v1.petab_problem import PetabProblem\n",
"from amici.importers.petab.v1 import import_petab_problem\n",
"from amici.sim.sundials import run_simulation\n",
"from amici.sim.sundials.petab.v1 import PetabProblem, simulate_petab\n",
"from amici.sim.sundials.plotting import plot_state_trajectories"
]
},
Expand Down
4 changes: 1 addition & 3 deletions doc/python_modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ AMICI Python API
amici.importers.antimony
amici.importers.petab
amici.importers.petab.v1
amici.importers.petab.v1.conditions
amici.importers.petab.v1.import_helpers
amici.importers.petab.v1.parameter_mapping
amici.importers.petab.v1.petab_import
amici.importers.petab.v1.pysb_import
amici.importers.petab.v1.sbml_import
amici.importers.petab.v1.simulations
amici.importers.petab.v1.simulator
amici.jax
amici.exporters.sundials.de_export
amici.sim.sundials
amici.sim.sundials.plotting
amici.sim.sundials.gradient_check
amici.sim.sundials.petab.v1
amici.logging
amici.adapters.fiddy
8 changes: 3 additions & 5 deletions python/sdist/amici/adapters/fiddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
from fiddy import CachedFunction, Type, fiddy_array
from petab.v1.C import LIN, LOG, LOG10

import amici
import amici.importers.petab.v1.simulations
from amici.importers.petab import LLH, SLLH
from amici.importers.petab.v1.conditions import create_edatas
from amici.importers.petab.v1.parameter_mapping import create_parameter_mapping
from amici.sim.sundials import (
AmiciExpData,
Expand All @@ -31,6 +28,7 @@
SensitivityOrder,
run_simulation,
)
from amici.sim.sundials.petab.v1._conditions import create_edatas

if TYPE_CHECKING:
from amici.importers.petab import PetabSimulator
Expand Down Expand Up @@ -297,7 +295,7 @@ def simulate_petab_to_cached_functions(
**kwargs,
) -> tuple[Type.FUNCTION, Type.FUNCTION]:
"""
Convert :func:`amici.petab.simulations.simulate_petab`
Convert :func:`amici.sim.sundials.petab.v1.simulate_petab`
(PEtab v1 simulations) to fiddy functions.

Note that all gradients are provided on linear scale. The correction from
Expand Down Expand Up @@ -333,7 +331,7 @@ def simulate_petab_to_cached_functions(
free_parameter_ids = list(petab_problem.parameter_df.index)

if simulate_petab is None:
simulate_petab = amici.importers.petab.v1.simulations.simulate_petab
from amici.sim.sundials.petab.v1._simulations import simulate_petab

edatas = None
if precreate_edatas:
Expand Down
10 changes: 9 additions & 1 deletion python/sdist/amici/importers/petab/_petab_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@
from amici.importers.utils import MeasurementChannel, amici_time_symbol
from amici.logging import get_logger
from amici.sim.sundials import SensitivityOrder
from amici.sim.sundials.petab.v1._simulations import (
EDATAS,
LLH,
RDATAS,
RES,
S2LLH,
SLLH,
SRES,
)

from .v1.sbml_import import _add_global_parameter
from .v1.simulations import EDATAS, LLH, RDATAS, RES, S2LLH, SLLH, SRES

if TYPE_CHECKING:
import pysb
Expand Down
24 changes: 0 additions & 24 deletions python/sdist/amici/importers/petab/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,7 @@
PREEQ_INDICATOR_ID = "preequilibration_indicator"

from .petab_import import import_petab_problem
from .simulations import (
EDATAS,
FIM,
LLH,
RDATAS,
RES,
S2LLH,
SLLH,
SRES,
rdatas_to_measurement_df,
rdatas_to_simulation_df,
simulate_petab,
)

__all__ = [
"import_petab_problem",
"simulate_petab",
"rdatas_to_simulation_df",
"rdatas_to_measurement_df",
"LLH",
"SLLH",
"FIM",
"S2LLH",
"RES",
"SRES",
"RDATAS",
"EDATAS",
]
Empty file.
34 changes: 34 additions & 0 deletions python/sdist/amici/sim/sundials/petab/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from ._conditions import create_edatas, create_parameterized_edatas
from ._petab_problem import PetabProblem
from ._simulations import (
EDATAS,
FIM,
LLH,
RDATAS,
RES,
S2LLH,
SLLH,
SRES,
rdatas_to_measurement_df,
rdatas_to_simulation_df,
simulate_petab,
)
from ._simulator import PetabSimulator

__all__ = [
"simulate_petab",
"rdatas_to_simulation_df",
"rdatas_to_measurement_df",
"LLH",
"SLLH",
"FIM",
"S2LLH",
"RES",
"SRES",
"RDATAS",
"EDATAS",
"PetabProblem",
"PetabSimulator",
"create_edatas",
"create_parameterized_edatas",
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@
TIME,
)

from amici.sim.sundials import (
AmiciModel,
ExpData,
parameter_scaling_from_int_vector,
)

from .parameter_mapping import (
from amici.importers.petab.v1.parameter_mapping import (
ParameterMapping,
ParameterMappingForCondition,
petab_to_amici_scale,
scale_parameters_dict,
unscale_parameters_dict,
)
from .util import get_states_in_condition_table
from amici.importers.petab.v1.util import get_states_in_condition_table
from amici.sim.sundials import (
AmiciModel,
ExpData,
parameter_scaling_from_int_vector,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -283,7 +282,9 @@ def create_parameterized_edatas(

# Get parameter mapping
if parameter_mapping is None:
from .parameter_mapping import create_parameter_mapping
from amici.importers.petab.v1.parameter_mapping import (
create_parameter_mapping,
)

parameter_mapping = create_parameter_mapping(
petab_problem=petab_problem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
from petab.v1.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID

import amici

from .conditions import create_edatas, fill_in_parameters
from .parameter_mapping import create_parameter_mapping
from amici.importers.petab.v1.parameter_mapping import create_parameter_mapping
from amici.sim.sundials.petab.v1._conditions import (
create_edatas,
fill_in_parameters,
)


class PetabProblem:
Expand Down Expand Up @@ -50,7 +52,7 @@ def __init__(
if amici_model is not None:
self._amici_model = amici_model
else:
from .petab_import import import_petab_problem
from amici.importers.petab.v1 import import_petab_problem

self._amici_model = import_petab_problem(petab_problem)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
from petab.v1.C import * # noqa: F403

import amici
from amici.importers.petab.v1.parameter_mapping import (
ParameterMapping,
create_parameter_mapping,
)
from amici.logging import get_logger, log_execution_time
from amici.sim.sundials import (
AMICI_SUCCESS,
Expand All @@ -27,15 +31,10 @@
SensitivityOrder,
run_simulations,
)

from .conditions import (
from amici.sim.sundials.petab.v1._conditions import (
create_edatas,
fill_in_parameters,
)
from .parameter_mapping import (
ParameterMapping,
create_parameter_mapping,
)

logger = get_logger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import pandas as pd
import petab.v1 as petab

from amici.importers.petab.v1.petab_import import import_petab_problem
from amici.sim.sundials import AmiciModel, SensitivityMethod

from .petab_import import import_petab_problem
from .simulations import RDATAS, rdatas_to_measurement_df, simulate_petab
from ._simulations import RDATAS, rdatas_to_measurement_df, simulate_petab

AMICI_MODEL = "amici_model"
AMICI_SOLVER = "solver"
Expand Down
2 changes: 1 addition & 1 deletion python/tests/adapters/test_fiddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import amici
import amici.importers.petab.v1.petab_import
import amici.importers.petab.v1.simulations
import amici.sim.sundials.petab.v1._simulations
import numpy as np
import pytest
from amici.adapters.fiddy import (
Expand Down
2 changes: 1 addition & 1 deletion python/tests/petab_/test_petab_problem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from amici.importers.petab.v1 import import_petab_problem
from amici.importers.petab.v1.petab_problem import PetabProblem
from amici.sim.sundials.petab.v1._petab_problem import PetabProblem
from amici.testing import skip_on_valgrind
from benchmark_models_petab import get_problem

Expand Down
12 changes: 7 additions & 5 deletions python/tests/splines_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
import petab.v1 as petab
import sympy as sp
from amici.importers.petab.v1 import (
EDATAS,
LLH,
RDATAS,
SLLH,
import_petab_problem,
simulate_petab,
)
from amici.importers.sbml.splines import (
AbstractSpline,
Expand All @@ -41,6 +36,13 @@
)
from amici.sim.sundials import run_simulation
from amici.sim.sundials.gradient_check import _check_results
from amici.sim.sundials.petab.v1 import (
EDATAS,
LLH,
RDATAS,
SLLH,
simulate_petab,
)
from amici.testing import TemporaryDirectoryWinSafe as TemporaryDirectory
from petab.v1.models.sbml_model import SbmlModel

Expand Down
3 changes: 2 additions & 1 deletion python/tests/test_petab_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import pandas as pd
import petab.v1 as petab
import pytest
from amici.importers.petab.v1 import SLLH, import_petab_problem, simulate_petab
from amici.importers.petab.v1 import import_petab_problem
from amici.sim.sundials import SensitivityOrder
from amici.sim.sundials.petab.v1 import SLLH, simulate_petab
from amici.testing import skip_on_valgrind

# Absolute and relative tolerances for finite difference gradient checks.
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_petab_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import petab.v1 as petab
import petabtests
import pytest
from amici.importers.petab.v1.simulator import PetabSimulator
from amici.sim.sundials.petab.v1 import PetabSimulator
from amici.testing import skip_on_valgrind


Expand Down
12 changes: 7 additions & 5 deletions tests/benchmark_models/test_petab_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
simulate_petab_v2_to_cached_functions,
)
from amici.importers.petab.v1 import (
LLH,
RDATAS,
SLLH,
import_petab_problem,
rdatas_to_measurement_df,
simulate_petab,
)
from amici.logging import get_logger
from amici.sim.sundials import (
Expand All @@ -40,6 +35,13 @@
SteadyStateComputationMode,
SteadyStateSensitivityMode,
)
from amici.sim.sundials.petab.v1 import (
LLH,
RDATAS,
SLLH,
rdatas_to_measurement_df,
simulate_petab,
)
from fiddy import MethodId, get_derivative
from fiddy.derivative_check import NumpyIsCloseDerivativeCheck
from fiddy.success import Consistency
Expand Down
Loading
Loading