mackelab / delfi

Density estimation likelihood-free inference. No longer actively developed see https://github.com/mackelab/sbi instead
http://www.mackelab.org/delfi
Other
71 stars 28 forks source link

Class inheritance #63

Closed yoavram closed 4 years ago

yoavram commented 4 years ago

Hi I'm wondering why you require class inheritance for the generator etc.? You can just require that the generator object has a gen_single() method that returns a dictionary, etc. In Python, this is usually the preferred way to implement what other languages use interfaces for. This would make implementing generators a bit easier. You always check that a generator has the desired attribute using hasattr.

BTW I also don't see that delfi.generator.Default.Default has gen_single.

dgreenberg commented 4 years ago

Hi Yoavram,

gen_single is for simulators, not generators.

In general, inheriting from the BaseGenerator allows us to define a lot of functions in the same place. But I don't think we require the generator object supplied to the inference methods to actually be of any particular class, nor do we check anything about it.

If any of this stuff is still not clear, feel free to reopen this issue!

yoavram commented 4 years ago

thx!