Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Jan 9, 2025
1 parent b5573a3 commit 268aa3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions test/contexts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ end
end

@testset "Dict" begin
ctx = ConditionContext(Dict(@varname(x) => 1, @varname(y) => 2, @varname(z) => 3))
ctx = ConditionContext(
Dict(@varname(x) => 1, @varname(y) => 2, @varname(z) => 3)
)
# Decondition all variables
@test decondition_context(ctx) isa DefaultContext
# Decondition only some variables
Expand All @@ -254,7 +256,8 @@ end
@test dctx isa ConditionContext
@test dctx.values == Dict(@varname(x) => 1)
# Decondition all variables manually
@test decondition_context(ctx, @varname(x), @varname(y), @varname(z)) isa DefaultContext
@test decondition_context(ctx, @varname(x), @varname(y), @varname(z)) isa
DefaultContext
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ const GDEMO_DEFAULT = DynamicPPL.TestUtils.demo_assume_observe_literal()
@testset "model conditioning with various arguments" begin
@model function demo_condition()
x ~ Normal()
y ~ Normal(x)
return y ~ Normal(x)
end
model = demo_condition()
# Test that different syntaxes work and give the same underlying ConditionContext
@testset "NamedTuple ConditionContext" begin
expected_values = (y = 2,)
expected_values = (y=2,)
@test condition(model, (y=2,)).context.values == expected_values
@test condition(model, y=2).context.values == expected_values
@test condition(model; y=2).context.values == expected_values
@test (model | (y = 2, )).context.values == expected_values
@test condition(model; y=2).context.values == expected_values
@test (model | (y=2,)).context.values == expected_values
end
@testset "AbstractDict ConditionContext" begin
expected_values = Dict(@varname(y) => 2)
@test condition(model, Dict(@varname(y) => 2)).context.values == expected_values
@test condition(model, @varname(y) => 2).context.values == expected_values
@test (model | (@varname(y) => 2, )).context.values == expected_values
@test (model | (@varname(y) => 2,)).context.values == expected_values
end
end

Expand Down

0 comments on commit 268aa3a

Please sign in to comment.