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

Fix get_model_settings for initial states + sensitivities #1751

Merged
merged 9 commits into from
Apr 4, 2022

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Mar 30, 2022

Fixes a couple of issues in amici.{get,set}_model_settings

  • Initial states and initial state sensitivities should only be included if custom values have been set. Otherwise, set_model_settings(model, get_model_settings(model)) will permanently set the given values, preventing evaluation of Model::fx0 / Model::fsx0.

    Fixes MultiProcessEngine results in incorrect ensemble prediction trajectories in the sampling diagnostics notebook ICB-DCM/pyPESTO#837

  • If a model had custom initial state sensitivities set, those would not have been set correctly by set_model_settings(model, get_model_settings(model)), because setParameter{List,Scale} was called after setInitialStateSensitivities and cleared initial state sensitivities. (Even if they would have been set, they would have been wrong in case of scaled parameters, due to using setInitialStateSensitivities instead of setUnscaledInitialStateSensitivities).

Initial states and initial state sensitivities should only be included if custom values have been set. Otherwise, `set_model_settings(model, get_model_settings(model))` will permanently set the given values, preventing evaluation of `Model::fx0` / `Model::fsx0`.

Fixes ICB-DCM/pyPESTO#837
@codecov
Copy link

codecov bot commented Mar 30, 2022

Codecov Report

Merging #1751 (695ddf7) into develop (5634d37) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1751      +/-   ##
===========================================
+ Coverage    77.76%   77.77%   +0.01%     
===========================================
  Files           74       74              
  Lines        12012    12018       +6     
===========================================
+ Hits          9341     9347       +6     
  Misses        2671     2671              
Flag Coverage Δ
cpp 74.86% <ø> (ø)
petab 59.18% <0.00%> (-0.09%) ⬇️
python 68.24% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/amici/swig_wrappers.py 94.91% <100.00%> (+0.57%) ⬆️
src/sundials_matrix_wrapper.cpp 80.08% <0.00%> (-0.45%) ⬇️
src/model.cpp 86.31% <0.00%> (+0.15%) ⬆️

Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Thanks a lot!

Copy link
Member

@FFroehlich FFroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, do we want to add a test for this?

@dweindl
Copy link
Member Author

dweindl commented Mar 31, 2022

makes sense, do we want to add a test for this?

Yes. Helped to discover another 2 old issues and 1 newly introduced issue...

@dweindl dweindl requested a review from FFroehlich March 31, 2022 10:05
@sonarcloud
Copy link

sonarcloud bot commented Apr 4, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

18.8% 18.8% Coverage
0.0% 0.0% Duplication

@dweindl dweindl merged commit 3d4975c into develop Apr 4, 2022
@dweindl dweindl deleted the fix_get_model_settings branch April 4, 2022 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants