Skip to content

Commit

Permalink
Merge pull request #341 from ReactiveBayes/linearizedproductof-sample…
Browse files Browse the repository at this point in the history
…list

add linearizedproductof to lowprioritycandidates for sample list form constraint
  • Loading branch information
wouterwln authored Aug 1, 2024
2 parents 04ea9fc + 44b9e49 commit 858000c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 858000c

Please sign in to comment.