TuringLang / SSMProblems.jl

Common abstractions for state-space models
http://turinglang.org/SSMProblems.jl/
MIT License
2 stars 2 forks source link

Avoid duplicate definitions of generic functions and combine doc strings. #40

Closed yebai closed 1 month ago

yebai commented 1 month ago

We currently define the same loddensity distribution and simulate functions multiple times and attach different doc strings to them. This does not work well. See, e.g., https://turinglang.org/SSMProblems.jl/dev/, where only docs for the final definition is recognised by Julia.

THargreaves commented 1 month ago

Ah I see. I think to be more specific, the issue is that we're defining the same method (no parameters) multiple times. The Julia documentation (section 17.3) does recommend documenting different methods of the same function multiple times if their behaviour is substantial different (which I believe is the case here).

I think we have two approaches:

  1. Combine all docstrings for, e.g., simulate into one definition. I worry this definition will look very messy, and it's not clear what the top level signature would be.
  2. This is somewhat diverging from the standard way that interfaces are defined, but we could define the interface as, e.g. logdensity(dyn::LatentDynamics, step::Int, state, extra), defaulting to returning a NotImplemented error. This would also allow us to split the docstring for initialisation and transition methods, which would be much clearer.
yebai commented 1 month ago

Option 2 sounds better to me.

yebai commented 1 month ago

This is now closed, but what are your thoughts, @willtebbutt?

willtebbutt commented 1 month ago

I think option 2 was correctly chosen.