Skip to content

(Not so) Minor sampler refactoring of the samplers

Moritz Huebner requested to merge minor_sampler_refactoring into master

This is the last of my series of MRs and builds on !199 (closed) and !200 (closed) and does a few things to simplify the samplers:

  • I got rid of the redundant external_sampler and external_sampler_function attribute
  • All samplers now have a static dictionary with default kwargs for the sampler
  • These dicts contain all possible kwargs
  • The previously obsolete _verify_kwargs_against_external_sampler_function now is called _verify_kwargs_against_default_kwargs and checks against our dict of kwargs
  • The kwargs property/setter now has a common template. Child classes only have to implement _translate_kwargs, which handles incorrect kwargs. Most kwargs property/setters could therefore be removed
  • Introduced helper classes MCSampler and NestedSampler`
  • The methods to setup_nburn and calculate_autocorrelation have been moved to MCSampler, since they don't really make sense outside of this right now
  • Some child classes implement an __init__ method now and have some custom attributes
  • Dynesty now handles the nested sampler (sampler -> self.sampler) as an attribute internally. This removes the sampler argument in some of the internal methods
  • Emcee now has some properties that refer to the respective kwargs
  • In case that the external sampler constructs a sampler object and then calls a sampler method, there are now sampler_function_kwargs and sampler_init_kwargs properties, that properly separate those.
Edited by Moritz Huebner

Merge request reports