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

More informative Solver.__repr__ #1928

Merged
merged 6 commits into from
Jan 13, 2023
Merged

More informative Solver.__repr__ #1928

merged 6 commits into from
Jan 13, 2023

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Jan 13, 2023

Closes #1926

Output of print(amici.CVodeSolver()):

<Swig Object of type 'amici::CVodeSolver *' at 0x7f988f70f090
  reporting_mode: <RDataReporting.full: 0>
  sens_meth: <SensitivityMethod.forward: 1>
  sens_order: <SensitivityOrder.none: 0>
  sens_meth_preeq: <SensitivityMethod.forward: 1>
  maxsteps: 10000
  maxtime: 1.7976931348623157e+308s
  abs_tol: 1e-16
  rel_tol: 1e-08
  abs_tol_b: 1e-16
  rel_tol_b: 1e-08
  abs_tol_fsa: 1e-16
  rel_tol_fsa: 1e-08
  abs_tol_quad: 1e-12
  rel_tol_quad: 1e-08
  abs_tol_ss: 1e-14
  rel_tol_ss: 1e-06
  abs_tol_sss: 1e-14
  rel_tol_sss: 1e-06
  int_sens_meth: <InternalSensitivityMethod.simultaneous: 1>
  int_type: <InterpolationType.hermite: 1>
  linsol: <LinearSolver.KLU: 9>
  lmm: <LinearMultistepMethod.BDF: 2>
  newton_damp_mode: <NewtonDampingFactorMode.on: 1>
  newton_damp_lb: 1e-08
  newton_maxsteps: 0
  newton_ss_check: False
  sens_ss_check: True
  interpolation_type: <InterpolationType.hermite: 1>
  ism: <InternalSensitivityMethod.simultaneous: 1>
  nlsol_iter: <NonlinearSolverIteration.newton: 2>
  stability_limit: True
  state_ordering: 0
>

Closes #1926

Output of `print(amici.CVodeSolver())`:

```
<Swig Object of type 'amici::CVodeSolver *' at 0x7f988f70f090
  reporting_mode: <RDataReporting.full: 0>
  sens_meth: <SensitivityMethod.forward: 1>
  sens_order: <SensitivityOrder.none: 0>
  sens_order: <SensitivityMethod.forward: 1>
  maxsteps: 10000
  maxtime: 1.7976931348623157e+308s
  abs_tol: 1e-16
  rel_tol: 1e-08
  abs_tol_b: 1e-16
  rel_tol_b: 1e-08
  abs_tol_fsa: 1e-16
  rel_tol_fsa: 1e-08
  abs_tol_quad: 1e-12
  rel_tol_quad: 1e-08
  abs_tol_ss: 1e-14
  rel_tol_ss: 1e-06
  abs_tol_sss: 1e-14
  rel_tol_sss: 1e-06
  int_sens_meth: <InternalSensitivityMethod.simultaneous: 1>
  int_type: <InterpolationType.hermite: 1>
  linsol: <LinearSolver.KLU: 9>
  lmm: <LinearMultistepMethod.BDF: 2>
  newton_damp_mode: <NewtonDampingFactorMode.on: 1>
  newton_damp_lb: 1e-08
  newton_maxsteps: 0
  newton_ss_check: False
  sens_ss_check: True
  interpolation_type: <InterpolationType.hermite: 1>
  ism: <InternalSensitivityMethod.simultaneous: 1>
  nlsol_iter: <NonlinearSolverIteration.newton: 2>
  stability_limit: True
  state_ordering: 0
>
```
@dweindl dweindl requested a review from FFroehlich January 13, 2023 14:44
@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Merging #1928 (56fc8f3) into develop (63826a7) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1928      +/-   ##
===========================================
- Coverage    76.01%   76.01%   -0.01%     
===========================================
  Files           76       76              
  Lines        12967    12969       +2     
===========================================
+ Hits          9857     9858       +1     
- Misses        3110     3111       +1     
Flag Coverage Δ
cpp 73.15% <ø> (+0.01%) ⬆️
petab 59.71% <0.00%> (-0.03%) ⬇️
python 69.03% <0.00%> (-0.04%) ⬇️
sbmlsuite ?

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

Impacted Files Coverage Δ
python/sdist/amici/swig.py 31.14% <0.00%> (-1.06%) ⬇️
src/sundials_matrix_wrapper.cpp 81.02% <0.00%> (+0.20%) ⬆️

@FFroehlich
Copy link
Member

Closes #1926

Output of print(amici.CVodeSolver()):

<Swig Object of type 'amici::CVodeSolver *' at 0x7f988f70f090
  reporting_mode: <RDataReporting.full: 0>
  sens_meth: <SensitivityMethod.forward: 1>
  sens_order: <SensitivityOrder.none: 0>
  sens_meth_preeq: <SensitivityMethod.forward: 1>
  maxsteps: 10000
  maxtime: 1.7976931348623157e+308s
  abs_tol: 1e-16
  rel_tol: 1e-08
  abs_tol_b: 1e-16
  rel_tol_b: 1e-08
  abs_tol_fsa: 1e-16
  rel_tol_fsa: 1e-08
  abs_tol_quad: 1e-12
  rel_tol_quad: 1e-08
  abs_tol_ss: 1e-14
  rel_tol_ss: 1e-06
  abs_tol_sss: 1e-14
  rel_tol_sss: 1e-06
  int_sens_meth: <InternalSensitivityMethod.simultaneous: 1>
  int_type: <InterpolationType.hermite: 1>
  linsol: <LinearSolver.KLU: 9>
  lmm: <LinearMultistepMethod.BDF: 2>
  newton_damp_mode: <NewtonDampingFactorMode.on: 1>
  newton_damp_lb: 1e-08
  newton_maxsteps: 0
  newton_ss_check: False
  sens_ss_check: True
  interpolation_type: <InterpolationType.hermite: 1>
  ism: <InternalSensitivityMethod.simultaneous: 1>
  nlsol_iter: <NonlinearSolverIteration.newton: 2>
  stability_limit: True
  state_ordering: 0
>

👍 neat, does this also work for SolverPtr out of the box?


def test_solver_repr_doesnt_raise():
print(amici.CVodeSolver())
print(repr(amici.CVodeSolver()))
Copy link
Member

Choose a reason for hiding this comment

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

isn't the default __repr__ set by swig anyways (as for self.this anyway), so this wouldn't have raised even before these changes?

@dweindl
Copy link
Member Author

dweindl commented Jan 13, 2023

does this also work for SolverPtr out of the box?

Good point. Now it does.

isn't the default repr set by swig anyways (as for self.this anyway), so this wouldn't have raised even before these changes?

That's correct. It was mostly intended to check that no non-existing ReturnData fields are accessed. Now it also checks that it is not just the default __repr__.

@sonarqubecloud
Copy link

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 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@dweindl dweindl merged commit 11a1f27 into develop Jan 13, 2023
@dweindl dweindl deleted the solver_repr branch January 13, 2023 18:51
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