Experimental: switch to DensityInterface #87
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To summarize:
gradient_logp
TuringLang/Turing.jl#1877).logdensity
andlogdensityof
...).There has already been talk of making DI a "parent package" of LDP, but the idea was rejected as DI is rather new and wasn't really well established back then.
I also don't feel comfortable messing radically with the interface of an existing package, deviating from the original considerations of the package author and surprising the existing user base, both of which make me hesitate. On the other hand, the situation as it has arisen in Turing is a bit unfortunate (even if not to the outside), and in the end, both packages are very close in what they want to cover.
Therfore, I'm opening this PR for the sake of discussion. The code as is passes all tests, but is not yet a serious proposal; you'll note that the interface is incompatibly changed in parts, and I cut some corners.
CC @oschulz @devmotion @cscherrer
An attempt to summarize the differences:
DensityKind
s and base measures; care was taken that everything can also be made to work in MeasureTheory.jl in a sensible way).HasDensity
orIsDensity
, and which do not have to be callable (evaluation is always vialogdensityof
). (But DI provideslogfuncdensity
to wrap any callable object and treat it as a density). PerhapsIsDensity
objects could actually expected to be callable... but this is nowhere said so or agreed upon.