@@ -145,22 +145,12 @@ struct RangeAndLinked
145145 is_linked:: Bool
146146end
147147
148- """
149- AbstractFastEvalContext
150-
151- Abstract type representing fast evaluation contexts. This currently is only subtyped by
152- `FastEvalVectorContext`. However, in the future, similar contexts may be implemented for
153- NamedTuple and Dict parameters.
154- """
155- abstract type AbstractFastEvalContext <: AbstractContext end
156- DynamicPPL. NodeTrait (:: AbstractFastEvalContext ) = DynamicPPL. IsLeaf ()
157-
158148"""
159149 FastEvalVectorContext(
160150 iden_varname_ranges::NamedTuple,
161151 varname_ranges::Dict{VarName,RangeAndLinked},
162152 params::AbstractVector{<:Real},
163- )
153+ ) <: AbstractContext
164154
165155A context that wraps a vector of parameter values, plus information about how random
166156variables map to ranges in that vector.
@@ -173,15 +163,16 @@ non-identity-optic VarNames are stored in the `varname_ranges` Dict.
173163It would be nice to unify the NamedTuple and Dict approach. See, e.g.
174164https://github.com/TuringLang/DynamicPPL.jl/issues/1116.
175165"""
176- struct FastEvalVectorContext{N<: NamedTuple ,T<: AbstractVector{<:Real} } < :
177- AbstractFastEvalContext
166+ struct FastEvalVectorContext{N<: NamedTuple ,T<: AbstractVector{<:Real} } <: AbstractContext
178167 # This NamedTuple stores the ranges for identity VarNames
179168 iden_varname_ranges:: N
180169 # This Dict stores the ranges for all other VarNames
181170 varname_ranges:: Dict{VarName,RangeAndLinked}
182171 # The full parameter vector which we index into to get variable values
183172 params:: T
184173end
174+ DynamicPPL. NodeTrait (:: FastEvalVectorContext ) = DynamicPPL. IsLeaf ()
175+
185176function get_range_and_linked (
186177 ctx:: FastEvalVectorContext , :: VarName{sym,typeof(identity)}
187178) where {sym}
0 commit comments