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

Python splines #1515

Merged
merged 438 commits into from
May 11, 2023
Merged

Python splines #1515

merged 438 commits into from
May 11, 2023

Conversation

paulstapor
Copy link
Contributor

This one is to replace #1245. However, it seems like in the long time of divergence, there were changes to functions from sbml_import, that may be not captured, as these functions have been moved out of sbml_import.py to sbml_utils.py on the python_splines branch... It looks like automatic merge of these files did not do completely the right thing... So, we have to be careful about functions that have been moved to newly created files, it seems...

@paulstapor paulstapor changed the base branch from master to develop June 17, 2021 15:15
@dweindl dweindl mentioned this pull request Sep 9, 2021
25 tasks
@dweindl dweindl changed the title New attempt to get the splines merged Python splines Sep 9, 2021
src/symbolic_functions.cpp Outdated Show resolved Hide resolved
src/splinefunctions.cpp Outdated Show resolved Hide resolved
src/splinefunctions.cpp Outdated Show resolved Hide resolved
@dweindl
Copy link
Member

dweindl commented Nov 5, 2021

ping @lcontento

include/amici/splinefunctions.h Outdated Show resolved Hide resolved
include/amici/splinefunctions.h Outdated Show resolved Hide resolved
include/amici/splinefunctions.h Outdated Show resolved Hide resolved
include/amici/splinefunctions.h Outdated Show resolved Hide resolved
include/amici/splinefunctions.h Outdated Show resolved Hide resolved
python/amici/sbml_utils.py Outdated Show resolved Hide resolved
python/amici/sbml_utils.py Outdated Show resolved Hide resolved
python/amici/splines.py Outdated Show resolved Hide resolved
src/model.cpp Outdated
Comment on lines 1985 to 1991
if (splines_[ispl].get_logarithmic_parametrization()) {
sspl_data[ispl + nspl * ip] =
state_.spl_[ispl] * splines_[ispl].getSensitivity(t, ip);
} else {
sspl_data[ispl + nspl * ip] =
splines_[ispl].getSensitivity(t, ip);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can/should that if not go into getSensitivity?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

If we put the if inside then we would have to recompute the spline value for each parameter, while in this way we can recycle it.

Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in the other comment, I honestly think the if belongs logically inside the spline methods, but with the current method signature I would not move it. If we had a method that computes both spline value and spline sensitivities at the same time it would be better though in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

see comment regarding same problem in sensitivity computation

Copy link
Member

Choose a reason for hiding this comment

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

If I understand it correctly, this could be addressed by having get_{value,sensitivity} and get_unscaled_{value,sensitivity}? Here, we'd use the former, and where required inside splinesfunctions.cpp, we'd use the latter?

src/model.cpp Outdated
Comment on lines 1972 to 1976
if (splines_[ispl].get_logarithmic_parametrization()) {
state_.spl_[ispl] = std::exp(splines_[ispl].getValue(t));
} else {
state_.spl_[ispl] = splines_[ispl].getValue(t);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can/should that if not go into getValue?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can and I think it should, not sure if there is any reason why Paul put it outside.
I can try putting inside getValue and see if anything breaks.

dweindl added a commit that referenced this pull request Dec 4, 2021
@codecov
Copy link

codecov bot commented Dec 5, 2021

Codecov Report

Merging #1515 (71735b6) into develop (81d32e7) will increase coverage by 0.50%.
The diff coverage is 80.15%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1515      +/-   ##
===========================================
+ Coverage    75.56%   76.06%   +0.50%     
===========================================
  Files           76       80       +4     
  Lines        13126    14679    +1553     
===========================================
+ Hits          9919    11166    +1247     
- Misses        3207     3513     +306     
Flag Coverage Δ
cpp 73.47% <79.65%> (+0.49%) ⬆️
petab 49.14% <20.69%> (-5.77%) ⬇️
python 76.79% <80.49%> (+7.92%) ⬆️
sbmlsuite ∅ <ø> (∅)

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

Impacted Files Coverage Δ
include/amici/abstract_model.h 0.00% <ø> (ø)
include/amici/model.h 56.00% <ø> (ø)
include/amici/model_state.h 100.00% <ø> (ø)
python/sdist/amici/petab_import.py 69.41% <ø> (ø)
python/sdist/amici/pysb_import.py 91.94% <ø> (ø)
src/spline.cpp 65.59% <ø> (ø)
include/amici/splinefunctions.h 33.33% <33.33%> (ø)
src/splinefunctions.cpp 77.22% <77.22%> (ø)
python/sdist/amici/sbml_import.py 75.98% <77.77%> (-0.13%) ⬇️
python/sdist/amici/splines.py 78.90% <78.90%> (ø)
... and 5 more

... and 5 files with indirect coverage changes

dweindl added a commit that referenced this pull request Dec 6, 2021
Make _print_with_exception, _get_sym_lines_array, and _get_sym_lines_symbols class methods of ODEExporter, as they may need to consider model-specific user_functions.

Prerequisite for #1515.
src/splinefunctions.cpp Outdated Show resolved Hide resolved
dweindl added a commit that referenced this pull request Dec 7, 2021
* Use class instead of dict for function info, to simplify default argument handling and to find more easily where the respective values are used.

* Allow specifying non-void return type.

* Remove redundant virtual with override

* Cleanup.

Will simplify some changes in #1515
@dweindl dweindl mentioned this pull request Dec 7, 2021
dweindl added a commit that referenced this pull request Dec 8, 2021
* Refactor ODE export

* Use class instead of dict for function info, to simplify default argument handling and to find more easily where the respective values are used.

* Allow specifying non-void return type.

* Remove redundant virtual with override

* Cleanup.

Will simplify some changes in #1515

Co-authored-by: Fabian Fröhlich <[email protected]>
python/amici/ode_export.py Outdated Show resolved Hide resolved
python/amici/sbml_utils.py Outdated Show resolved Hide resolved
src/model.cpp Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 6, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

0.0% 0.0% Coverage
7.8% 7.8% Duplication

@dweindl dweindl modified the milestones: v0.17.0, v0.18.0 May 9, 2023
This reverts commit 9eedc54.
@dweindl dweindl enabled auto-merge May 11, 2023 08:50
Copy link
Member

@dweindl dweindl left a comment

Choose a reason for hiding this comment

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

TODO: #2081

@dweindl dweindl added this pull request to the merge queue May 11, 2023
Merged via the queue into develop with commit 8c63c73 May 11, 2023
@dweindl dweindl deleted the python_splines_before_merge branch November 3, 2023 13:59
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.

How to encode splines in the python or C++ interface?
4 participants