-
Notifications
You must be signed in to change notification settings - Fork 34
Make MALA allow repeated ask() #994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,6 @@ def __init__(self, x0, sigma0=None): | |
|
|
||
| # Set initial state | ||
| self._running = False | ||
| self._ready_for_tell = False | ||
|
|
||
| # Current point and proposed point | ||
| self._current = None | ||
|
|
@@ -166,9 +165,6 @@ def ask(self): | |
| if not self._running: | ||
| self._initialise() | ||
|
|
||
| if self._ready_for_tell: | ||
| raise RuntimeError('Ask() called when expecting call to tell().') | ||
|
|
||
| # Propose new point | ||
| if self._proposed is None: | ||
|
|
||
|
|
@@ -187,18 +183,15 @@ def ask(self): | |
| # Set as read-only | ||
| self._proposed.setflags(write=False) | ||
|
|
||
| self._ready_for_tell = True | ||
|
|
||
| # Return proposed point | ||
| return self._proposed | ||
|
|
||
| def tell(self, reply): | ||
| """ See :meth:`pints.SingleChainMCMC.tell()`. """ | ||
|
|
||
| # Check if we had a proposal | ||
| if not self._ready_for_tell: | ||
| if self._proposed is None: | ||
| raise RuntimeError('Tell called before proposal was set.') | ||
| self._ready_for_tell = False | ||
|
|
||
|
Comment on lines
228
to
229
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, probably not getting something but don't quite get why we'd remove these checks.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's more in line with what we have in the other MCMC methods, with the exception of the ones that do more complicated stuff in ask() than just set a proposal. So no very strong reason! Just that it's possible to let users ask() as often as they like in this case (and always get the same result), and it lets us remove a variable... We might want to disallow this everywhere instead though? In which case we'd have to update the documentation for SingleChainMCMC and MultiChainMCMC a bit to make this explicit... |
||
| # Unpack reply | ||
| fx, log_gradient = reply | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow why we'd want to remove this check? Probably missing the point, but what would be a use case for repeatedly calling ask?