ENH: rework to allow general proposal distributions - #70
Open
mj-will wants to merge 13 commits into
Open
Conversation
mj-will
force-pushed
the
general-proposal
branch
from
July 30, 2026 12:55
12caba3 to
1be57b4
Compare
mj-will
force-pushed
the
general-proposal
branch
from
July 30, 2026 12:56
1be57b4 to
ddeccf8
Compare
mj-will
marked this pull request as ready for review
July 30, 2026 13:00
Contributor
There was a problem hiding this comment.
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
Aspireto use aproposalinterface instead ofprior_flow/flow, with deprecation shims. - Add
GaussianProposalplus 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 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__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rework the main aspire class to allow general proposals rather than just flows.
Also adds a basic Gaussian proposal.