Skip to content

v2: handle infinite parameter bounds (PEtab 2.0 erratum E1) - #601

Merged
dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:worktree-565
Nov 18, 2026
Merged

dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:worktree-565

Conversation

@dweindl

@dweindl dweindl commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Implements PEtab 2.0.0 erratum E1: lowerBound may be -inf, upperBound may be inf, and if any estimated parameter has a prior, estimated parameters with infinite bounds need an explicit proper prior.

  • Parameter.lb must be finite or -inf, Parameter.ub finite or inf. Previously, e.g. lb=ub=inf was accepted.
  • CheckPriorDistribution reports estimated parameters with infinite bounds and no prior if the problem has a MAP objective. Explicit improper uniform/log-uniform priors (e.g., with infinite prior parameters) are already rejected via Reject improper Uniform and LogUniform distributions #604.
  • Problem.get_priors and Problem.get_startpoint_distributions raise a ValueError naming the parameters with infinite (or missing) bounds and no prior, instead of the generic error from Uniform (since Reject improper Uniform and LogUniform distributions #604) or, before that, an improper Uniform that failed on sampling. I chose this over adding a fallback-distribution argument to keep the API unchanged; a fallback could be added later if needed.
  • Problem.sample_parameter_startpoints used get_priors, which is empty for maximum likelihood problems, and thus always failed for them. It now uses get_startpoint_distributions (identical to get_priors for MAP problems). It also returns an (n_starts, 0) array if no parameters are estimated, and no longer accepts arbitrary keyword arguments. These were a leftover from copying the v1 method, where they are forwarded to petab.v1.sampling.sample_parameter_startpoints; in v2 they have been silently ignored since v2: Startpoint sampling #380, so nothing should depend on them.
  • Tests that prior truncation at bounds matching the prior's domain (e.g., log-normal on [0, inf]) is a no-op, and that one-sided infinite bounds still truncate at the finite bound.

Infinite nominal values (erratum E3) were already accepted; no change.

Closes #565.

🤖 Generated with Claude Code

@dweindl dweindl self-assigned this Nov 17, 2026
@codecov-commenter

codecov-commenter commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.14%. Comparing base (4329d1b) to head (60973cb).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #601      +/-   ##
==========================================
+ Coverage   79.93%   80.14%   +0.21%     
==========================================
  Files          70       70              
  Lines        8362     8431      +69     
  Branches     1519     1545      +26     
==========================================
+ Hits         6684     6757      +73     
+ Misses       1188     1183       -5     
- Partials      490      491       +1     

☔ 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 worktree-565 branch 2 times, most recently from f73091a to 799768f Compare November 17, 2026 16:11
@dweindl
dweindl marked this pull request as ready for review November 17, 2026 16:16
@dweindl
dweindl requested a review from a team as a code owner November 17, 2026 16:16
Comment thread petab/v2/core.py
Comment on lines +2162 to +2166
raise ValueError(
"The default uniform distribution is undefined for estimated "
"parameters with infinite or missing bounds and no prior: "
f"{unbounded}."
)

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.

Maybe, "Proper priors are required and must be specified for estimated parameters with infinite or missing bounds. Affected parameters: {unbounded}"?

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.

This error message is used for both MAP and MLE problems, so I think it would be incorrect to ask for proper priors. I can distinguish the two cases though.

Comment thread petab/v2/core.py
"""Create 2D array with starting points for optimization"""
priors = self.get_priors()
return np.vstack([p.sample(n_starts) for p in priors.values()]).T
def sample_parameter_startpoints(self, n_starts: int = 100) -> np.ndarray:

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.

Not sure what kwargs was for, but removing them would be a breaking changes?

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.

[...] and no longer accepts arbitrary keyword arguments. These were a leftover from copying the v1 method, where they are forwarded to petab.v1.sampling.sample_parameter_startpoints; in v2 they have been silently ignored since #380, so nothing should depend on them.

Technically, you are right, but **kwargs was just useless copypasta.

Comment thread tests/v2/test_core.py
assert sp.shape == (n_starts, 2)


def test_sample_startpoints_ml():

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.

Test that the samples match the expected distribution, and that the bounds are (in)valid samples (distribution-specific)?

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.

The actual sampling is tested in test_sample_matches_pdf (https://github.com/dweindl/libpetab-python/blob/799768fe80db62e1cac47d702bfa72c270457b9e/tests/v1/test_distributions.py#L44), untouched here. I don't think repeating it here would add much.

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.

Added an additional bound check there.

PEtab 2.0.0 erratum E1 allows `lowerBound=-inf` and `upperBound=inf`.
If any estimated parameter has a prior, estimated parameters with
infinite bounds require an explicit proper prior, since the default
`uniform(lowerBound, upperBound)` prior would be improper.

* `Parameter.lb` must be finite or `-inf`, `Parameter.ub` finite or
  `inf`. Errors refer to the `lowerBound`/`upperBound` columns.
* `CheckPriorDistribution` reports estimated parameters with infinite
  bounds and no prior if the problem has a MAP objective.
* `Problem.get_startpoint_distributions` raises a `ValueError` naming
  estimated parameters with infinite or missing bounds and no prior,
  instead of returning improper uniform distributions. `get_priors`
  delegates to it for MAP problems.
* `Problem.sample_parameter_startpoints` used `get_priors`, which is
  empty for maximum likelihood problems, and thus failed. It now uses
  `get_startpoint_distributions`, returns an `(n_starts, 0)` array if no
  parameters are estimated, and no longer accepts and ignores arbitrary
  keyword arguments.
* Test that prior truncation at bounds matching the prior's domain is a
  no-op, and that one-sided infinite bounds still truncate.

Closes PEtab-dev#565.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl
dweindl added this pull request to the merge queue Nov 18, 2026
Merged via the queue into PEtab-dev:main with commit 7f89886 Nov 18, 2026
8 checks passed
@dweindl
dweindl deleted the worktree-565 branch November 18, 2026 10:11
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.

v2: Update parameter table validation for PEtab 2.0 erratum E1 (infinite bounds)

3 participants