|  | 
| 67 | 67 | 
 | 
| 68 | 68 |     @testset "demo models" begin | 
| 69 | 69 |         @testset "$(model.f)" for model in DynamicPPL.TestUtils.DEMO_MODELS | 
| 70 |  | -            sampling_model = contextualize(model, SamplingContext(model.context)) | 
| 71 | 70 |             # Use debug logging below. | 
| 72 | 71 |             varinfo = DynamicPPL.Experimental.determine_suitable_varinfo(model) | 
| 73 |  | -            # Check that the inferred varinfo is indeed suitable for evaluation and sampling | 
| 74 |  | -            f_eval, argtypes_eval = DynamicPPL.DebugUtils.gen_evaluator_call_with_types( | 
| 75 |  | -                model, varinfo | 
| 76 |  | -            ) | 
| 77 |  | -            JET.test_call(f_eval, argtypes_eval) | 
| 78 |  | - | 
| 79 |  | -            f_sample, argtypes_sample = DynamicPPL.DebugUtils.gen_evaluator_call_with_types( | 
| 80 |  | -                sampling_model, varinfo | 
| 81 |  | -            ) | 
| 82 |  | -            JET.test_call(f_sample, argtypes_sample) | 
| 83 | 72 |             # For our demo models, they should all result in typed. | 
| 84 | 73 |             is_typed = varinfo isa DynamicPPL.NTVarInfo | 
| 85 | 74 |             @test is_typed | 
| 86 |  | -            # If the test failed, check why it didn't infer a typed varinfo | 
|  | 75 | +            # If the test failed, check what the type stability problem was for | 
|  | 76 | +            # the typed varinfo. This is mostly useful for debugging from test | 
|  | 77 | +            # logs. | 
| 87 | 78 |             if !is_typed | 
|  | 79 | +                @info "Model `$(model.f)` is not type stable with typed varinfo." | 
| 88 | 80 |                 typed_vi = DynamicPPL.typed_varinfo(model) | 
| 89 |  | -                f_eval, argtypes_eval = DynamicPPL.DebugUtils.gen_evaluator_call_with_types( | 
| 90 |  | -                    model, typed_vi | 
|  | 81 | + | 
|  | 82 | +                @info "Evaluating with DefaultContext:" | 
|  | 83 | +                model = DynamicPPL.contextualize( | 
|  | 84 | +                    model, | 
|  | 85 | +                    DynamicPPL.setleafcontext(model.context, DynamicPPL.DefaultContext()), | 
|  | 86 | +                ) | 
|  | 87 | +                f, argtypes = DynamicPPL.DebugUtils.gen_evaluator_call_with_types( | 
|  | 88 | +                    model, varinfo | 
|  | 89 | +                ) | 
|  | 90 | +                JET.test_call(f, argtypes) | 
|  | 91 | + | 
|  | 92 | +                @info "Initialising with InitContext:" | 
|  | 93 | +                model = DynamicPPL.contextualize( | 
|  | 94 | +                    model, | 
|  | 95 | +                    DynamicPPL.setleafcontext(model.context, DynamicPPL.InitContext()), | 
| 91 | 96 |                 ) | 
| 92 |  | -                JET.test_call(f_eval, argtypes_eval) | 
| 93 |  | -                f_sample, argtypes_sample = DynamicPPL.DebugUtils.gen_evaluator_call_with_types( | 
| 94 |  | -                    sampling_model, typed_vi | 
|  | 97 | +                f, argtypes = DynamicPPL.DebugUtils.gen_evaluator_call_with_types( | 
|  | 98 | +                    model, varinfo | 
| 95 | 99 |                 ) | 
| 96 |  | -                JET.test_call(f_sample, argtypes_sample) | 
|  | 100 | +                JET.test_call(f, argtypes) | 
| 97 | 101 |             end | 
| 98 | 102 |         end | 
| 99 | 103 |     end | 
|  | 
0 commit comments