Skip to content

Commit 0ee82ef

Browse files
committed
Clean up amici.sim.sundials exports
* Re-export `import_model_module`. * Set `__all__` The goal should be that after having compiled a model, for most applications, the only required import for loading and simulating that model is `amici.sim.sundials`.
1 parent e32d65c commit 0ee82ef

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from types import ModuleType
1212
from typing import Protocol, runtime_checkable
1313

14-
from ... import amici_path
14+
import amici
15+
from amici import amici_path, import_model_module
1516

1617
#: boolean indicating if this is the full package with swig interface or
1718
# the raw package without extension
@@ -22,6 +23,11 @@
2223
#: boolean indicating if amici was compiled with hdf5 support
2324
hdf5_enabled: bool = False
2425

26+
__all__ = [
27+
"import_model_module",
28+
"ModelModule",
29+
]
30+
2531
if has_clibs:
2632
# Import SWIG module and swig-dependent submodules
2733
# if required and available
@@ -37,7 +43,7 @@
3743
message="builtin type .* has no __module__ attribute",
3844
)
3945
# The swig-generated Python module
40-
from amici._installation import amici
46+
from amici._installation import amici as amici_swig_py
4147

4248
# TODO: selective import to avoid loading unneeded symbols
4349
from amici._installation.amici import *
@@ -62,10 +68,26 @@ class ModelModule(Protocol): # noqa: F811
6268
6369
To enable static type checking."""
6470

65-
def get_model(self) -> amici.Model:
71+
def get_model(self) -> amici_swig_py.Model:
6672
"""Create a model instance."""
6773
...
6874

69-
AmiciModel = amici.Model | amici.ModelPtr
75+
AmiciModel = amici_swig_py.Model | amici_swig_py.ModelPtr
76+
77+
from . import _pandas, _swig_wrappers
78+
79+
__all__ += [
80+
*amici._installation.amici.__all__,
81+
"ExpDataView",
82+
"ReturnDataView",
83+
"evaluate",
84+
"ModelModule",
85+
*_pandas.__all__,
86+
*_swig_wrappers.__all__,
87+
"AmiciModel",
88+
]
89+
90+
# expose the swig module itself
91+
amici = amici_swig_py
7092
else:
7193
ModelModule = ModuleType

swig/amici.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ from collections.abc import Sequence
406406
import numpy as np
407407
if TYPE_CHECKING:
408408
import numpy
409-
from .numpy import ReturnDataView
409+
from amici.sim.sundials import ReturnDataView
410410
%}
411411

412412
%pythoncode %{

0 commit comments

Comments
 (0)