-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Description
The distinction between _getvalue, getval, and getindex is rather confusing. I suggested here to simplify the implementation of SimpleVarInfo as
haskey(vi::SimpleVarInfo, vn) = haskey(vi.θ, getsym(vn))
istrans(::SimpleVarInfo, vn::VarName) = false
getindex(vi::SimpleVarInfo, spl::SampleFromPrior) = vi.θ
getindex(vi::SimpleVarInfo, spl::SampleFromUniform) = vi.θ
# TODO: Should we do better?
getindex(vi::SimpleVarInfo, spl::Sampler) = vi.θ
function getindex(vi::SimpleVarInfo, vn::VarName{sym}) where {sym}
value = getproperty(nt, sym)
return _getindex(value, vn.indexing)
end
getindex(vi::SimpleVarInfo, vns::AbstractArray{<:VarName}) = map(vn -> getindex(vi, vn), vns)but that could lead to problems in the original VarInfo, which uses the other functions all over the place. Ideally, we get rid of _getvalue and getval completely and rely only on getindex.
(_getindex is a different case -- it performs the recursive indexing for VarNames, e.g. in x[1][2][3].)
Metadata
Metadata
Assignees
Labels
No labels