joshspeagle / dynesty

Dynamic Nested Sampling package for computing Bayesian posteriors and evidences
https://dynesty.readthedocs.io/
MIT License
355 stars 77 forks source link

DynamicNestedSampler as a class #387

Closed segasai closed 2 years ago

segasai commented 2 years ago

Is there a reason why DynamicNestedSampler is a function as opposed to a class inheriting from from DynamicSampler @joshspeagle ? like this

class DynamicNestedSampler(DynamicSampler):
    def __init__(self,
                 loglikelihood,
                 prior_transform,
         ...
         super().__init__(...)

without that it's hard to have a restore method for the checkpointing patch. I.e. dns= DynamicNestedSampler.restore('xx.pkl') or something like that.

joshspeagle commented 2 years ago

Back when I was setting this up I probably had a reason, but I can't really remember why at the moment...

segasai commented 2 years ago

Ok, I will aim to change that then, as I think it makes more sense and now with the restoring/saving it is becoming important for the main DynamicNestedSampler and NestedSampler to be classes as opposed to functions returning some other classes.

segasai commented 2 years ago

I think I can see the problem.

With dynamic sampler it's an easy natural change https://github.com/joshspeagle/dynesty/commit/1d41ca314acb9f9505a90e5bfe5710e4b4eeabc0

But the problem with the static samplers is that they (EllipsoodalSampler etc ) all inherit from SuperSampler class. And then NestedSampler() returns either of these.

I need to think if there is an restructuring with inheritance/interface that would work for the static case