Skip to content

Commit 84b9d8d

Browse files
authored
Reorganize package: amici.exporters.sundials (#3021)
Move modules and templates related to generating C++ code for simulation with sundials solvers to `amici.exporters.sundials`.
1 parent 2204711 commit 84b9d8d

32 files changed

+87
-87
lines changed

.github/workflows/test_sbml_semantic_test_suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
pull_request:
88
paths:
99
- .github/workflows/test_sbml_semantic_test_suite.yml
10-
- python/sdist/amici/de_export.py
10+
- python/sdist/amici/exporters/sundials/de_export.py
1111
- python/sdist/amici/de_model_components.py
1212
- python/sdist/amici/de_model.py
1313
- python/sdist/amici/sbml_import.py

CMakeLists.txt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ else()
143143
set(VENDORED_SUNDIALS_INSTALL_DIR ${VENDORED_SUNDIALS_BUILD_DIR})
144144
endif()
145145
set(SUNDIALS_ROOT "${VENDORED_SUNDIALS_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}")
146-
find_package(SUNDIALS 7.1.1 REQUIRED CONFIG PATHS "${SUNDIALS_ROOT}/cmake/sundials/" )
146+
find_package(SUNDIALS 7.1.1 REQUIRED CONFIG PATHS
147+
"${SUNDIALS_ROOT}/cmake/sundials/")
147148
message(STATUS "Found SUNDIALS: ${SUNDIALS_DIR}")
148149

149150
set(GSL_LITE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/gsl")
@@ -306,22 +307,25 @@ if(AMICI_PYTHON_BUILD_EXT_ONLY)
306307
"gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION=1")
307308
endif()
308309

309-
# Create targets to make the sources show up in IDEs for convenience
310-
# For template files
311-
add_custom_target(
312-
fileTemplates
313-
SOURCES src/CMakeLists.template.cmake
314-
src/main.template.cpp
315-
src/model_header.template.h
316-
src/model.template.cpp
317-
src/wrapfunctions.template.h
318-
src/wrapfunctions.template.cpp
319-
swig/CMakeLists_model.cmake
320-
swig/modelname.template.i
321-
COMMENT "Dummy target for SWIG files")
322-
set_target_properties(
323-
fileTemplates PROPERTIES INCLUDE_DIRECTORIES
324-
"${CMAKE_CURRENT_SOURCE_DIR}/include/")
310+
if(NOT AMICI_PYTHON_BUILD_EXT_ONLY)
311+
# Create targets to make the sources show up in IDEs for convenience For
312+
# template files
313+
set(template_dir "python/sdist/amici/exporters/sundials/templates")
314+
add_custom_target(
315+
fileTemplates
316+
SOURCES ${template_dir}/CMakeLists.template.cmake
317+
${template_dir}//main.template.cpp
318+
${template_dir}//model_header.template.h
319+
${template_dir}//model.template.cpp
320+
${template_dir}//wrapfunctions.template.h
321+
${template_dir}//wrapfunctions.template.cpp
322+
${template_dir}//CMakeLists_model.cmake
323+
${template_dir}//modelname.template.i
324+
COMMENT "Dummy target for SWIG files")
325+
set_target_properties(
326+
fileTemplates PROPERTIES INCLUDE_DIRECTORIES
327+
"${CMAKE_CURRENT_SOURCE_DIR}/include/")
328+
endif()
325329

326330
if(NOT AMICI_PYTHON_BUILD_EXT_ONLY)
327331
include(clang-tools)

doc/python_modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AMICI Python API
2323
amici.petab.simulator
2424
amici.import_utils
2525
amici.jax
26-
amici.de_export
26+
amici.exporters.sundials.de_export
2727
amici.de_model
2828
amici.de_model_components
2929
amici.plotting

python/sdist/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ recursive-include amici/cmake *
55
recursive-include amici/include/amici *.h
66
recursive-include amici/src *
77
recursive-include amici/swig *
8+
recursive-include amici/exporters/sundials/templates *
89
include amici/*
910
include version.txt
1011
include LICENSE.md

python/sdist/amici/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def get_model_dir(model_id: str | None = None, jax: bool = False) -> Path:
178178
# These modules don't require the swig interface
179179
from typing import Protocol, runtime_checkable
180180

181-
from .de_export import DEExporter # noqa: F401
182181
from .import_utils import MeasurementChannel # noqa: F401
183182
from .sbml_import import ( # noqa: F401
184183
SbmlImporter,

python/sdist/amici/de_model.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
import sympy as sp
1616
from sympy import ImmutableDenseMatrix, MutableDenseMatrix
1717

18-
from ._codegen.cxx_functions import (
19-
nobody_functions,
20-
sensi_functions,
21-
sparse_functions,
22-
var_in_function_signature,
23-
)
24-
from .cxxcodeprinter import csc_matrix
2518
from .de_model_components import (
2619
AlgebraicEquation,
2720
AlgebraicState,
@@ -45,6 +38,13 @@
4538
SigmaZ,
4639
State,
4740
)
41+
from .exporters.sundials.cxx_functions import (
42+
nobody_functions,
43+
sensi_functions,
44+
sparse_functions,
45+
var_in_function_signature,
46+
)
47+
from .exporters.sundials.cxxcodeprinter import csc_matrix
4848
from .import_utils import (
4949
ObservableTransformation,
5050
SBMLException,
@@ -1135,18 +1135,14 @@ def _generate_symbol(self, name: str) -> None:
11351135
components = sorted(
11361136
components,
11371137
key=lambda x: int(
1138-
x.get_id().replace(
1139-
"observableParameter", ""
1140-
)
1138+
x.get_id().replace("observableParameter", "")
11411139
),
11421140
)
11431141
if name == "np":
11441142
components = sorted(
11451143
components,
11461144
key=lambda x: int(
1147-
x.get_id().replace(
1148-
"noiseParameter", ""
1149-
)
1145+
x.get_id().replace("noiseParameter", "")
11501146
),
11511147
)
11521148
self._syms[name] = sp.Matrix(
@@ -1213,8 +1209,7 @@ def _generate_symbol(self, name: str) -> None:
12131209
[
12141210
[
12151211
sp.Symbol(
1216-
f"s{tcl.get_id()}__"
1217-
f"{par.get_id()}",
1212+
f"s{tcl.get_id()}__{par.get_id()}",
12181213
real=True,
12191214
)
12201215
for par in self._parameters

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

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)