Skip to content

Commit 11813ec

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 11813ec

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

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

Lines changed: 25 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 *
@@ -47,6 +53,7 @@
4753
# from .swig_wrappers
4854
hdf5_enabled = "read_solver_settings_from_hdf5" in dir()
4955
# These modules require the swig interface and other dependencies
56+
from . import _pandas, _swig_wrappers
5057
from ._numpy import ExpDataView as ExpDataView
5158
from ._numpy import ReturnDataView as ReturnDataView
5259
from ._numpy import evaluate as evaluate
@@ -62,10 +69,24 @@ class ModelModule(Protocol): # noqa: F811
6269
6370
To enable static type checking."""
6471

65-
def get_model(self) -> amici.Model:
72+
def get_model(self) -> amici_swig_py.Model:
6673
"""Create a model instance."""
6774
...
6875

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

0 commit comments

Comments
 (0)