Skip to content

Reject improper Uniform and LogUniform distributions - #604

Merged
dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:distributions_validate_uniform
Nov 17, 2026
Merged

dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:distributions_validate_uniform

Conversation

@dweindl

@dweindl dweindl commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

petab.v1.distributions.Uniform accepted any limits. E.g., Uniform(0, inf) has pdf 0 and cdf nan, and fails only when sampled, with numpy's OverflowError: Range exceeds valid bounds.

Uniform now requires finite limits with low < high (on the scale of the underlying uniform distribution), and LogUniform requires 0 < low < high < inf. Both raise a ValueError otherwise.

Affected petab.v1 use: start point sampling for parameters with infinite bounds, or with lowerBound=0 and a log-scaled default parameterScaleUniform initialization prior. These already failed during sampling; they now fail when the Prior is created. low == high is also rejected, so an estimated parameter with lowerBound == upperBound and no prior can no longer be sampled (v1 and v2). None of the problems in the PEtab benchmark collection are affected.

In petab.v2, invalid uniform/log-uniform priors are still reported by CheckPriorDistribution, now with a clearer hint. If a uniform prior range does not overlap the parameter bounds, the error names the prior parameters and bounds instead of the clipped limits.

🤖 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 79.93%. Comparing base (3fd2a3f) to head (81653cd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #604      +/-   ##
==========================================
+ Coverage   79.87%   79.93%   +0.06%     
==========================================
  Files          70       70              
  Lines        8356     8362       +6     
  Branches     1516     1519       +3     
==========================================
+ Hits         6674     6684      +10     
+ Misses       1191     1188       -3     
+ Partials      491      490       -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 distributions_validate_uniform branch from 11ac1aa to 3883ca9 Compare November 17, 2026 10:11
@dweindl
dweindl marked this pull request as ready for review November 17, 2026 11:17
@dweindl
dweindl requested a review from a team as a code owner November 17, 2026 11:17
Comment thread petab/v1/distributions.py Resolved
Comment thread petab/v1/distributions.py Resolved
`Uniform` accepted any limits, e.g., `Uniform(0, inf)`, whose pdf is 0,
whose cdf is nan, and which fails only when sampled, with numpy's
`OverflowError: Range exceeds valid bounds`.

`Uniform` now requires finite limits with `low < high` (on the scale of
the underlying uniform distribution), and `LogUniform` requires
`0 < low < high < inf`.

In `petab.v1`, this affects start point sampling for parameters with
infinite bounds or with `lowerBound=0` and log-scaled
`parameterScaleUniform` priors. These already failed during sampling;
they now fail when the `Prior` is created. Estimated parameters with
`lowerBound == upperBound` and no prior can no longer be sampled.

In `petab.v2`, `Parameter.prior_dist` reports the original prior
parameters and bounds if a `uniform` prior does not overlap the
parameter bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl
dweindl force-pushed the distributions_validate_uniform branch from 3883ca9 to 81653cd Compare November 17, 2026 14:06
@dweindl
dweindl enabled auto-merge November 17, 2026 14:08
@dweindl
dweindl added this pull request to the merge queue Nov 17, 2026
Merged via the queue into PEtab-dev:main with commit 71091ea Nov 17, 2026
8 checks passed
@dweindl
dweindl deleted the distributions_validate_uniform branch November 17, 2026 14:17
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