[ENH] Easier subclassing of bilby implemented dynesty ensemble samplers#1066
Open
JasperMartins wants to merge 3 commits intobilby-dev:mainfrom
Open
[ENH] Easier subclassing of bilby implemented dynesty ensemble samplers#1066JasperMartins wants to merge 3 commits intobilby-dev:mainfrom
JasperMartins wants to merge 3 commits intobilby-dev:mainfrom
Conversation
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.
The changes in dynesty v3 made sub-classing of samplers much easier. However, if a user wants to implement further sub-classes, these have to be passed to dynesty/bilby already fully initialized. One of the greatest things about bilby is its flexibility, which includes implementing the functionality required to initialize quite different samplers with the same input.
How the samplers are initialized is hardcoded in
bilby.[...].Dynesty.sampler_init_kwargs(). This is a bit unfortunate, because custom samplers can be plugged into this init-system only by changing the bilby source. That change, then, is easy: It just requires one moreelifcase.This MR makes this system a bit more automatic: (Subclasses) of
BaseEnsembleSamplerexpose directly which keyword arguments they can take, which then allows for the automatic collection of these arguments from abilby.[...].Dynestyinstance. Custom samplers can just be passed via their class. If a custom sampler needs keyword arguments that have not been taken into account in the native implementation, they can be passed via a newcustom_sampler_kwargskeyword-argument.I have also implemented this change in a Bilby 3 compatible way based on #1049 Here