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

Move ConditionalMeasure to MeasureBase #186

Open
cscherrer opened this issue Mar 29, 2022 · 0 comments
Open

Move ConditionalMeasure to MeasureBase #186

cscherrer opened this issue Mar 29, 2022 · 0 comments
Assignees

Comments

@cscherrer
Copy link
Collaborator

Currently in conditional.jl we have

using NestedTuples: lazymerge

struct ConditionalMeasure{M,C} <: AbstractMeasure
    parent::M 
    constraint::C
end

Base.:|::AbstractMeasure, constraint) = ConditionalMeasure(μ, constraint)

@inline function logdensity_def(cm::ConditionalMeasure, x)
    logdensity_def(cm.parent, lazymerge(cm.constraint, x))
end

@inline basemeasure(cm::ConditionalMeasure) = basemeasure(cm.parent) | cm.constraint

This really belongs as part of the interface, so it should be moved to MeasureBase. Also, the constraint could be extended beyond named tuples, so the logdensity_def method should really be

@inline function logdensity_def(cm::ConditionalMeasure{M,C}, x) where {M,C<:NamedTuple}
    logdensity_def(cm.parent, lazymerge(cm.constraint, x))
end
@cscherrer cscherrer self-assigned this Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant