@@ -131,9 +131,7 @@ A context used for checking validity of a model.
131131# Fields
132132$(FIELDS)
133133"""
134- struct DebugContext{M<: Model ,C<: AbstractContext } <: AbstractContext
135- " model that is being run"
136- model:: M
134+ struct DebugContext{C<: AbstractContext } <: AbstractContext
137135 " context used for running the model"
138136 context:: C
139137 " mapping from varnames to the number of times they have been seen"
@@ -149,7 +147,6 @@ struct DebugContext{M<:Model,C<:AbstractContext} <: AbstractContext
149147end
150148
151149function DebugContext (
152- model:: Model ,
153150 context:: AbstractContext = DefaultContext ();
154151 varnames_seen= OrderedDict {VarName,Int} (),
155152 statements= Vector {Stmt} (),
@@ -158,7 +155,6 @@ function DebugContext(
158155 record_varinfo= false ,
159156)
160157 return DebugContext (
161- model,
162158 context,
163159 varnames_seen,
164160 statements,
@@ -344,7 +340,7 @@ function check_varnames_seen(varnames_seen::AbstractDict{VarName,Int})
344340end
345341
346342# A check we run on the model before evaluating it.
347- function check_model_pre_evaluation (context :: DebugContext , model:: Model )
343+ function check_model_pre_evaluation (model:: Model )
348344 issuccess = true
349345 # If something is in the model arguments, then it should NOT be in `condition`,
350346 # nor should there be any symbol present in `condition` that has the same symbol.
@@ -361,8 +357,8 @@ function check_model_pre_evaluation(context::DebugContext, model::Model)
361357 return issuccess
362358end
363359
364- function check_model_post_evaluation (context :: DebugContext , model:: Model )
365- return check_varnames_seen (context. varnames_seen)
360+ function check_model_post_evaluation (model:: Model )
361+ return check_varnames_seen (model . context. varnames_seen)
366362end
367363
368364"""
@@ -443,21 +439,18 @@ function check_model_and_trace(
443439)
444440 # Execute the model with the debug context.
445441 debug_context = DebugContext (
446- model,
447- SamplingContext (rng, model. context);
448- error_on_failure= error_on_failure,
449- kwargs... ,
442+ SamplingContext (rng, model. context); error_on_failure= error_on_failure, kwargs...
450443 )
451444 debug_model = DynamicPPL. contextualize (model, debug_context)
452445
453446 # Perform checks before evaluating the model.
454- issuccess = check_model_pre_evaluation (debug_context, debug_model)
447+ issuccess = check_model_pre_evaluation (debug_model)
455448
456449 # Force single-threaded execution.
457450 DynamicPPL. evaluate_threadunsafe!! (debug_model, varinfo)
458451
459452 # Perform checks after evaluating the model.
460- issuccess &= check_model_post_evaluation (debug_context, debug_model)
453+ issuccess &= check_model_post_evaluation (debug_model)
461454
462455 if ! issuccess && error_on_failure
463456 error (" model check failed" )
0 commit comments