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
77 changes: 15 additions & 62 deletions doc/examples/example_jax/ExampleJax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "beb890bd2f3d0880",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"from amici.sim.sundials import SensitivityOrder\n",
"from amici.sim.sundials.petab.v1 import simulate_petab\n",
Expand All @@ -320,7 +319,7 @@
"def amici_callback_base(parameters: jnp.array):\n",
" ret = simulate_petab(\n",
" petab_problem,\n",
" amici_model,\n",
" amici_model=amici_model,\n",
" problem_parameters=dict(zip(petab_problem.x_free_ids, parameters)),\n",
" solver=amici_solver,\n",
" )\n",
Expand All @@ -329,7 +328,8 @@
" tuple(ret[\"sllh\"][par_id] for par_id in petab_problem.x_free_ids)\n",
" )\n",
" return llh, sllh"
]
],
"id": "3fa0df1128a9cb41"
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -477,75 +477,27 @@
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "48451b0e",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"r = simulate_petab(\n",
" petab_problem,\n",
" amici_model,\n",
" amici_model=amici_model,\n",
" solver=amici_solver,\n",
" scaled_parameters=True,\n",
" scaled_gradients=True,\n",
" problem_parameters=scaled_parameters,\n",
")"
]
],
"id": "24a7792cc548dfe2"
},
{
"cell_type": "code",
"execution_count": 12,
"id": "2628db12",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>amici</th>\n",
" <th>jax</th>\n",
" <th>rel_diff</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>llh</th>\n",
" <td>-138.221997</td>\n",
" <td>-138.222</td>\n",
" <td>-2.135248e-08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" amici jax rel_diff\n",
"llh -138.221997 -138.222 -2.135248e-08"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"import pandas as pd\n",
"\n",
Expand All @@ -557,7 +509,8 @@
" ),\n",
" index=(\"llh\",),\n",
")"
]
],
"id": "7f72eab3da313f24"
},
{
"cell_type": "code",
Expand Down
46 changes: 23 additions & 23 deletions doc/examples/example_jax_petab/ExampleJaxPEtab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -598,82 +598,82 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "768fa60e439ca8b4",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"%%timeit\n",
"simulate_petab(\n",
" petab_problem,\n",
" amici_model,\n",
" amici_model=amici_model,\n",
" solver=solver,\n",
" problem_parameters=problem_parameters,\n",
" scaled_parameters=True,\n",
" scaled_gradients=True,\n",
")"
]
],
"id": "42cbc67bc09b67dc"
},
{
"cell_type": "code",
"execution_count": null,
"id": "81fe95a6e7f613f1",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Profile gradient computation using forward sensitivity analysis\n",
"solver.set_sensitivity_order(SensitivityOrder.first)\n",
"solver.set_sensitivity_method(SensitivityMethod.forward)"
]
],
"id": "4f1c06c5893a9c07"
},
{
"cell_type": "code",
"execution_count": null,
"id": "3bae1fab8c416122",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"%%timeit\n",
"simulate_petab(\n",
" petab_problem,\n",
" amici_model,\n",
" amici_model=amici_model,\n",
" solver=solver,\n",
" problem_parameters=problem_parameters,\n",
" scaled_parameters=True,\n",
" scaled_gradients=True,\n",
")"
]
],
"id": "7367a19bcea98597"
},
{
"cell_type": "code",
"execution_count": null,
"id": "71e0358227e1dc74",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"# Profile gradient computation using adjoint sensitivity analysis\n",
"solver.set_sensitivity_order(SensitivityOrder.first)\n",
"solver.set_sensitivity_method(SensitivityMethod.adjoint)"
]
],
"id": "a31e8eda806c2d7"
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3cc7971002b6d06",
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"%%timeit\n",
"simulate_petab(\n",
" petab_problem,\n",
" amici_model,\n",
" amici_model=amici_model,\n",
" solver=solver,\n",
" problem_parameters=problem_parameters,\n",
" scaled_parameters=True,\n",
" scaled_gradients=True,\n",
")"
]
],
"id": "3f2ab1acb3ba818f"
}
],
"metadata": {
Expand Down
10 changes: 4 additions & 6 deletions doc/examples/example_petab/petab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"simulate_petab(petab_problem, amici_model)"
]
"source": "simulate_petab(petab_problem, amici_model=amici_model)"
},
{
"cell_type": "markdown",
Expand All @@ -100,10 +98,10 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"parameters = {\n",
" x_id: x_val\n",
Expand All @@ -114,7 +112,7 @@
"}\n",
"simulate_petab(\n",
" petab_problem,\n",
" amici_model,\n",
" amici_model=amici_model,\n",
" problem_parameters=parameters,\n",
" scaled_parameters=True,\n",
")"
Expand Down
2 changes: 2 additions & 0 deletions python/sdist/amici/adapters/fiddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def derivative(point: Type.POINT, return_dict: bool = False):

def simulate_petab_to_cached_functions(
petab_problem: petab.Problem,
*,
amici_model: Model,
free_parameter_ids: list[str] = None,
cache: bool = True,
Expand Down Expand Up @@ -363,6 +364,7 @@ def derivative(point: Type.POINT) -> Type.POINT:

def simulate_petab_v2_to_cached_functions(
petab_simulator: PetabSimulator,
*,
free_parameter_ids: list[str] = None,
cache: bool = True,
) -> tuple[Type.FUNCTION, Type.FUNCTION]:
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/importers/antimony/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def antimony2sbml(ant_model: str | Path) -> str:
return sbml_str


def antimony2amici(ant_model: str | Path, *args, **kwargs):
def antimony2amici(ant_model: str | Path, **kwargs):
"""Convert Antimony model to AMICI model.

Converts the Antimony model provided as string or file to SBML and then
Expand All @@ -66,4 +66,4 @@ def antimony2amici(ant_model: str | Path, *args, **kwargs):

sbml_str = antimony2sbml(ant_model)
sbml_importer = SbmlImporter(sbml_str, from_file=False)
return sbml_importer.sbml2amici(*args, **kwargs)
return sbml_importer.sbml2amici(**kwargs)
7 changes: 2 additions & 5 deletions python/sdist/amici/importers/bngl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
]


def bngl2amici(bngl_model: str, *args, **kwargs) -> None:
def bngl2amici(bngl_model: str, **kwargs) -> None:
r"""
Generate AMICI C++ files for the provided model.

:param bngl_model:
bngl model file, model name will determine the name of the generated
module

:param args:
see :func:`amici.importers.pysb.pysb2amici` for additional arguments

:param kwargs:
see :func:`amici.importers.pysb.pysb2amici` for additional arguments

"""
if "model" in kwargs:
raise ValueError("model argument not allowed")
pysb_model = model_from_bngl(bngl_model)
pysb2amici(pysb_model, *args, **kwargs)
pysb2amici(pysb_model, **kwargs)
1 change: 1 addition & 0 deletions python/sdist/amici/importers/petab/v1/petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
def import_petab_problem(
petab_problem: petab.Problem,
model_output_dir: str | Path | None = None,
*,
model_name: str = None,
compile_: bool = None,
non_estimated_parameters_as_constants=True,
Expand Down
2 changes: 2 additions & 0 deletions python/sdist/amici/importers/pysb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
def pysb2jax(
model: pysb.Model,
output_dir: str | Path | None = None,
*,
observation_model: list[MeasurementChannel] = None,
verbose: int | bool = False,
compute_conservation_laws: bool = True,
Expand Down Expand Up @@ -163,6 +164,7 @@ def pysb2jax(
def pysb2amici(
model: pysb.Model,
output_dir: str | Path | None = None,
*,
observation_model: list[MeasurementChannel] = None,
fixed_parameters: list[str] = None,
verbose: int | bool = False,
Expand Down
2 changes: 2 additions & 0 deletions python/sdist/amici/importers/sbml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class SbmlImporter:
def __init__(
self,
sbml_source: str | Path | libsbml.Model,
*,
show_sbml_warnings: bool = False,
from_file: bool = True,
discard_annotations: bool = False,
Expand Down Expand Up @@ -261,6 +262,7 @@ def sbml2amici(
self,
model_name: str,
output_dir: str | Path = None,
*,
fixed_parameters: Iterable[str] = None,
observation_model: list[MeasurementChannel] = None,
verbose: int | bool = logging.ERROR,
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/importers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class MeasurementChannel:
def __init__(
self,
id_: str,
*,
name: str | None = None,
formula: str | sp.Expr | None = None,
noise_distribution: str | Callable[[str], str] | None = None,
Expand Down
Loading
Loading