Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement missing posterior_optima and likelihood_optima for a test model. #503

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DynamicPPL"
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
version = "0.23.5"
version = "0.23.6"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
57 changes: 57 additions & 0 deletions src/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,13 @@
function posterior_mean(model::UnivariateAssumeDemoModels)
return (s=49 / 24, m=7 / 6)
end
function likelihood_optima(::DynamicPPL.TestUtils.UnivariateAssumeDemoModels)
return (s=1/16, m=7/4)

Check warning on line 625 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L624-L625

Added lines #L624 - L625 were not covered by tests
yebai marked this conversation as resolved.
Show resolved Hide resolved
end
function posterior_optima(::DynamicPPL.TestUtils.UnivariateAssumeDemoModels)

Check warning on line 627 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L627

Added line #L627 was not covered by tests
# TODO: Figure out exact for `s`.
return (s=0.907407, m=7/6)

Check warning on line 629 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L629

Added line #L629 was not covered by tests
yebai marked this conversation as resolved.
Show resolved Hide resolved
end
function Random.rand(
rng::Random.AbstractRNG, ::Type{NamedTuple}, model::UnivariateAssumeDemoModels
)
Expand Down Expand Up @@ -654,6 +661,31 @@

return vals
end
function likelihood_optima(model::DynamicPPL.TestUtils.MultivariateAssumeDemoModels)

Check warning on line 664 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L664

Added line #L664 was not covered by tests
# Get some containers to fill.
vals = Random.rand(model)

Check warning on line 666 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L666

Added line #L666 was not covered by tests

# NOTE: These are "as close to zero as we can get".
vals.s[1] = 1e-32
vals.s[2] = 1e-32

Check warning on line 670 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L669-L670

Added lines #L669 - L670 were not covered by tests

vals.m[1] = 1.5
vals.m[2] = 2.0

Check warning on line 673 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L672-L673

Added lines #L672 - L673 were not covered by tests

return vals

Check warning on line 675 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L675

Added line #L675 was not covered by tests
end
function posterior_optima(model::DynamicPPL.TestUtils.MultivariateAssumeDemoModels)

Check warning on line 677 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L677

Added line #L677 was not covered by tests
# Get some containers to fill.
vals = Random.rand(model)

Check warning on line 679 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L679

Added line #L679 was not covered by tests

# TODO: Figure out exact for `s[1]`.
vals.s[1] = 0.890625
vals.s[2] = 1
vals.m[1] = 3/4
yebai marked this conversation as resolved.
Show resolved Hide resolved
vals.m[2] = 1

Check warning on line 685 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L682-L685

Added lines #L682 - L685 were not covered by tests

return vals

Check warning on line 687 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L687

Added line #L687 was not covered by tests
end
function Random.rand(
rng::Random.AbstractRNG, ::Type{NamedTuple}, model::MultivariateAssumeDemoModels
)
Expand Down Expand Up @@ -684,6 +716,31 @@

return vals
end
function likelihood_optima(model::DynamicPPL.TestUtils.MatrixvariateAssumeDemoModels)

Check warning on line 719 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L719

Added line #L719 was not covered by tests
# Get some containers to fill.
vals = Random.rand(model)

Check warning on line 721 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L721

Added line #L721 was not covered by tests

# NOTE: These are "as close to zero as we can get".
vals.s[1, 1] = 1e-32
vals.s[1, 2] = 1e-32

Check warning on line 725 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L724-L725

Added lines #L724 - L725 were not covered by tests

vals.m[1] = 1.5
vals.m[2] = 2.0

Check warning on line 728 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L727-L728

Added lines #L727 - L728 were not covered by tests

return vals

Check warning on line 730 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L730

Added line #L730 was not covered by tests
end
function posterior_optima(model::DynamicPPL.TestUtils.MatrixvariateAssumeDemoModels)

Check warning on line 732 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L732

Added line #L732 was not covered by tests
# Get some containers to fill.
vals = Random.rand(model)

Check warning on line 734 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L734

Added line #L734 was not covered by tests

# TODO: Figure out exact for `s[1]`.
vals.s[1, 1] = 0.890625
vals.s[1, 2] = 1
vals.m[1] = 3/4
yebai marked this conversation as resolved.
Show resolved Hide resolved
vals.m[2] = 1

Check warning on line 740 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L737-L740

Added lines #L737 - L740 were not covered by tests

return vals

Check warning on line 742 in src/test_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/test_utils.jl#L742

Added line #L742 was not covered by tests
end
function Base.rand(
rng::Random.AbstractRNG, ::Type{NamedTuple}, model::MatrixvariateAssumeDemoModels
)
Expand Down
Loading