Skip to content

Add Model.simulate#2963

Merged
dweindl merged 1 commit intoAMICI-dev:mainfrom
dweindl:gh-2944-simulate
Oct 17, 2025
Merged

Add Model.simulate#2963
dweindl merged 1 commit intoAMICI-dev:mainfrom
dweindl:gh-2944-simulate

Conversation

@dweindl
Copy link
Member

@dweindl dweindl commented Oct 6, 2025

Replace Complement the old amici.runAmiciSimulation, amici.runAmiciSimulations by with something more convenient.

Related to #2944.

@dweindl dweindl self-assigned this Oct 6, 2025
@dweindl
Copy link
Member Author

dweindl commented Oct 6, 2025

Here a first draft.

@FFroehlich @dilpath: Would that work for you? Any better suggestions?

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.46%. Comparing base (a666ef9) to head (6c2d9cc).
⚠️ Report is 111 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2963      +/-   ##
==========================================
- Coverage   76.51%   74.46%   -2.05%     
==========================================
  Files         307      302       -5     
  Lines       19992    19849     -143     
  Branches     1500     1500              
==========================================
- Hits        15296    14781     -515     
- Misses       4683     5055     +372     
  Partials       13       13              
Flag Coverage Δ
cpp 72.00% <100.00%> (+<0.01%) ⬆️
cpp_python 38.18% <11.53%> (-0.04%) ⬇️
petab ?
python 69.58% <100.00%> (+<0.01%) ⬆️
sbmlsuite-jax ?

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

Files with missing lines Coverage Δ
python/sdist/amici/__init__.py 96.07% <ø> (ø)
python/sdist/amici/swig_wrappers.py 98.76% <100.00%> (+0.58%) ⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Works for me 👍 I would also be fine with removing Model.simulate_multiple and instead adapting Model.simulate to support edatas = ExpData | list[ExpData].

solver.setSensitivityOrder(amici.SensitivityOrder.first)
solver.setSensitivityMethod(amici.SensitivityMethod.forward)
rdata = amici.runAmiciSimulation(model, solver)
rdata = model.simulate(sensi_order="first", sensi_method="forward")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rdata = model.simulate(sensi_order="first", sensi_method="forward")
rdata = model.simulate(sensi_order=amici.SensitivityOrder.first, sensi_method=amici.SensitivityMethod.forward)

Copy link
Member Author

Choose a reason for hiding this comment

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

Both are supported. I like the former, because it's less verbose, in particular for interactive use.

@dweindl
Copy link
Member Author

dweindl commented Oct 6, 2025

Works for me 👍 I would also be fine with removing Model.simulate_multiple and instead adapting Model.simulate to support edatas = ExpData | list[ExpData].

Thanks. Yeah, I am divided on that one.

@dweindl
Copy link
Member Author

dweindl commented Oct 8, 2025

Works for me 👍 I would also be fine with removing Model.simulate_multiple and instead adapting Model.simulate to support edatas = ExpData | list[ExpData].

Thanks. Yeah, I am divided on that one.

I think my concerns are easily addressable by two typing.overloads. So, in favor of merging them.

@FFroehlich
Copy link
Member

Here a first draft.

@FFroehlich @dilpath: Would that work for you? Any better suggestions?

yes looks great!

@dweindl dweindl force-pushed the gh-2944-simulate branch 2 times, most recently from d9d4017 to addf172 Compare October 16, 2025 07:09
@dweindl dweindl changed the title amici.runAmiciSimulation -> Model.simulate Add Model.simulate Oct 16, 2025
Add `Model.simulate()` as a convenience function to run simulations without having to create a `Solver` object explicitly.
This is a wrapper for both `amici.run_simulation` and `amici.run_simulations`, depending on the type of the `edata` argument.
It also supports passing some `Solver` options as keyword arguments.
@dweindl dweindl marked this pull request as ready for review October 16, 2025 10:46
@dweindl dweindl requested a review from a team as a code owner October 16, 2025 10:46
@dweindl dweindl added this pull request to the merge queue Oct 17, 2025
Merged via the queue into AMICI-dev:main with commit d1bdebd Oct 17, 2025
16 checks passed
@dweindl dweindl deleted the gh-2944-simulate branch October 17, 2025 13:48
@dweindl dweindl mentioned this pull request Oct 17, 2025
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