@@ -502,52 +502,6 @@ If no `Type` is provided, return values as stored in `varinfo`.
502502
503503# Examples
504504
505- `SimpleVarInfo` with `NamedTuple`:
506-
507- ```jldoctest
508- julia> data = (x = 1.0, m = [2.0]);
509-
510- julia> values_as(SimpleVarInfo(data))
511- (x = 1.0, m = [2.0])
512-
513- julia> values_as(SimpleVarInfo(data), NamedTuple)
514- (x = 1.0, m = [2.0])
515-
516- julia> values_as(SimpleVarInfo(data), OrderedDict)
517- OrderedDict{VarName{sym, typeof(identity)} where sym, Any} with 2 entries:
518- x => 1.0
519- m => [2.0]
520-
521- julia> values_as(SimpleVarInfo(data), Vector)
522- 2-element Vector{Float64}:
523- 1.0
524- 2.0
525- ```
526-
527- `SimpleVarInfo` with `OrderedDict`:
528-
529- ```jldoctest
530- julia> data = OrderedDict{Any,Any}(@varname(x) => 1.0, @varname(m) => [2.0]);
531-
532- julia> values_as(SimpleVarInfo(data))
533- OrderedDict{Any, Any} with 2 entries:
534- x => 1.0
535- m => [2.0]
536-
537- julia> values_as(SimpleVarInfo(data), NamedTuple)
538- (x = 1.0, m = [2.0])
539-
540- julia> values_as(SimpleVarInfo(data), OrderedDict)
541- OrderedDict{Any, Any} with 2 entries:
542- x => 1.0
543- m => [2.0]
544-
545- julia> values_as(SimpleVarInfo(data), Vector)
546- 2-element Vector{Float64}:
547- 1.0
548- 2.0
549- ```
550-
551505`VarInfo` with `NamedTuple` of `Metadata`:
552506
553507```jldoctest
@@ -828,8 +782,8 @@ function link!!(vi::AbstractVarInfo, vns::VarNameTuple, model::Model)
828782 return link!! (default_transformation (model, vi), vi, vns, model)
829783end
830784function link!! (t:: DynamicTransformation , vi:: AbstractVarInfo , model:: Model )
831- # Note that in practice this method is only called for SimpleVarInfo, because VarInfo
832- # has a dedicated implementation
785+ # Note that VarInfo has a dedicated implementation so this is only a generic
786+ # fallback (previously used for SimpleVarInfo)
833787 model = setleafcontext (model, DynamicTransformationContext {false} ())
834788 vi = last (evaluate!! (model, vi))
835789 return set_transformed!! (vi, t)
@@ -890,8 +844,8 @@ function invlink!!(vi::AbstractVarInfo, vns::VarNameTuple, model::Model)
890844 return invlink!! (default_transformation (model, vi), vi, vns, model)
891845end
892846function invlink!! (:: DynamicTransformation , vi:: AbstractVarInfo , model:: Model )
893- # Note that in practice this method is only called for SimpleVarInfo, because VarInfo
894- # has a dedicated implementation
847+ # Note that VarInfo has a dedicated implementation so this is only a generic
848+ # fallback (previously used for SimpleVarInfo)
895849 model = setleafcontext (model, DynamicTransformationContext {true} ())
896850 vi = last (evaluate!! (model, vi))
897851 return set_transformed!! (vi, NoTransformation ())
@@ -946,47 +900,6 @@ This will be called prior to `model` evaluation, allowing one to perform a singl
946900basis as is done with [`DynamicTransformation`](@ref).
947901
948902See also: [`StaticTransformation`](@ref), [`DynamicTransformation`](@ref).
949-
950- # Examples
951- ```julia-repl
952- julia> using DynamicPPL, Distributions, Bijectors
953-
954- julia> @model demo() = x ~ Normal()
955- demo (generic function with 2 methods)
956-
957- julia> # By subtyping `Transform`, we inherit the `(inv)link!!`.
958- struct MyBijector <: Bijectors.Transform end
959-
960- julia> # Define some dummy `inverse` which will be used in the `link!!` call.
961- Bijectors.inverse(f::MyBijector) = identity
962-
963- julia> # We need to define `with_logabsdet_jacobian` for `MyBijector`
964- # (`identity` already has `with_logabsdet_jacobian` defined)
965- function Bijectors.with_logabsdet_jacobian(::MyBijector, x)
966- # Just using a large number of the logabsdet-jacobian term
967- # for demonstration purposes.
968- return (x, 1000)
969- end
970-
971- julia> # Change the `default_transformation` for our model to be a
972- # `StaticTransformation` using `MyBijector`.
973- function DynamicPPL.default_transformation(::Model{typeof(demo)})
974- return DynamicPPL.StaticTransformation(MyBijector())
975- end
976-
977- julia> model = demo();
978-
979- julia> vi = SimpleVarInfo(x=1.0)
980- SimpleVarInfo((x = 1.0,), 0.0)
981-
982- julia> # Uses the `inverse` of `MyBijector`, which we have defined as `identity`
983- vi_linked = link!!(vi, model)
984- Transformed SimpleVarInfo((x = 1.0,), 0.0)
985-
986- julia> # Now performs a single `invlink!!` before model evaluation.
987- logjoint(model, vi_linked)
988- -1001.4189385332047
989- ```
990903"""
991904function maybe_invlink_before_eval!! (vi:: AbstractVarInfo , model:: Model )
992905 return maybe_invlink_before_eval!! (transformation (vi), vi, model)
0 commit comments