Skip to content

Add petab.v2.reparametrize_log - #560

Merged
dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:reparametrize-log
Oct 21, 2026
Merged

dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:reparametrize-log

Conversation

@dweindl

@dweindl dweindl commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

PEtab v2 has no parameterScale. To estimate a parameter <id> on log scale, or to specify a prior for log10(<id>), the v2 spec recommends replacing <id> by a new parameter log10_<id> with <id> = 10^log10_<id>.

This adds petab.v2.reparametrize_log(problem, parameter_ids, ...), which does this for the given parameters on a copy of the problem and returns the copy and the mapping of old to new parameter IDs:

  • parameter table: log-transformed bounds (dropped for non-estimated parameters) and nominal value; priors from the priors argument, or derived from log-normal, log-laplace and log-uniform priors on <id> (other priors on <id> raise; priors of non-estimated parameters raise NotImplementedError unless dropped via priors={<id>: None})
  • SBML model: new parameter log10_<id> and initial assignment <id> = 10^log10_<id> (replacing any existing one; <id> stays constant=true)
  • observable/noise formulas and condition target values: <id> → 10^log10_<id>
  • measurement overrides: replaced by the new IDs, numeric overrides are log-transformed, and the placeholder ph is replaced by 10^ph in the formulas

A lower bound of 0 becomes -inf, following PEtab-dev/PEtab#682. If other estimated parameters have priors, such a parameter needs an explicit prior, since the default uniform(lb, ub) would be improper; otherwise, a ValueError is raised. A nominal value of 0 becomes -inf, assuming PEtab-dev/PEtab#685 is accepted, e.g., for parameters fixed at 0.

Problems with required extensions are not supported.

Base e (log_<id>) is supported as well. The procedure follows the one described in the proposed v1→v2 migration guide (PEtab-dev/PEtab#680).

Split off from #539, which uses this in petab1to2(reparametrize=...) to preserve v1 parameter-scale priors.

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.18605% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.85%. Comparing base (e654711) to head (98e2737).

Files with missing lines Patch % Lines
petab/v2/reparametrize.py 94.93% 4 Missing and 4 partials ⚠️
petab/v2/models/_sbml_utils.py 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #560      +/-   ##
==========================================
+ Coverage   78.44%   78.85%   +0.41%     
==========================================
  Files          68       69       +1     
  Lines        7876     8043     +167     
  Branches     1406     1445      +39     
==========================================
+ Hits         6178     6342     +164     
  Misses       1214     1214              
- Partials      484      487       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@dweindl
dweindl force-pushed the reparametrize-log branch 2 times, most recently from 74b7276 to e74ee3b Compare October 19, 2026 15:26
@dweindl
dweindl marked this pull request as ready for review October 20, 2026 06:22
@dweindl
dweindl requested a review from a team as a code owner October 20, 2026 06:22
@dweindl
dweindl force-pushed the reparametrize-log branch 4 times, most recently from e1d0f09 to 2c303c3 Compare October 20, 2026 14:56

@dilpath dilpath left a comment

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.

Thanks!

Comment thread tests/v2/test_reparametrize.py
Comment thread tests/v2/test_reparametrize.py
Comment thread petab/v2/reparametrize.py Outdated
Comment thread petab/v2/reparametrize.py
Comment thread petab/v2/reparametrize.py Outdated
Comment thread petab/v2/reparametrize.py Outdated
Comment thread petab/v2/reparametrize.py Outdated
Comment thread petab/v2/reparametrize.py Outdated
Comment thread petab/v2/reparametrize.py Outdated
@dweindl
dweindl force-pushed the reparametrize-log branch 2 times, most recently from 7fc047b to aa4298d Compare October 21, 2026 12:22
PEtab v2 has no `parameterScale`. To estimate a parameter `p` on log
scale (and to specify priors for `log10(p)`), `p` has to be replaced by
a new parameter `log10_p` with `p = 10^log10_p`.

`reparametrize_log` does this for a given set of parameters on a copy
of the problem and returns the copy and the mapping of old to new IDs:

* parameter table: log-transformed bounds and nominal values (a lower
  bound or nominal value of 0 becomes -inf); priors given explicitly,
  or derived from `log-normal`, `log-laplace` and `log-uniform` priors
* SBML model: new parameter `log10_p` and initial assignment
  `p = 10^log10_p`
* observable/noise formulas and condition table target values:
  `p` -> `10^log10_p`
* measurement table overrides: `p` -> `log10_p`, numeric overrides are
  log-transformed, and the placeholder `ph` -> `10^ph` in the formulas

Base e is supported as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dweindl
dweindl merged commit 68be6d1 into PEtab-dev:main Oct 21, 2026
7 checks passed
@dweindl
dweindl deleted the reparametrize-log branch October 21, 2026 13:25
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