Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.28.0 #2581

Merged
merged 16 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .github/workflows/test_benchmark_collection_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,28 @@ jobs:
AMICI_PARALLEL_COMPILE="" pip3 install -v --user \
$(ls -t python/sdist/dist/amici-*.tar.gz | head -1)[petab,test,vis]

- run: |
- name: Install test dependencies
run: |
python3 -m pip uninstall -y petab && python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@develop \
&& python3 -m pip install -U sympy
&& python3 -m pip install -U sympy \
&& python3 -m pip install git+https://github.com/ICB-DCM/fiddy.git

# retrieve test models
- name: Download and test benchmark collection
- name: Download benchmark collection
run: |
git clone --depth 1 https://github.com/benchmarking-initiative/Benchmark-Models-PEtab.git \
&& export BENCHMARK_COLLECTION="$(pwd)/Benchmark-Models-PEtab/Benchmark-Models/" \
&& pip3 install -e $BENCHMARK_COLLECTION/../src/python \
&& AMICI_PARALLEL_COMPILE="" tests/benchmark-models/test_benchmark_collection.sh
&& python3 -m pip install -e Benchmark-Models-PEtab/src/python

- name: Run tests
env:
AMICI_PARALLEL_COMPILE: ""
run: |
cd tests/benchmark-models && pytest --durations=10

# run gradient checks
- name: Run Gradient Checks
# collect & upload results
- name: Aggregate results
run: |
pip install git+https://github.com/ICB-DCM/fiddy.git \
&& cd tests/benchmark-models && pytest --durations=10 ./test_petab_benchmark.py
cd tests/benchmark-models && python3 evaluate_benchmark.py

# upload results
- uses: actions/upload-artifact@v4
with:
name: computation-times-${{ matrix.python-version }}-${{ matrix.extract_subexpressions }}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ jobs:
macos_cpp_py:
name: Tests MacOS C++/Python
runs-on: macos-latest
env:
PYTHONFAULTHANDLER: "1"

steps:
- name: Set up Python
Expand Down Expand Up @@ -291,7 +293,8 @@ jobs:

- name: Python tests
run: |
scripts/run-python-tests.sh \
# ignore warnings until https://github.com/swig/swig/issues/3061 is resolved
scripts/run-python-tests.sh -W ignore:: \
test_pregenerated_models.py \
test_splines_short.py \
test_misc.py
Expand All @@ -300,6 +303,8 @@ jobs:
macos_python:
name: Tests MacOS Python
runs-on: macos-latest
env:
PYTHONFAULTHANDLER: "1"

steps:
- name: Cache
Expand Down Expand Up @@ -351,7 +356,8 @@ jobs:

- name: Python tests
run: |
scripts/run-python-tests.sh \
# ignore warnings until https://github.com/swig/swig/issues/3061 is resolved
scripts/run-python-tests.sh -W ignore:: \
--ignore=test_pregenerated_models.py \
--ignore=test_splines_short.py \
--ignore=test_misc.py
2 changes: 1 addition & 1 deletion .github/workflows/test_python_ver_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- python-version: '3.12'
experimental: false
- python-version: '3.13'
experimental: true
experimental: false

steps:
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
Expand Down
57 changes: 57 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,63 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni

## v0.X Series

### v0.28.0 (2024-11-11)

**Breaking changes**

* Changed the default steady-state method to `integrationOnly`
(by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2574)

The default mode for computing steady states and sensitivities at steady
state was changed to `integrationOnly`
(from previously `integrateIfNewtonFails`).

This was done for a more robust default behavior. For example, the evaluation
in https://doi.org/10.1371/journal.pone.0312148 shows that - at least for
some models - Newton's method may easily lead to physically impossible
solutions.

To keep the previous behavior, use:
```python
amici_model.setSteadyStateComputationMode(amici.SteadyStateComputationMode.integrateIfNewtonFails)
amici_model.setSteadyStateSensitivityMode(amici.SteadyStateSensitivityMode.integrateIfNewtonFails)
```

**Fixes**

* PEtab import: **Fixed potentially incorrect sensitivities** with
observable/state-dependent sigmas.
This was fixed for all cases amici can handle, others cases will now result
in `ValueError`s (https://github.com/AMICI-dev/AMICI/pull/2563).

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2562

* Fixed potentially incorrect disabling of Newton's method

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2576

* Fixed `ModelStateDerived` copy ctor, where previously dangling pointers
could lead to crashes in some situations

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2583

* Added missing simulation status codes

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2560

* Check for unsupported observable IDs in sigma expressions

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2563


**Features**

* Optional warning in `fill_in_parameters`

by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2578

**Full Changelog**: https://github.com/AMICI-dev/AMICI/compare/v0.27.0...v0.28.0

### v0.27.0 (2024-10-21)

This release comes with an **updated version of the SUNDIALS package (7.1.1)** (https://github.com/AMICI-dev/AMICI/pull/2513).
Expand Down
12 changes: 8 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
fixes:
- "build/venv/lib/python3.9/site-packages/::python/"
- "build/venv/lib/python3.10/site-packages/::python/"
- "build/venv/lib/python3.11/site-packages/::python/"
# see https://docs.codecov.com/docs/codecovyml-reference

fixes:
# https://docs.codecov.com/docs/fixing-paths
- "build/venv/lib/python[0-9.]+/site-packages/::python/"
- "python/sdist/build/temp_amici/CMakeFiles/amici.dir/src/::src/"
- "build/CMakeFiles/amici.dir/src/::src/"
codecov:
require_ci_to_pass: yes

Expand All @@ -27,6 +29,8 @@ comment:
ignore:
- "tests/*"
- "tests/**/*"
- "build/tests/**"
- "amici_models/**"

flags:
python:
Expand Down
6 changes: 6 additions & 0 deletions include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ constexpr int AMICI_CONSTR_FAIL= -15;
constexpr int AMICI_CVODES_CONSTR_FAIL= -15;
constexpr int AMICI_IDAS_CONSTR_FAIL= -11;
constexpr int AMICI_ILL_INPUT= -22;
constexpr int AMICI_BAD_T= -25;
constexpr int AMICI_BAD_DKY= -26;
constexpr int AMICI_FIRST_QRHSFUNC_ERR= -32;
constexpr int AMICI_SRHSFUNC_FAIL= -41;
constexpr int AMICI_FIRST_SRHSFUNC_ERR= -42;
constexpr int AMICI_REPTD_SRHSFUNC_ERR= -43;
constexpr int AMICI_UNREC_SRHSFUNC_ERR= -44;
constexpr int AMICI_ERROR= -99;
constexpr int AMICI_NO_STEADY_STATE= -81;
constexpr int AMICI_DAMPING_FACTOR_ERROR= -86;
Expand Down
4 changes: 2 additions & 2 deletions include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2063,12 +2063,12 @@ class Model : public AbstractModel, public ModelDimensions {

/** method for steady-state computation */
SteadyStateComputationMode steadystate_computation_mode_{
SteadyStateComputationMode::integrateIfNewtonFails
SteadyStateComputationMode::integrationOnly
};

/** method for steadystate sensitivities computation */
SteadyStateSensitivityMode steadystate_sensitivity_mode_{
SteadyStateSensitivityMode::integrateIfNewtonFails
SteadyStateSensitivityMode::integrationOnly
};

/**
Expand Down
90 changes: 28 additions & 62 deletions include/amici/model_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,71 +146,37 @@ struct ModelStateDerived {
, dwdw_(other.dwdw_)
, dwdx_hierarchical_(other.dwdx_hierarchical_)
, dJydy_dense_(other.dJydy_dense_) {
// Update the SUNContext of all matrices
if (J_.data()) {
J_.get()->sunctx = sunctx_;
// Update the SUNContext of all SUNDIALS objects
J_.set_ctx(sunctx_);
JB_.set_ctx(sunctx_);
dxdotdw_.set_ctx(sunctx_);
dwdx_.set_ctx(sunctx_);
dwdp_.set_ctx(sunctx_);
M_.set_ctx(sunctx_);
MSparse_.set_ctx(sunctx_);
dfdx_.set_ctx(sunctx_);
dxdotdp_full.set_ctx(sunctx_);
dxdotdp_explicit.set_ctx(sunctx_);
dxdotdp_implicit.set_ctx(sunctx_);
dxdotdx_explicit.set_ctx(sunctx_);
dxdotdx_implicit.set_ctx(sunctx_);
dx_rdatadx_solver.set_ctx(sunctx_);
dx_rdatadtcl.set_ctx(sunctx_);
dtotal_cldx_rdata.set_ctx(sunctx_);
dxdotdp.set_ctx(sunctx_);

for (auto& dJydy : dJydy_) {
dJydy.set_ctx(sunctx_);
}
if (JB_.data()) {
JB_.get()->sunctx = sunctx_;
for (auto& dwdp : dwdp_hierarchical_) {
dwdp.set_ctx(sunctx_);
}
if (dxdotdw_.data()) {
dxdotdw_.get()->sunctx = sunctx_;
}
if (dwdx_.data()) {
dwdx_.get()->sunctx = sunctx_;
}
if (dwdp_.data()) {
dwdp_.get()->sunctx = sunctx_;
}
if (M_.data()) {
M_.get()->sunctx = sunctx_;
}
if (MSparse_.data()) {
MSparse_.get()->sunctx = sunctx_;
}
if (dfdx_.data()) {
dfdx_.get()->sunctx = sunctx_;
}
if (dxdotdp_full.data()) {
dxdotdp_full.get()->sunctx = sunctx_;
}
if (dxdotdp_explicit.data()) {
dxdotdp_explicit.get()->sunctx = sunctx_;
}
if (dxdotdp_implicit.data()) {
dxdotdp_implicit.get()->sunctx = sunctx_;
}
if (dxdotdx_explicit.data()) {
dxdotdx_explicit.get()->sunctx = sunctx_;
}
if (dxdotdx_implicit.data()) {
dxdotdx_implicit.get()->sunctx = sunctx_;
}
if (dx_rdatadx_solver.data()) {
dx_rdatadx_solver.get()->sunctx = sunctx_;
}
if (dx_rdatadtcl.data()) {
dx_rdatadtcl.get()->sunctx = sunctx_;
}
if (dtotal_cldx_rdata.data()) {
dtotal_cldx_rdata.get()->sunctx = sunctx_;
}
for (auto const& dwdp : dwdp_hierarchical_) {
if (dwdp.data()) {
dwdp.get()->sunctx = sunctx_;
}
}
for (auto const& dwdx : dwdx_hierarchical_) {
if (dwdx.data()) {
dwdx.get()->sunctx = sunctx_;
}
}
if (dwdw_.data()) {
dwdw_.get()->sunctx = sunctx_;
}
if (dJydy_dense_.data()) {
dJydy_dense_.get()->sunctx = sunctx_;
for (auto& dwdx : dwdx_hierarchical_) {
dwdx.set_ctx(sunctx_);
}
sspl_.set_ctx(sunctx_);
dwdw_.set_ctx(sunctx_);
dJydy_dense_.set_ctx(sunctx_);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions include/amici/sundials_matrix_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,19 @@ class SUNMatrixWrapper {
*/
SUNContext get_ctx() const;

/**
* @brief Set SUNContext
*
* Update the SUNContext of the wrapped SUNMatrix.
*
* @param ctx SUNDIALS context to set
*/
void set_ctx(SUNContext ctx) {
if (matrix_) {
matrix_->sunctx = ctx;
}
}

private:
/**
* @brief SUNMatrix to which all methods are applied
Expand Down
14 changes: 14 additions & 0 deletions include/amici/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,20 @@
*/
void copy(AmiVectorArray const& other);

/**
* @brief Set SUNContext
*
* If any AmiVector is non-empty, this changes the current SUNContext of the
* associated N_Vector. If empty, do nothing.
*
* @param ctx SUNDIALS context to set
*/
void set_ctx(SUNContext ctx) {
for (auto& vec : vec_array_) {
vec.set_ctx(ctx);

Check warning on line 426 in include/amici/vector.h

View check run for this annotation

Codecov / codecov/patch

include/amici/vector.h#L426

Added line #L426 was not covered by tests
}
}

private:
/** main data storage */
std::vector<AmiVector> vec_array_;
Expand Down
Loading
Loading