Skip to content

Commit

Permalink
Merge branch 'develop' into refactor_event
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Dec 1, 2023
2 parents 2e584e6 + c174c40 commit 82fde3f
Show file tree
Hide file tree
Showing 67 changed files with 2,099 additions and 1,976 deletions.
3 changes: 2 additions & 1 deletion .github/actions/setup-sonar-tools/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ runs:

- name: Install sonarcloud tools
run: |
sudo apt-get install nodejs curl unzip \
sudo apt-get update \
&& sudo apt-get install nodejs curl unzip \
&& curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip \
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip \
&& unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ jobs:
sudo apt-get update \
&& sudo apt-get install -y \
pandoc \
python3-venv
&& pip install tox
- name: Set up SWIG
uses: ./.github/actions/setup-swig

- name: Run sphinx
run: scripts/run-sphinx.sh
run: tox -e doc
21 changes: 10 additions & 11 deletions documentation/ExampleJax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"output_type": "stream",
"text": [
"Cloning into 'tmp/benchmark-models'...\n",
"remote: Enumerating objects: 336, done.\u001b[K\n",
"remote: Counting objects: 100% (336/336), done.\u001b[K\n",
"remote: Compressing objects: 100% (285/285), done.\u001b[K\n",
"remote: Total 336 (delta 88), reused 216 (delta 39), pack-reused 0\u001b[K\n",
"remote: Enumerating objects: 336, done.\u001B[K\n",
"remote: Counting objects: 100% (336/336), done.\u001B[K\n",
"remote: Compressing objects: 100% (285/285), done.\u001B[K\n",
"remote: Total 336 (delta 88), reused 216 (delta 39), pack-reused 0\u001B[K\n",
"Receiving objects: 100% (336/336), 2.11 MiB | 7.48 MiB/s, done.\n",
"Resolving deltas: 100% (88/88), done.\n"
]
Expand Down Expand Up @@ -557,8 +557,7 @@
"clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c swig/Boehm_JProteomeRes2014_wrap.cpp -o build/temp.macosx-13-arm64-cpython-310/swig/Boehm_JProteomeRes2014_wrap.o -std=c++14\n",
"clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c wrapfunctions.cpp -o build/temp.macosx-13-arm64-cpython-310/wrapfunctions.o -std=c++14\n",
"clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_Jy.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydsigma.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dsigmaydp.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dydx.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_sigmay.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_sx0_fixedParameters.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_w.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x0.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x0_fixedParameters.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x_rdata.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x_solver.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_xdot.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_y.o build/temp.macosx-13-arm64-cpython-310/swig/Boehm_JProteomeRes2014_wrap.o build/temp.macosx-13-arm64-cpython-310/wrapfunctions.o -L/opt/homebrew/Cellar/hdf5/1.12.2_2/lib -L/Users/fabian/Documents/projects/AMICI/python/sdist/amici/libs -lamici -lsundials -lsuitesparse -lcblas -lhdf5_hl_cpp -lhdf5_hl -lhdf5_cpp -lhdf5 -o /Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014/Boehm_JProteomeRes2014/_Boehm_JProteomeRes2014.cpython-310-darwin.so\n",
"ld: warning: -undefined dynamic_lookup may not work with chained fixups\n",
"\n"
"ld: warning: -undefined dynamic_lookup may not work with chained fixups\n"
]
},
{
Expand All @@ -571,7 +570,7 @@
}
],
"source": [
"from amici.petab_import import import_petab_problem\n",
"from amici.petab.petab_import import import_petab_problem\n",
"\n",
"amici_model = import_petab_problem(petab_problem, force_compile=True)"
]
Expand All @@ -589,7 +588,7 @@
"id": "e2ef051a",
"metadata": {},
"source": [
"For full jax support, we would have to implement a new [primitive](https://jax.readthedocs.io/en/latest/notebooks/How_JAX_primitives_work.html), which would require quite a bit of engineering, and in the end wouldn't add much benefit since AMICI can't run on GPUs. Instead will interface AMICI using the experimental jax module [`host_callback`](https://jax.readthedocs.io/en/latest/jax.experimental.host_callback.html). "
"For full jax support, we would have to implement a new [primitive](https://jax.readthedocs.io/en/latest/notebooks/How_JAX_primitives_work.html), which would require quite a bit of engineering, and in the end wouldn't add much benefit since AMICI can't run on GPUs. Instead, we will interface AMICI using the experimental jax module [`host_callback`](https://jax.readthedocs.io/en/latest/jax.experimental.host_callback.html). "
]
},
{
Expand All @@ -607,7 +606,7 @@
"metadata": {},
"outputs": [],
"source": [
"from amici.petab_objective import simulate_petab\n",
"from amici.petab.simulations import simulate_petab\n",
"import amici\n",
"\n",
"amici_solver = amici_model.getSolver()\n",
Expand Down Expand Up @@ -655,7 +654,7 @@
"id": "98e819bd",
"metadata": {},
"source": [
"Now we can finally define the JAX function that runs amici simulation using the host callback. We add a `custom_jvp` decorater so that we can define a custom jacobian vector product function in the next step. More details about custom jacobian vector product functions can be found in the [JAX documentation](https://jax.readthedocs.io/en/latest/notebooks/Custom_derivative_rules_for_Python_code.html)"
"Now we can finally define the JAX function that runs amici simulation using the host callback. We add a `custom_jvp` decorator so that we can define a custom jacobian vector product function in the next step. More details about custom jacobian vector product functions can be found in the [JAX documentation](https://jax.readthedocs.io/en/latest/notebooks/Custom_derivative_rules_for_Python_code.html)"
]
},
{
Expand Down Expand Up @@ -937,7 +936,7 @@
"metadata": {},
"source": [
"We see quite some differences in the gradient calculation. The primary reason is that running JAX in default configuration will use float32 precision for the parameters that are passed to AMICI, which uses float64, and the derivative of the parameter transformation \n",
"As AMICI simulations that run on the CPU are the most expensive operation, there is barely any tradeoff for using float32 vs float64 in JAX. Therefore we configure JAX to use float64 instead and rerun simulations."
"As AMICI simulations that run on the CPU are the most expensive operation, there is barely any tradeoff for using float32 vs float64 in JAX. Therefore, we configure JAX to use float64 instead and rerun simulations."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions documentation/GettingStarted.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"metadata": {},
"source": [
"## Model Compilation\n",
"Before simulations can be run, the model must be imported and compiled. In this process, AMICI performs all symbolic manipulations that later enable scalable simulations and efficient sensitivity computation. The first step towards model compilation is the creation of an [SbmlImporter](https://amici.readthedocs.io/en/latest/generated/amici.sbml_import.SbmlImporter.html) instance, which requires an SBML Document that specifies the model using the [Systems Biology Markup Language (SBML)](http://sbml.org/Main_Page). \n",
"Before simulations can be run, the model must be imported and compiled. In this process, AMICI performs all symbolic manipulations that later enable scalable simulations and efficient sensitivity computation. The first step towards model compilation is the creation of an [SbmlImporter](https://amici.readthedocs.io/en/latest/generated/amici.sbml_import.SbmlImporter.html) instance, which requires an SBML Document that specifies the model using the [Systems Biology Markup Language (SBML)](https://sbml.org/). \n",
"\n",
"For the purpose of this tutorial, we will use `model_steadystate_scaled.xml`, which is contained in the same directory as this notebook."
]
Expand Down Expand Up @@ -113,7 +113,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Model simulations can be executed using the [amici.runAmiciSimulations](https://amici.readthedocs.io/en/latest/generated/amici.html#amici.runAmiciSimulation) routine. By default the model does not not contain any timepoints for which the model is to be simulated. Here we define a simulation timecourse with two timepoints at `0` and `1` and then run the simulation."
"Model simulations can be executed using the [amici.runAmiciSimulations](https://amici.readthedocs.io/en/latest/generated/amici.html#amici.runAmiciSimulation) routine. By default, the model does not contain any timepoints for which the model is to be simulated. Here we define a simulation timecourse with two timepoints at `0` and `1` and then run the simulation."
]
},
{
Expand Down
8 changes: 1 addition & 7 deletions documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The legacy GitHub Pages URL https://amici-dev.github.io/AMICI/ is set up as a
redirect to RTD.

The main configuration file is `documentation/conf.py` and the documentation
is generated using `scripts/run-sphinx.sh`. The documentation is written to
is generated using `tox -e doc`. The documentation is written to
`documentation/_build/`.

The documentation comprises:
Expand Down Expand Up @@ -50,12 +50,6 @@ Matlab documentation is processed by
[mtoc++](https://www.morepas.org/software/mtocpp/docs/tools.html).
This is configured in `matlab/mtoc/config`.

#### Python documentation

Python documentation is processed by doxygen and doxypypy using the script and
filters in `scripts/`.


## Writing documentation

### Out-of-source documentation
Expand Down
3 changes: 2 additions & 1 deletion documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ def process_signature(
return

# only apply in the amici.amici module
if name.split(".")[1] != "amici":
split_name = name.split(".")
if len(split_name) < 2 or split_name[1] != "amici":
return

signature = fix_typehints(signature)
Expand Down
16 changes: 15 additions & 1 deletion documentation/python_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ Install the AMICI dependencies via ``pacman``
sudo pacman -S python swig openblas gcc hdf5 boost-libs
Export the bash variables ``BLAS_CFLAGS`` and ``BLAS_LIBS`` to point to where BLAS was installed, e.g.:

.. code-block:: bash
export BLAS_CFLAGS="-I/usr/include/openblas/"
export BLAS_LIBS="-lopenblas"
Install AMICI:

.. code-block:: bash
Expand All @@ -99,7 +106,14 @@ Alternatively:
sudo pacman -Su python swig openblas gcc hdf5 boost-libs
3. Install AMICI:
3. Export the bash variables ``BLAS_CFLAGS`` and ``BLAS_LIBS`` to point to where BLAS was installed, e.g.:

.. code-block:: bash
export BLAS_CFLAGS="-I/usr/include/openblas/"
export BLAS_LIBS="-lopenblas"
4. Install AMICI:

.. code-block:: bash
Expand Down
8 changes: 8 additions & 0 deletions documentation/python_modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ AMICI Python API
amici.sbml_import
amici.pysb_import
amici.bngl_import
amici.petab
amici.petab.import_helpers
amici.petab.parameter_mapping
amici.petab.petab_import
amici.petab.pysb_import
amici.petab.sbml_import
amici.petab.simulations
amici.petab.simulator
amici.petab_import
amici.petab_import_pysb
amici.petab_objective
Expand Down
14 changes: 7 additions & 7 deletions documentation/rtd_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# NOTE: relative paths are expected to be relative to the repository root
sphinx<7
sphinx
mock>=5.0.2
setuptools==67.7.2
setuptools>=67.7.2
pysb>=1.11.0
matplotlib==3.7.1
nbsphinx==0.9.1
nbformat==5.8.0
recommonmark>=0.7.1
sphinx_rtd_theme>=1.2.0
petab[vis]>=0.2.0
sphinx-autodoc-typehints==1.23.0
sphinx-autodoc-typehints
git+https://github.com/readthedocs/sphinx-hoverxref@main
ipython==8.13.2
breathe==4.35.0
ipython>=8.13.2
breathe>=4.35.0
#exhale>=0.3.5
-e git+https://github.com/mithro/sphinx-contrib-mithro#egg=sphinx-contrib-exhale-multiproject&subdirectory=sphinx-contrib-exhale-multiproject
sphinxcontrib-matlabdomain<0.19.0
sphinxcontrib-matlabdomain>=0.20.0
sphinxcontrib-napoleon>=0.7
pygments==2.15.1
pygments>=2.15.1
Jinja2==3.1.2
git+https://github.com/readthedocs/readthedocs-sphinx-ext
ipykernel
Expand Down
2 changes: 1 addition & 1 deletion documentation/rtd_requirements2.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exhale>=0.3.6
-e git+https://github.com/svenevs/exhale.git@a1a8551321e246e3ab81f5456e04a8159804595b#egg=exhale
1 change: 0 additions & 1 deletion include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#endif

#include <cmath>
#include <functional>

/* Math constants in case _USE_MATH_DEFINES is not supported */
#if defined(_USE_MATH_DEFINES)
Expand Down
5 changes: 2 additions & 3 deletions include/amici/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <algorithm>
#include <ctime>
#include <functional>
#include <memory>
#include <regex>
#include <vector>

Expand Down Expand Up @@ -291,7 +290,7 @@ class CpuTimer {
return d_milliseconds(clock::now() - start_).count();
}

static const bool uses_thread_clock = true;
static bool const uses_thread_clock = true;

private:
/** Start time */
Expand Down Expand Up @@ -330,7 +329,7 @@ class CpuTimer {
/ CLOCKS_PER_SEC;
}

static const bool uses_thread_clock = false;
static bool const uses_thread_clock = false;

private:
/** Start time */
Expand Down
1 change: 0 additions & 1 deletion include/amici/model_dae.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sunmatrix/sunmatrix_sparse.h>

#include <numeric>
#include <utility>
#include <vector>

namespace amici {
Expand Down
1 change: 0 additions & 1 deletion include/amici/model_ode.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sunmatrix/sunmatrix_dense.h>
#include <sunmatrix/sunmatrix_sparse.h>

#include <utility>
#include <vector>

namespace amici {
Expand Down
5 changes: 1 addition & 4 deletions include/amici/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
#include "amici/solver.h"
#include "amici/solver_cvodes.h"

#include <cassert>
#include <chrono>
#include <fstream>
#include <iostream>

#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
Expand All @@ -35,7 +32,7 @@ template <class Archive, typename T>
void archiveVector(Archive& ar, T** p, int size) {
if (Archive::is_loading::value) {
if (*p != nullptr)
delete[] * p;
delete[] *p;
ar& size;
*p = size ? new T[size] : nullptr;
} else {
Expand Down
1 change: 0 additions & 1 deletion include/amici/spline.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef amici_spline_h
#define amici_spline_h
#include <math.h>

namespace amici {

Expand Down
1 change: 0 additions & 1 deletion include/amici/steadystateproblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <nvector/nvector_serial.h>

#include <functional>
#include <memory>

namespace amici {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"from IPython.display import Image\n",
"\n",
"fig = Image(\n",
" filename=(\"../../../documentation/gfx/steadystate_solver_workflow.png\")\n",
" filename=\"../../../documentation/gfx/steadystate_solver_workflow.png\"\n",
")\n",
"fig"
]
Expand Down Expand Up @@ -97,12 +97,9 @@
],
"source": [
"import libsbml\n",
"import importlib\n",
"import amici\n",
"import os\n",
"import sys\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# SBML model we want to import\n",
"sbml_file = \"model_constant_species.xml\"\n",
Expand Down Expand Up @@ -397,7 +394,7 @@
" * `-5`: Error: The model was simulated past the timepoint `t=1e100` without finding a steady state. Therefore, it is likely that the model has not steady state for the given parameter vector.\n",
"\n",
"Here, only the second entry of `posteq_status` contains a positive integer: The first run of Newton's method failed due to a Jacobian, which oculd not be factorized, but the second run (simulation) contains the entry 1 (success). The third entry is 0, thus Newton's method was not launched for a second time.\n",
"More information can be found in`posteq_numsteps`: Also here, only the second entry contains a positive integer, which is smaller than the maximum number of steps taken (<1000). Hence steady state was reached via simulation, which corresponds to the simulated time written to `posteq_time`.\n",
"More information can be found in`posteq_numsteps`: Also here, only the second entry contains a positive integer, which is smaller than the maximum number of steps taken (<1000). Hence, steady state was reached via simulation, which corresponds to the simulated time written to `posteq_time`.\n",
"\n",
"We want to demonstrate a complete failure if inferring the steady state by reducing the number of integration steps to a lower value:"
]
Expand Down Expand Up @@ -951,7 +948,7 @@
}
],
"source": [
"# Singluar Jacobian, use simulation\n",
"# Singular Jacobian, use simulation\n",
"model.setSteadyStateSensitivityMode(\n",
" amici.SteadyStateSensitivityMode.integrateIfNewtonFails\n",
")\n",
Expand Down Expand Up @@ -1207,7 +1204,7 @@
}
],
"source": [
"# Non-singular Jacobian, use simulaiton\n",
"# Non-singular Jacobian, use simulation\n",
"model_reduced.setSteadyStateSensitivityMode(\n",
" amici.SteadyStateSensitivityMode.integrateIfNewtonFails\n",
")\n",
Expand Down
Loading

0 comments on commit 82fde3f

Please sign in to comment.