Skip to content

Commit 6a4fa65

Browse files
committed
Require kwargs
Require keyword arguments for a couple of functions. Closes #3099.
1 parent a724161 commit 6a4fa65

File tree

26 files changed

+120
-136
lines changed

26 files changed

+120
-136
lines changed

doc/examples/example_jax/ExampleJax.ipynb

Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,10 @@
304304
]
305305
},
306306
{
307-
"cell_type": "code",
308-
"execution_count": null,
309-
"id": "beb890bd2f3d0880",
310307
"metadata": {},
308+
"cell_type": "code",
311309
"outputs": [],
310+
"execution_count": null,
312311
"source": [
313312
"from amici.sim.sundials import SensitivityOrder\n",
314313
"from amici.sim.sundials.petab.v1 import simulate_petab\n",
@@ -320,7 +319,7 @@
320319
"def amici_callback_base(parameters: jnp.array):\n",
321320
" ret = simulate_petab(\n",
322321
" petab_problem,\n",
323-
" amici_model,\n",
322+
" amici_model=amici_model,\n",
324323
" problem_parameters=dict(zip(petab_problem.x_free_ids, parameters)),\n",
325324
" solver=amici_solver,\n",
326325
" )\n",
@@ -329,7 +328,8 @@
329328
" tuple(ret[\"sllh\"][par_id] for par_id in petab_problem.x_free_ids)\n",
330329
" )\n",
331330
" return llh, sllh"
332-
]
331+
],
332+
"id": "3fa0df1128a9cb41"
333333
},
334334
{
335335
"cell_type": "markdown",
@@ -477,75 +477,27 @@
477477
]
478478
},
479479
{
480-
"cell_type": "code",
481-
"execution_count": 11,
482-
"id": "48451b0e",
483480
"metadata": {},
481+
"cell_type": "code",
484482
"outputs": [],
483+
"execution_count": null,
485484
"source": [
486485
"r = simulate_petab(\n",
487486
" petab_problem,\n",
488-
" amici_model,\n",
487+
" amici_model=amici_model,\n",
489488
" solver=amici_solver,\n",
490489
" scaled_parameters=True,\n",
491490
" scaled_gradients=True,\n",
492491
" problem_parameters=scaled_parameters,\n",
493492
")"
494-
]
493+
],
494+
"id": "24a7792cc548dfe2"
495495
},
496496
{
497-
"cell_type": "code",
498-
"execution_count": 12,
499-
"id": "2628db12",
500497
"metadata": {},
501-
"outputs": [
502-
{
503-
"data": {
504-
"text/html": [
505-
"<div>\n",
506-
"<style scoped>\n",
507-
" .dataframe tbody tr th:only-of-type {\n",
508-
" vertical-align: middle;\n",
509-
" }\n",
510-
"\n",
511-
" .dataframe tbody tr th {\n",
512-
" vertical-align: top;\n",
513-
" }\n",
514-
"\n",
515-
" .dataframe thead th {\n",
516-
" text-align: right;\n",
517-
" }\n",
518-
"</style>\n",
519-
"<table border=\"1\" class=\"dataframe\">\n",
520-
" <thead>\n",
521-
" <tr style=\"text-align: right;\">\n",
522-
" <th></th>\n",
523-
" <th>amici</th>\n",
524-
" <th>jax</th>\n",
525-
" <th>rel_diff</th>\n",
526-
" </tr>\n",
527-
" </thead>\n",
528-
" <tbody>\n",
529-
" <tr>\n",
530-
" <th>llh</th>\n",
531-
" <td>-138.221997</td>\n",
532-
" <td>-138.222</td>\n",
533-
" <td>-2.135248e-08</td>\n",
534-
" </tr>\n",
535-
" </tbody>\n",
536-
"</table>\n",
537-
"</div>"
538-
],
539-
"text/plain": [
540-
" amici jax rel_diff\n",
541-
"llh -138.221997 -138.222 -2.135248e-08"
542-
]
543-
},
544-
"execution_count": 12,
545-
"metadata": {},
546-
"output_type": "execute_result"
547-
}
548-
],
498+
"cell_type": "code",
499+
"outputs": [],
500+
"execution_count": null,
549501
"source": [
550502
"import pandas as pd\n",
551503
"\n",
@@ -557,7 +509,8 @@
557509
" ),\n",
558510
" index=(\"llh\",),\n",
559511
")"
560-
]
512+
],
513+
"id": "7f72eab3da313f24"
561514
},
562515
{
563516
"cell_type": "code",

doc/examples/example_jax_petab/ExampleJaxPEtab.ipynb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -598,82 +598,82 @@
598598
]
599599
},
600600
{
601-
"cell_type": "code",
602-
"execution_count": null,
603-
"id": "768fa60e439ca8b4",
604601
"metadata": {},
602+
"cell_type": "code",
605603
"outputs": [],
604+
"execution_count": null,
606605
"source": [
607606
"%%timeit\n",
608607
"simulate_petab(\n",
609608
" petab_problem,\n",
610-
" amici_model,\n",
609+
" amici_model=amici_model,\n",
611610
" solver=solver,\n",
612611
" problem_parameters=problem_parameters,\n",
613612
" scaled_parameters=True,\n",
614613
" scaled_gradients=True,\n",
615614
")"
616-
]
615+
],
616+
"id": "42cbc67bc09b67dc"
617617
},
618618
{
619-
"cell_type": "code",
620-
"execution_count": null,
621-
"id": "81fe95a6e7f613f1",
622619
"metadata": {},
620+
"cell_type": "code",
623621
"outputs": [],
622+
"execution_count": null,
624623
"source": [
625624
"# Profile gradient computation using forward sensitivity analysis\n",
626625
"solver.set_sensitivity_order(SensitivityOrder.first)\n",
627626
"solver.set_sensitivity_method(SensitivityMethod.forward)"
628-
]
627+
],
628+
"id": "4f1c06c5893a9c07"
629629
},
630630
{
631-
"cell_type": "code",
632-
"execution_count": null,
633-
"id": "3bae1fab8c416122",
634631
"metadata": {},
632+
"cell_type": "code",
635633
"outputs": [],
634+
"execution_count": null,
636635
"source": [
637636
"%%timeit\n",
638637
"simulate_petab(\n",
639638
" petab_problem,\n",
640-
" amici_model,\n",
639+
" amici_model=amici_model,\n",
641640
" solver=solver,\n",
642641
" problem_parameters=problem_parameters,\n",
643642
" scaled_parameters=True,\n",
644643
" scaled_gradients=True,\n",
645644
")"
646-
]
645+
],
646+
"id": "7367a19bcea98597"
647647
},
648648
{
649-
"cell_type": "code",
650-
"execution_count": null,
651-
"id": "71e0358227e1dc74",
652649
"metadata": {},
650+
"cell_type": "code",
653651
"outputs": [],
652+
"execution_count": null,
654653
"source": [
655654
"# Profile gradient computation using adjoint sensitivity analysis\n",
656655
"solver.set_sensitivity_order(SensitivityOrder.first)\n",
657656
"solver.set_sensitivity_method(SensitivityMethod.adjoint)"
658-
]
657+
],
658+
"id": "a31e8eda806c2d7"
659659
},
660660
{
661-
"cell_type": "code",
662-
"execution_count": null,
663-
"id": "e3cc7971002b6d06",
664661
"metadata": {},
662+
"cell_type": "code",
665663
"outputs": [],
664+
"execution_count": null,
666665
"source": [
667666
"%%timeit\n",
668667
"simulate_petab(\n",
669668
" petab_problem,\n",
670-
" amici_model,\n",
669+
" amici_model=amici_model,\n",
671670
" solver=solver,\n",
672671
" problem_parameters=problem_parameters,\n",
673672
" scaled_parameters=True,\n",
674673
" scaled_gradients=True,\n",
675674
")"
676-
]
675+
],
676+
"id": "3f2ab1acb3ba818f"
677677
}
678678
],
679679
"metadata": {

doc/examples/example_petab/petab.ipynb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@
8888
"execution_count": null,
8989
"metadata": {},
9090
"outputs": [],
91-
"source": [
92-
"simulate_petab(petab_problem, amici_model)"
93-
]
91+
"source": "simulate_petab(petab_problem, amici_model=amici_model)"
9492
},
9593
{
9694
"cell_type": "markdown",
@@ -100,10 +98,10 @@
10098
]
10199
},
102100
{
103-
"cell_type": "code",
104-
"execution_count": null,
105101
"metadata": {},
102+
"cell_type": "code",
106103
"outputs": [],
104+
"execution_count": null,
107105
"source": [
108106
"parameters = {\n",
109107
" x_id: x_val\n",
@@ -114,7 +112,7 @@
114112
"}\n",
115113
"simulate_petab(\n",
116114
" petab_problem,\n",
117-
" amici_model,\n",
115+
" amici_model=amici_model,\n",
118116
" problem_parameters=parameters,\n",
119117
" scaled_parameters=True,\n",
120118
")"

python/sdist/amici/adapters/fiddy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def derivative(point: Type.POINT, return_dict: bool = False):
240240

241241
def simulate_petab_to_cached_functions(
242242
petab_problem: petab.Problem,
243+
*,
243244
amici_model: Model,
244245
free_parameter_ids: list[str] = None,
245246
cache: bool = True,
@@ -363,6 +364,7 @@ def derivative(point: Type.POINT) -> Type.POINT:
363364

364365
def simulate_petab_v2_to_cached_functions(
365366
petab_simulator: PetabSimulator,
367+
*,
366368
free_parameter_ids: list[str] = None,
367369
cache: bool = True,
368370
) -> tuple[Type.FUNCTION, Type.FUNCTION]:

python/sdist/amici/importers/antimony/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def antimony2sbml(ant_model: str | Path) -> str:
5454
return sbml_str
5555

5656

57-
def antimony2amici(ant_model: str | Path, *args, **kwargs):
57+
def antimony2amici(ant_model: str | Path, **kwargs):
5858
"""Convert Antimony model to AMICI model.
5959
6060
Converts the Antimony model provided as string or file to SBML and then
@@ -66,4 +66,4 @@ def antimony2amici(ant_model: str | Path, *args, **kwargs):
6666

6767
sbml_str = antimony2sbml(ant_model)
6868
sbml_importer = SbmlImporter(sbml_str, from_file=False)
69-
return sbml_importer.sbml2amici(*args, **kwargs)
69+
return sbml_importer.sbml2amici(**kwargs)

python/sdist/amici/importers/bngl/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,19 @@
1616
]
1717

1818

19-
def bngl2amici(bngl_model: str, *args, **kwargs) -> None:
19+
def bngl2amici(bngl_model: str, **kwargs) -> None:
2020
r"""
2121
Generate AMICI C++ files for the provided model.
2222
2323
:param bngl_model:
2424
bngl model file, model name will determine the name of the generated
2525
module
2626
27-
:param args:
28-
see :func:`amici.importers.pysb.pysb2amici` for additional arguments
29-
3027
:param kwargs:
3128
see :func:`amici.importers.pysb.pysb2amici` for additional arguments
3229
3330
"""
3431
if "model" in kwargs:
3532
raise ValueError("model argument not allowed")
3633
pysb_model = model_from_bngl(bngl_model)
37-
pysb2amici(pysb_model, *args, **kwargs)
34+
pysb2amici(pysb_model, **kwargs)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
def import_petab_problem(
4242
petab_problem: petab.Problem,
4343
model_output_dir: str | Path | None = None,
44+
*,
4445
model_name: str = None,
4546
compile_: bool = None,
4647
non_estimated_parameters_as_constants=True,

python/sdist/amici/importers/pysb/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
def pysb2jax(
6767
model: pysb.Model,
6868
output_dir: str | Path | None = None,
69+
*,
6970
observation_model: list[MeasurementChannel] = None,
7071
verbose: int | bool = False,
7172
compute_conservation_laws: bool = True,
@@ -163,6 +164,7 @@ def pysb2jax(
163164
def pysb2amici(
164165
model: pysb.Model,
165166
output_dir: str | Path | None = None,
167+
*,
166168
observation_model: list[MeasurementChannel] = None,
167169
fixed_parameters: list[str] = None,
168170
verbose: int | bool = False,

python/sdist/amici/importers/sbml/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class SbmlImporter:
9797
def __init__(
9898
self,
9999
sbml_source: str | Path | libsbml.Model,
100+
*,
100101
show_sbml_warnings: bool = False,
101102
from_file: bool = True,
102103
discard_annotations: bool = False,
@@ -261,6 +262,7 @@ def sbml2amici(
261262
self,
262263
model_name: str,
263264
output_dir: str | Path = None,
265+
*,
264266
fixed_parameters: Iterable[str] = None,
265267
observation_model: list[MeasurementChannel] = None,
266268
verbose: int | bool = logging.ERROR,

python/sdist/amici/importers/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class MeasurementChannel:
132132
def __init__(
133133
self,
134134
id_: str,
135+
*,
135136
name: str | None = None,
136137
formula: str | sp.Expr | None = None,
137138
noise_distribution: str | Callable[[str], str] | None = None,

0 commit comments

Comments
 (0)