[Merged by Bors] - Add TestUtils submodule#313
Conversation
|
|
||
| # A collection of models for which the mean-of-means for the posterior should | ||
| # be same. | ||
| @model function demo1(x=10 * ones(2), ::Type{TV}=Vector{Float64}) where {TV} |
There was a problem hiding this comment.
Maybe we could use a bit more descriptive names?
There was a problem hiding this comment.
Thought crossed my mind, but was worried they'd be too long. Buuuut we're not going to be using the constructors of these models very often, so the cost of making them overly verbose is approx. 0 👍
I'll do that!
phipsgabler
left a comment
There was a problem hiding this comment.
Aren't the implicitly constructed named tuples ((; m, x)) too new to be backwards compatible with 1.3?
Co-authored-by: Philipp Gabler <phipsgabler@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
Is this ready to go, or is there something else that needs to be addressed? |
| meanfunction, | ||
| sampler::AbstractMCMC.AbstractSampler, | ||
| args...; | ||
| target=8.0, |
There was a problem hiding this comment.
Haha, not entirely certain what you're saying 😅 It's "random" in the sense that it just happened to be the number that you get from the default values of the models, but it's deliberate in the sense that it's the actual true mean of the posterior of the models with the default values:)
There was a problem hiding this comment.
So it's really the expected result, but only if you pass meanfunction = mean? I suspected it's either that or a random you put in for testing.
There was a problem hiding this comment.
So if IIUC, maybe that is better?
function test_sampler_demo_models(
meanfunction,
sampler::AbstractMCMC.AbstractSampler,
args...;
target,
atol=1e-1,
rtol=1e-3,
kwargs...,
)
...
end
test_sampler_demo_models(::typeof(mean), args...; kwargs...,) = test_sampler_demo_models(mean, args...; target=8.0, kwargs...)There was a problem hiding this comment.
It's not valid just for mean though. This is because different samplers can have completely different return-values from sample, and so we want to allow different mean functions, while still wanting the target to be 8.0.
|
Apart from the magic 8.0, looks good to me. |
devmotion
left a comment
There was a problem hiding this comment.
Some additional suggestions 🙂
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
|
bors r+ |
This PR adds a `DynamicPPL.TestUtils` submodule which is meant to include functionality to make it easy to test new samplers, new implementations of `AbstractVarInfo`, etc. As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using `.~`, some are using `@submodel`, etc. Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292. These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.
|
Build failed: |
|
bors r+ |
This PR adds a `DynamicPPL.TestUtils` submodule which is meant to include functionality to make it easy to test new samplers, new implementations of `AbstractVarInfo`, etc. As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using `.~`, some are using `@submodel`, etc. Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292. These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.
|
Build failed: |
|
bors r+ |
This PR adds a `DynamicPPL.TestUtils` submodule which is meant to include functionality to make it easy to test new samplers, new implementations of `AbstractVarInfo`, etc. As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using `.~`, some are using `@submodel`, etc. Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292. These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.
|
Pull request successfully merged into master. Build succeeded: |
This PR adds a
DynamicPPL.TestUtilssubmodule which is meant to include functionality to make it easy to test new samplers, new implementations ofAbstractVarInfo, etc.As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using
.~, some are using@submodel, etc.Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292.
These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.