@@ -1088,7 +1088,9 @@ TestParentContext() = TestParentContext(DefaultContext())
1088
1088
DynamicPPL. NodeTrait (:: TestParentContext ) = DynamicPPL. IsParent ()
1089
1089
DynamicPPL. childcontext (context:: TestParentContext ) = context. context
1090
1090
DynamicPPL. setchildcontext (:: TestParentContext , child) = TestParentContext (child)
1091
- Base. show (io:: IO , c:: TestParentContext ) = print (io, " TestParentContext(" , DynamicPPL. childcontext (c), " )" )
1091
+ function Base. show (io:: IO , c:: TestParentContext )
1092
+ return print (io, " TestParentContext(" , DynamicPPL. childcontext (c), " )" )
1093
+ end
1092
1094
1093
1095
"""
1094
1096
test_context(context::AbstractContext, model::Model)
@@ -1103,19 +1105,27 @@ function test_context(context::DynamicPPL.AbstractContext, model::DynamicPPL.Mod
1103
1105
# `NodeTrait`.
1104
1106
node_trait = DynamicPPL. NodeTrait (context)
1105
1107
# Throw error immediately if it it's missing a `NodeTrait` implementation.
1106
- node_trait isa Union{DynamicPPL. IsLeaf, DynamicPPL. IsParent} || throw (ValueError (" Invalid NodeTrait: $node_trait " ))
1108
+ node_trait isa Union{DynamicPPL. IsLeaf,DynamicPPL. IsParent} ||
1109
+ throw (ValueError (" Invalid NodeTrait: $node_trait " ))
1107
1110
1108
1111
# The interface methods.
1109
1112
if node_trait isa DynamicPPL. IsParent
1110
1113
# `childcontext` and `setchildcontext`
1111
1114
# With new child context
1112
1115
childcontext_new = TestParentContext ()
1113
- @test DynamicPPL. childcontext (DynamicPPL. setchildcontext (context, childcontext_new)) == childcontext_new
1116
+ @test DynamicPPL. childcontext (
1117
+ DynamicPPL. setchildcontext (context, childcontext_new)
1118
+ ) == childcontext_new
1114
1119
end
1115
1120
1116
1121
# To see change, let's make sure we're using a different leaf context than the current.
1117
- leafcontext_new = DynamicPPL. leafcontext (context) isa DefaultContext ? PriorContext () : DefaultContext ()
1118
- @test DynamicPPL. leafcontext (DynamicPPL. setleafcontext (context, leafcontext_new)) == leafcontext_new
1122
+ leafcontext_new = if DynamicPPL. leafcontext (context) isa DefaultContext
1123
+ PriorContext ()
1124
+ else
1125
+ DefaultContext ()
1126
+ end
1127
+ @test DynamicPPL. leafcontext (DynamicPPL. setleafcontext (context, leafcontext_new)) ==
1128
+ leafcontext_new
1119
1129
1120
1130
# Make sure that the we can evaluate the model with the context (i.e. that none of the tilde-functions are incorrectly overloaded).
1121
1131
# The tilde-pipeline contains two different paths: with `SamplingContext` as a parent, and without it.
0 commit comments