diff --git a/src/constraints/form/form_sample_list.jl b/src/constraints/form/form_sample_list.jl index 11749be4b..ce6033808 100644 --- a/src/constraints/form/form_sample_list.jl +++ b/src/constraints/form/form_sample_list.jl @@ -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) diff --git a/test/constraints/form/form_sample_list_tests.jl b/test/constraints/form/form_sample_list_tests.jl index af7b950a0..6a1afb4f9 100644 --- a/test/constraints/form/form_sample_list_tests.jl +++ b/test/constraints/form/form_sample_list_tests.jl @@ -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