Skip to content

PEtab v2: Fix numeric noise overrides replacing the noise formula - #3584

Merged
dweindl merged 1 commit into
AMICI-dev:mainfrom
dweindl:petab_v2_numeric_noise_overrides
Nov 16, 2026
Merged

dweindl merged 1 commit into
AMICI-dev:mainfrom
dweindl:petab_v2_numeric_noise_overrides

Conversation

@dweindl

@dweindl dweindl commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Fixes numeric noiseParameters overrides in the PEtab v2 SUNDIALS simulator replacing the whole noise formula instead of being substituted into it. For any noise formula other than the bare noise placeholder, sigma and the likelihood were wrong, without a warning.

  • ExperimentManager passes a numeric override directly as sigma via ExpData only if the noise formula is exactly the noise placeholder (for PySB models, after resolving the <obs>_sigma expression created during import). Otherwise, the override is applied to the placeholder parameter as for non-numeric overrides.
  • PetabImporter accepts timepoint-specific numeric noise overrides without flattening only for such bare-placeholder noise formulas. The error message now suggests flatten_timepoint_specific_output_overrides.

Test coverage is added in the PEtab test suite (PEtab-dev/petab_test_suite#122, cases 0006 and 0033), which the v2 suite job uses from main. Those cases fail without this fix.

The PEtab v1 path has the same problem; that will be addressed separately.

Relates to #3560 (PEtab v2 part).

🤖 Generated with Claude Code

A single numeric `noiseParameters` value was written into the `ExpData`
noise scales, replacing the model-computed sigma, regardless of the
noise formula. For any noise formula other than the bare noise
placeholder, sigma and the likelihood were wrong.

Use numeric overrides as sigmas directly only if the noise formula is
just the noise placeholder (for PySB, resolving the `<obs>_sigma`
expression). Otherwise, the override is applied to the placeholder
parameter. Accordingly, timepoint-specific numeric noise overrides are
only accepted without flattening for such noise formulas.

Fixes AMICI-dev#3560.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl dweindl added the PEtab PEtab-import related label Nov 16, 2026
@dweindl dweindl self-assigned this Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.72%. Comparing base (7fb8c57) to head (56a8114).

Files with missing lines Patch % Lines
...hon/sdist/amici/importers/petab/_petab_importer.py 90.90% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3584   +/-   ##
=======================================
  Coverage   80.71%   80.72%           
=======================================
  Files         331      331           
  Lines       23688    23699   +11     
  Branches     1674     1674           
=======================================
+ Hits        19120    19131   +11     
  Misses       4562     4562           
  Partials        6        6           
Flag Coverage Δ
cpp 75.28% <16.66%> (-0.03%) ⬇️
cpp_python 34.86% <8.33%> (-0.02%) ⬇️
petab 47.17% <91.66%> (+0.03%) ⬆️
petab_sciml 16.50% <16.66%> (+<0.01%) ⬆️
petab_sciml_benchmarks 15.11% <16.66%> (+<0.01%) ⬆️
python 72.97% <66.66%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
python/sdist/amici/sim/sundials/petab/_v2.py 99.06% <100.00%> (+<0.01%) ⬆️
...hon/sdist/amici/importers/petab/_petab_importer.py 88.99% <90.90%> (+0.26%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dweindl dweindl added the blocker Blocks CI or other PRs; review/merge first label Nov 16, 2026
@dweindl
dweindl marked this pull request as ready for review November 16, 2026 15:51
@dweindl
dweindl requested a review from a team as a code owner November 16, 2026 15:51
@dweindl
dweindl requested a review from dilpath November 16, 2026 17:48
# experiment
# experiment, and the noise formula is just that placeholder
# (the literals are then passed as sigmas via ExpData)
id_to_observable = {o.id: o for o in self.petab_problem.observables}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

self.petab_problem has __getitem__ for this I think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's correct, but for larger problems, this is very expensive because for every lookup, it iterates over many lists of various entities.

@dweindl
dweindl added this pull request to the merge queue Nov 16, 2026
Merged via the queue into AMICI-dev:main with commit 7cb3c09 Nov 16, 2026
40 checks passed
@dweindl
dweindl deleted the petab_v2_numeric_noise_overrides branch November 17, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker Blocks CI or other PRs; review/merge first PEtab PEtab-import related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants