Skip to content

Commit 54ae7e3

Browse files
authored
Standardise :lp -> :logjoint (#1161)
* Standardise `:lp` -> `:logjoint` * changelog * fix a test
1 parent 993cc5b commit 54ae7e3

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ Leaf contexts require no changes, apart from a removal of the `NodeTrait` functi
6565
`ConditionContext` and `PrefixContext` are no longer exported.
6666
You should not need to use these directly, please use `AbstractPPL.condition` and `DynamicPPL.prefix` instead.
6767

68+
#### ParamsWithStats
69+
70+
In the 'stats' part of `DynamicPPL.ParamsWithStats`, the log-joint is now consistently represented with the key `logjoint` instead of `lp`.
71+
6872
#### Miscellaneous
6973

7074
Removed the method `returned(::Model, values, keys)`; please use `returned(::Model, ::AbstractDict{<:VarName})` instead.

src/chains.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function ParamsWithStats(
5757
(
5858
logprior=DynamicPPL.getlogprior(varinfo),
5959
loglikelihood=DynamicPPL.getloglikelihood(varinfo),
60-
lp=DynamicPPL.getlogjoint(varinfo),
60+
logjoint=DynamicPPL.getlogjoint(varinfo),
6161
),
6262
)
6363
end
@@ -158,7 +158,7 @@ function ParamsWithStats(
158158
(
159159
logprior=DynamicPPL.getlogprior(vi),
160160
loglikelihood=DynamicPPL.getloglikelihood(vi),
161-
lp=DynamicPPL.getlogjoint(vi),
161+
logjoint=DynamicPPL.getlogjoint(vi),
162162
),
163163
)
164164
end

test/chains.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ using Test
2020
@test length(ps.params) == 2
2121
@test haskey(ps.stats, :logprior)
2222
@test haskey(ps.stats, :loglikelihood)
23-
@test haskey(ps.stats, :lp)
23+
@test haskey(ps.stats, :logjoint)
2424
@test length(ps.stats) == 3
25-
@test ps.stats.lp ps.stats.logprior + ps.stats.loglikelihood
25+
@test ps.stats.logjoint ps.stats.logprior + ps.stats.loglikelihood
2626
@test ps.params[@varname(y)] ps.params[@varname(x)] + 1
2727
@test ps.stats.logprior logpdf(Normal(), ps.params[@varname(x)])
2828
@test ps.stats.loglikelihood logpdf(Normal(ps.params[@varname(y)]), z)
@@ -34,9 +34,9 @@ using Test
3434
@test length(ps.params) == 1
3535
@test haskey(ps.stats, :logprior)
3636
@test haskey(ps.stats, :loglikelihood)
37-
@test haskey(ps.stats, :lp)
37+
@test haskey(ps.stats, :logjoint)
3838
@test length(ps.stats) == 3
39-
@test ps.stats.lp ps.stats.logprior + ps.stats.loglikelihood
39+
@test ps.stats.logjoint ps.stats.logprior + ps.stats.loglikelihood
4040
@test ps.stats.logprior logpdf(Normal(), ps.params[@varname(x)])
4141
@test ps.stats.loglikelihood logpdf(Normal(ps.params[@varname(x)] + 1), z)
4242
end

test/ext/DynamicPPLMCMCChainsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using DynamicPPL, Distributions, MCMCChains, Test, AbstractMCMC
2020
@test size(c, 1) == 50
2121
@test size(c, 3) == 3
2222
@test Set(c.name_map.parameters) == Set([:x, :y])
23-
@test Set(c.name_map.internals) == Set([:logprior, :loglikelihood, :lp])
23+
@test Set(c.name_map.internals) == Set([:logprior, :loglikelihood, :logjoint])
2424
@test logpdf.(Normal(), c[:x]) c[:logprior]
2525
@test c.info.varname_to_symbol[@varname(x)] == :x
2626
@test c.info.varname_to_symbol[@varname(y)] == :y

0 commit comments

Comments
 (0)