Skip to content

Transform distributions#925

Merged
NicolaCourtier merged 16 commits intodevelopfrom
transform-distributions
Apr 13, 2026
Merged

Transform distributions#925
NicolaCourtier merged 16 commits intodevelopfrom
transform-distributions

Conversation

@NicolaCourtier
Copy link
Copy Markdown
Member

Description

The implementation of parameters, distributions and transformations is over-complicated. The aim here is to simplify the definitions and interactions between these classes to improve maintainability. A new UnboundedDistribution is created to define the behaviour of a parameter without a statistical distribution. The get_transformed_distribution functionality is added to both univariate and multivariate distributions.

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #).

Important checks:

Please confirm the following before marking the PR as ready for review:

  • No style issues: $ pre-commit run or $ nox -s pre-commit (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctest
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 89.20635% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.24%. Comparing base (4628a65) to head (183a238).
⚠️ Report is 53 commits behind head on develop.

Files with missing lines Patch % Lines
pybop/parameters/distributions.py 88.88% 16 Missing ⚠️
pybop/parameters/multivariate_distributions.py 85.54% 12 Missing ⚠️
pybop/parameters/parameter.py 92.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #925      +/-   ##
===========================================
+ Coverage    89.41%   90.24%   +0.83%     
===========================================
  Files           63       73      +10     
  Lines         4857     5692     +835     
===========================================
+ Hits          4343     5137     +794     
- Misses         514      555      +41     

☔ View full report in Codecov by Sentry.
📢 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.

@NicolaCourtier NicolaCourtier changed the base branch from add-noise-util to develop April 2, 2026 16:08
@NicolaCourtier NicolaCourtier marked this pull request as ready for review April 10, 2026 13:50
@NicolaCourtier NicolaCourtier requested a review from SarahRo April 10, 2026 13:50
@NicolaCourtier NicolaCourtier linked an issue Apr 10, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

looks good, couple of questions around distribution = None / unbounded


def __init__(
self,
distribution: stats.distributions.rv_frozen | None = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what does distribution=None mean? unbounded? need to add to the docstring

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.

To make things clearer, I have added the BaseDistribution class - which can be used as a placeholder for an empty parameter.

def __init__(
self,
distribution: stats.distributions.rv_frozen | Distribution | None = None,
distribution: Distribution | None = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

again, what is distribution=None mean?

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 to the description:

distribution : BaseDistribution, optional
        Probability distribution for the parameter. If None, an empty
        `pybop.BaseDistribution` will return a NotImplementedError for any
        functionality that requires a distribution, such as `rvs`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but what does it mean from a user perspective? Does it mean that the parameter is unbounded? Or that it can't be used in sampling, or multi-start optimisation?

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.

If no distribution, bounds or initial value is specified, an empty Parameter with an empty BaseDistribution will be created. It doesn't really mean anything... but it should return a somewhat helpful error when something is required but not implemented. It has no bounds and yes, it cannot be used for sampling (no mean or cov) or multi-start optimisation (no rvs).

@NicolaCourtier NicolaCourtier merged commit dc0971f into develop Apr 13, 2026
63 of 65 checks passed
@NicolaCourtier NicolaCourtier deleted the transform-distributions branch April 13, 2026 17:06
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.

Align the setting and passing of bounds

2 participants