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

Refactor amici.ode_export, add AmiciCxxCodePrinter #1610

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Dec 6, 2021

Move custom codeprinting to a separate code printer class and reuse the same instance for all printing.
Avoids plenty of reinstantiations of the code printer and keeps all settings in one place.

@dweindl dweindl marked this pull request as draft December 6, 2021 20:31
@dweindl dweindl force-pushed the refactor_odeexport branch from 94afaef to 8095d96 Compare December 6, 2021 21:35
Move custom codeprinting to a separate code printer class and reuse the same instance for all printing.
Avoids plenty of reinstantiations of the code printer and keeps all settings in one place.
@dweindl dweindl force-pushed the refactor_odeexport branch from 8095d96 to 469c8cb Compare December 6, 2021 21:35
@dweindl dweindl changed the title Refactor amici.ode_export: code printing to ODEExporter Refactor amici.ode_export, add AmiciCxxCodePrinter Dec 6, 2021
@codecov
Copy link

codecov bot commented Dec 6, 2021

Codecov Report

Merging #1610 (469c8cb) into develop (81ae628) will increase coverage by 0.04%.
The diff coverage is 92.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1610      +/-   ##
===========================================
+ Coverage    78.76%   78.80%   +0.04%     
===========================================
  Files           67       68       +1     
  Lines        10683    10666      -17     
===========================================
- Hits          8414     8405       -9     
+ Misses        2269     2261       -8     
Flag Coverage Δ
cpp 75.31% <ø> (-0.07%) ⬇️
petab 67.11% <89.33%> (+0.26%) ⬆️
python 68.24% <92.00%> (+0.22%) ⬆️
sbmlsuite 87.60% <70.58%> (+0.42%) ⬆️

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

Impacted Files Coverage Δ
python/amici/__init__.py 92.39% <ø> (ø)
python/amici/ode_export.py 93.62% <82.35%> (+1.19%) ⬆️
python/amici/cxxcodeprinter.py 94.82% <94.82%> (ø)
src/amici.cpp 67.96% <0.00%> (-5.47%) ⬇️
src/exception.cpp 74.19% <0.00%> (ø)
src/solver_cvodes.cpp 71.10% <0.00%> (ø)
src/sundials_matrix_wrapper.cpp 82.33% <0.00%> (+0.45%) ⬆️

@dweindl dweindl requested a review from FFroehlich December 6, 2021 22:26
@dweindl dweindl marked this pull request as ready for review December 6, 2021 22:26
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

87.3% 87.3% Coverage
0.0% 0.0% Duplication

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.

👍 nice cleanup!

@@ -3114,7 +3027,7 @@ def _get_function_body(self,
f'reinitialization_state_idxs.cend(), {index}) != '
'reinitialization_state_idxs.cend())',
f' {function}[{index}] = '
f'{_print_with_exception(formula)};'
f'{self.model._code_printer.doprint(formula)};'
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it make more sense to have _code_printer as member of the exporter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fully agreed. The problem is that ODEModel also generates code (which I think should be changed, but maybe rather separately). Having it in ODEModel for now allows using it also in ODEExporter, but not vice versa.

@dweindl dweindl merged commit 9094cf1 into develop Dec 6, 2021
@dweindl dweindl deleted the refactor_odeexport branch December 6, 2021 22:50
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.

2 participants