Skip to content

[ENH] Easier subclassing of bilby implemented dynesty ensemble samplers#1066

Open
JasperMartins wants to merge 3 commits intobilby-dev:mainfrom
JasperMartins:support-custom-sampler
Open

[ENH] Easier subclassing of bilby implemented dynesty ensemble samplers#1066
JasperMartins wants to merge 3 commits intobilby-dev:mainfrom
JasperMartins:support-custom-sampler

Conversation

@JasperMartins
Copy link
Copy Markdown
Contributor

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 more elif case.

This MR makes this system a bit more automatic: (Subclasses) of BaseEnsembleSampler expose directly which keyword arguments they can take, which then allows for the automatic collection of these arguments from a bilby.[...].Dynesty instance. 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 new custom_sampler_kwargs keyword-argument.

I have also implemented this change in a Bilby 3 compatible way based on #1049 Here

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.

1 participant