Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add linearizedproductof to lowprioritycandidates for sample list form constraint #341

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/constraints/form/form_sample_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ __approximate(constraint::SampleListFormConstraint{N, R, S, M}, left, right) whe
# which is not in the `AutoProposalLowPriorityCandidates` list
# For example if we have a product of a `Gaussian` and a `ContinuousGenericLogPdf` the `AutoProposal` strategy
# should pick the `Gaussian` as the proposal distribution
const AutoProposalLowPriorityCandidates = Union{AbstractContinuousGenericLogPdf}
const AutoProposalLowPriorityCandidates = Union{AbstractContinuousGenericLogPdf, LinearizedProductOf}

function __approximate(constraint::SampleListFormConstraint{N, R, S, M}, left::AutoProposalLowPriorityCandidates, right) where {N, R, S <: AutoProposal, M}
return BayesBase.approximate_prod_with_sample_list(constraint.rng, constraint.method, right, left, N)
Expand Down
10 changes: 10 additions & 0 deletions test/constraints/form/form_sample_list_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@
end
end
end

@testset "approximation when left or right is LinearizedProductOf" begin
using LinearAlgebra
left = MvNormalMeanCovariance(randn(2), Diagonal(rand(2)))

right = LinearizedProductOf([ContinuousMultivariateLogPdf(2, (x) -> rand()) for _ in 1:10], 10)
constraint = SampleListFormConstraint(100)
q = constrain_form(constraint, prod(GenericProd(), left, right))
@test q isa SampleList
end
end
Loading