6
6
# VarInfo metadata #
7
7
# ###################
8
8
9
+ abstract type DynamicPPLAny end
10
+ Base. convert (:: Type{DynamicPPLAny} , x) = x
11
+ Base. zero (:: Type{DynamicPPLAny} ) = zero (LogProbType)
12
+
9
13
"""
10
14
The `Metadata` struct stores some metadata about the parameters of the model. This helps
11
15
query certain information about a variable, such as its distribution, which samplers
@@ -37,7 +41,7 @@ struct Metadata{
37
41
TIdcs<: Dict{<:VarName,Int} ,
38
42
TDists<: AbstractVector{<:Distribution} ,
39
43
TVN<: AbstractVector{<:VarName} ,
40
- TVal<: AbstractVector{<:Any } ,
44
+ TVal<: AbstractVector{<:DynamicPPLAny } ,
41
45
}
42
46
# Mapping from the `VarName` to its integer index in `vns`, `ranges` and `dists`
43
47
idcs:: TIdcs # Dict{<:VarName,Int}
@@ -51,7 +55,7 @@ struct Metadata{
51
55
52
56
# Vector of values of all the univariate, multivariate and matrix variables
53
57
# The value(s) of `vn` is/are `vals[ranges[idcs[vn]]]`
54
- vals:: TVal # AbstractVector{<:Any }
58
+ vals:: TVal # AbstractVector{<:DynamicPPLAny }
55
59
56
60
# Vector of distributions correpsonding to `vns`
57
61
dists:: TDists # AbstractVector{<:Distribution}
@@ -409,7 +413,7 @@ unflatten_metadata(vnv::VarNamedVector, x::AbstractVector) = unflatten(vnv, x)
409
413
Construct an empty type unstable instance of `Metadata`.
410
414
"""
411
415
function Metadata ()
412
- vals = Vector {Any } ()
416
+ vals = Vector {DynamicPPLAny } ()
413
417
flags = Dict {String,BitVector} ()
414
418
flags[" del" ] = BitVector ()
415
419
flags[" trans" ] = BitVector ()
@@ -576,8 +580,8 @@ function merge_metadata(metadata_left::Metadata, metadata_right::Metadata)
576
580
T_right = eltype (metadata_right. vals)
577
581
T = promote_type (T_left, T_right)
578
582
# TODO : Is this necessary?
579
- if ! (T <: Any )
580
- T = Any
583
+ if ! (T <: DynamicPPLAny )
584
+ T = DynamicPPLAny
581
585
end
582
586
583
587
# Determine `eltype` of `dists`.
@@ -766,8 +770,8 @@ getindex_internal(vi::VarInfo, ::Colon) = getindex_internal(vi.metadata, Colon()
766
770
function getindex_internal (vi:: NTVarInfo , :: Colon )
767
771
return reduce (vcat, map (Base. Fix2 (getindex_internal, Colon ()), vi. metadata))
768
772
end
769
- function getindex_internal (vi :: VarInfo{NamedTuple{(),Tuple{}}} , :: Colon )
770
- return Any []
773
+ function getindex_internal (:: VarInfo{NamedTuple{(),Tuple{}}} , :: Colon )
774
+ return DynamicPPLAny []
771
775
end
772
776
function getindex_internal (md:: Metadata , :: Colon )
773
777
return mapreduce (
0 commit comments