jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.35k stars 589 forks source link

[Suggestion] Expose `Distribution` class via public API #1015

Closed AKuederle closed 1 year ago

AKuederle commented 1 year ago

I think it would make sense to expose the base Distribution class via the "public" API.

This would help with typing of user code and probably this is required when implementing custom distributions.

jmschrei commented 1 year ago

I'm not sure what this means. Everything is public in Python.

AKuederle commented 1 year ago

I know that everything is public in Python, but "things with leading underscore" are by convention viewed as private. I.e. internal API that is not expected for external consumption/if you need to use it, you probably doing something wrong. So to signal users that it is "ok" to import Distribution in their code, I would suggest reexporting it from pomegrenate.distributions.

See: https://github.com/jmschrei/pomegranate/pull/1027

jmschrei commented 1 year ago

I think that's the right signal to send, though. You shouldn't ever be creating a Distribution object directly in your code, and you should only use the Distribution when implementing your own distributions. I still view that as private because I don't see a semantic difference between distributions that I've implemented and custom distributions that the user implements, in terms of public/private. Basically, if private meant that a user should never touch them in any circumstance, you're saying that the user is unable to make custom extensions that use such methods. I know in some other languages private literally means that the function/method cannot be accessed outside the code, but Python isn't like those.

Please re-open if you'd like to keep chatting -- always happy to hear alternate perspectives.