Skip to content

ENH: rework to allow general proposal distributions - #70

Open
mj-will wants to merge 13 commits into
mainfrom
general-proposal
Open

ENH: rework to allow general proposal distributions#70
mj-will wants to merge 13 commits into
mainfrom
general-proposal

Conversation

@mj-will

@mj-will mj-will commented Mar 5, 2026

Copy link
Copy Markdown
Owner

Rework the main aspire class to allow general proposals rather than just flows.

Also adds a basic Gaussian proposal.

@mj-will
mj-will force-pushed the general-proposal branch from 12caba3 to 1be57b4 Compare July 30, 2026 12:55
@mj-will
mj-will force-pushed the general-proposal branch from 1be57b4 to ddeccf8 Compare July 30, 2026 12:56
@mj-will
mj-will marked this pull request as ready for review July 30, 2026 13:00
@mj-will
mj-will requested a review from Copilot August 3, 2026 09:14

Copilot AI left a comment

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.

Pull request overview

This PR refactors Aspire’s “flow-only” proposal concept into a more general proposal interface, enabling non-flow proposal distributions (e.g., a new Gaussian proposal) while maintaining backwards compatibility via deprecations.

Changes:

  • Generalize samplers and Aspire to use a proposal interface instead of prior_flow / flow, with deprecation shims.
  • Add GaussianProposal plus serialization support and new tests covering proposal behavior and checkpointing/resume.
  • Update docs and examples to use proposal terminology and APIs (save_proposal, init_proposal, sample_proposal).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_proposals.py Adds unit tests for proposal protocol, GaussianProposal, and proposal persistence/loading behavior.
tests/integration_tests/test_integration.py Updates integration tests to use proposal APIs (save_proposal, init_proposal).
src/aspire/samplers/smc/minipcn.py Switches SMC mutation bookkeeping from prior_flow to proposal.
src/aspire/samplers/smc/emcee.py Switches SMC mutation bookkeeping from prior_flow to proposal.
src/aspire/samplers/smc/blackjax.py Updates BlackJAX SMC wrapper to accept proposal while retaining deprecated prior_flow.
src/aspire/samplers/smc/base.py Generalizes SMC base to accept proposal and deprecate prior_flow.
src/aspire/samplers/mcmc.py Updates MCMC sampler to draw initial samples from proposal and keep deprecated prior_flow.
src/aspire/samplers/importance.py Updates importance sampler to sample from proposal.
src/aspire/samplers/base.py Introduces proposal as the primary sampler dependency and deprecates prior_flow.
src/aspire/proposals.py Adds the Proposal protocol and the new GaussianProposal implementation.
src/aspire/aspire.py Core refactor: proposal property, init/save/load/checkpointing updates, and flow deprecations.
examples/smc_example.py Updates example usage to match new proposal/checkpoint APIs.
examples/basic_example.py Updates example usage to save proposals instead of flows.
docs/user_guide.rst Documents the proposal abstraction and introduces GaussianProposal usage.
docs/recipes.rst Updates recipe to inspect/sample from proposals instead of flows.
docs/checkpointing.rst Updates checkpointing docs to describe proposal persistence and legacy flow compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/aspire/aspire.py
Comment thread src/aspire/aspire.py
Comment thread src/aspire/aspire.py
Comment on lines +962 to +971
if self.proposal is None:
raise ValueError("Proposal has not been initialized.")
self.proposal.save(h5_file, path=path)
proposal_group = h5_file[path]
proposal_group.attrs["proposal_module"] = type(
self.proposal
).__module__
proposal_group.attrs["proposal_qualname"] = type(
self.proposal
).__qualname__

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This now raises an error.

Comment thread src/aspire/aspire.py
@mj-will mj-will added the enhancement New feature or request label Aug 3, 2026
@mj-will mj-will added this to the v0.2.0 milestone Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants