Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
torfjelde and github-actions[bot] authored Nov 28, 2024
1 parent d503c3c commit acb2cb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions ext/DynamicPPLJETExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function DynamicPPL.determine_varinfo(
model::DynamicPPL.Model,
context::DynamicPPL.AbstractContext=DynamicPPL.DefaultContext();
verbose::Bool=false,
only_tilde::Bool=true
only_tilde::Bool=true,
)
# First we try with the typed varinfo.
varinfo = DynamicPPL.typed_varinfo(model)
Expand Down Expand Up @@ -88,4 +88,3 @@ function DynamicPPL.determine_varinfo(
end

end

15 changes: 10 additions & 5 deletions test/ext/DynamicPPLJETExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
end
end
model = demo1()
@test DynamicPPL.determine_varinfo(model; verbose=true) isa DynamicPPL.UntypedVarInfo
@test DynamicPPL.determine_varinfo(model; verbose=true) isa
DynamicPPL.UntypedVarInfo

@model demo2() = x ~ Normal()
@test DynamicPPL.determine_varinfo(demo2()) isa DynamicPPL.TypedVarInfo
Expand All @@ -24,7 +25,8 @@
z ~ Normal()
end
end
@test DynamicPPL.determine_varinfo(demo3(); verbose=true) isa DynamicPPL.UntypedVarInfo
@test DynamicPPL.determine_varinfo(demo3(); verbose=true) isa
DynamicPPL.UntypedVarInfo

# Evaluation works (and it would even do so in practice), but sampling
# fill fail due to storing `Cauchy{Float64}` in `Vector{Normal{Float64}}`.
Expand All @@ -36,7 +38,8 @@
y ~ Cauchy() # different distibution, but same transformation => should work
end
end
@test DynamicPPL.determine_varinfo(demo4(); verbose=true) isa DynamicPPL.UntypedVarInfo
@test DynamicPPL.determine_varinfo(demo4(); verbose=true) isa
DynamicPPL.UntypedVarInfo

# In this model, the type error occurs in the user code rather than in DynamicPPL.
@model function demo5()
Expand All @@ -48,9 +51,11 @@
return sum(xs)
end
# Should pass if we're only checking the tilde statements.
@test DynamicPPL.determine_varinfo(demo5(); verbose=true) isa DynamicPPL.TypedVarInfo
@test DynamicPPL.determine_varinfo(demo5(); verbose=true) isa
DynamicPPL.TypedVarInfo
# Should fail if we're including errors in the model body.
@test DynamicPPL.determine_varinfo(demo5(); verbose=true, only_tilde=false) isa DynamicPPL.UntypedVarInfo
@test DynamicPPL.determine_varinfo(demo5(); verbose=true, only_tilde=false) isa
DynamicPPL.UntypedVarInfo
end

@testset "demo models" begin
Expand Down

0 comments on commit acb2cb0

Please sign in to comment.