Skip to content

Commit bae04ff

Browse files
committed
Add output if a typed varinfo isn't inferred
1 parent 080366a commit bae04ff

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

test/ext/DynamicPPLJETExt.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,31 @@
6464
@testset "$(model.f)" for model in DynamicPPL.TestUtils.DEMO_MODELS
6565
# Use debug logging below.
6666
varinfo = DynamicPPL.Experimental.determine_suitable_varinfo(model)
67-
# They should all result in typed.
68-
@test varinfo isa DynamicPPL.TypedVarInfo
69-
# But let's also make sure that they're not lying by checking the
70-
# type inference with a typed varinfo.
67+
# Check that the inferred varinfo is indeed suitable for evaluation and sampling
7168
f_eval, argtypes_eval = DynamicPPL.DebugUtils.gen_evaluator_call_with_types(
72-
model, VarInfo(model)
69+
model, varinfo
7370
)
7471
JET.test_call(f_eval, argtypes_eval)
7572

7673
f_sample, argtypes_sample = DynamicPPL.DebugUtils.gen_evaluator_call_with_types(
77-
model, VarInfo(model), DynamicPPL.SamplingContext()
74+
model, varinfo, DynamicPPL.SamplingContext()
7875
)
7976
JET.test_call(f_sample, argtypes_sample)
77+
# For our demo models, they should all result in typed.
78+
is_typed = varinfo isa DynamicPPL.TypedVarInfo
79+
@test is_typed
80+
# If the test failed, check why it didn't infer a typed varinfo
81+
if !is_typed
82+
typed_vi = VarInfo(model)
83+
f_eval, argtypes_eval = DynamicPPL.DebugUtils.gen_evaluator_call_with_types(
84+
model, typed_vi
85+
)
86+
JET.test_call(f_eval, argtypes_eval)
87+
f_sample, argtypes_sample = DynamicPPL.DebugUtils.gen_evaluator_call_with_types(
88+
model, typed_vi, DynamicPPL.SamplingContext()
89+
)
90+
JET.test_call(f_sample, argtypes_sample)
91+
end
8092
end
8193
end
8294
end

0 commit comments

Comments
 (0)