Skip to content

Commit

Permalink
reverted merge with torfjelde/extract-realizations
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde committed Apr 19, 2024
1 parent af64356 commit 33a84c7
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 208 deletions.
6 changes: 0 additions & 6 deletions docs/src/api.md
Expand Up @@ -143,12 +143,6 @@ Sometimes it can be useful to extract the priors of a model. This is the possibl
extract_priors
```

Safe extraction of values from a given [`AbstractVarInfo`](@ref) as they are seen in the model can be done using [`values_as_in_model`](@ref).

```@docs
values_as_in_model
```

```@docs
NamedDist
```
Expand Down
2 changes: 0 additions & 2 deletions src/DynamicPPL.jl
Expand Up @@ -93,7 +93,6 @@ export AbstractVarInfo,
getargnames,
generated_quantities,
extract_priors,
values_as_in_model,
# Samplers
Sampler,
SampleFromPrior,
Expand Down Expand Up @@ -179,7 +178,6 @@ include("transforming.jl")
include("logdensityfunction.jl")
include("model_utils.jl")
include("extract_priors.jl")
include("values_as_in_model.jl")

if !isdefined(Base, :get_extension)
using Requires
Expand Down
181 changes: 0 additions & 181 deletions src/values_as_in_model.jl

This file was deleted.

20 changes: 1 addition & 19 deletions test/model.jl
Expand Up @@ -356,7 +356,7 @@ is_typed_varinfo(varinfo::DynamicPPL.SimpleVarInfo{<:NamedTuple}) = true
]
@testset "$(model.f)" for model in models_to_test
vns = DynamicPPL.TestUtils.varnames(model)
example_values = DynamicPPL.TestUtils.rand_prior_true(model)
example_values = DynamicPPL.TestUtils.rand(model)
varinfos = filter(
is_typed_varinfo,
DynamicPPL.TestUtils.setup_varinfos(model, example_values, vns),
Expand All @@ -375,22 +375,4 @@ is_typed_varinfo(varinfo::DynamicPPL.SimpleVarInfo{<:NamedTuple}) = true
end
end
end

@testset "values_as_in_model" begin
@testset "$(model.f)" for model in DynamicPPL.TestUtils.DEMO_MODELS
vns = DynamicPPL.TestUtils.varnames(model)
example_values = DynamicPPL.TestUtils.rand_prior_true(model)
varinfos = DynamicPPL.TestUtils.setup_varinfos(model, example_values, vns)
@testset "$(short_varinfo_name(varinfo))" for varinfo in varinfos
realizations = values_as_in_model(model, varinfo)
# Ensure that all variables are found.
vns_found = collect(keys(realizations))
@test vns vns_found == vns vns_found
# Ensure that the values are the same.
for vn in vns
@test realizations[vn] == varinfo[vn]
end
end
end
end
end

0 comments on commit 33a84c7

Please sign in to comment.