Skip to content

Commit

Permalink
Merge pull request #85 from TuringLang/kx/fix-resize
Browse files Browse the repository at this point in the history
Fix resize
  • Loading branch information
yebai authored Jul 26, 2019
2 parents e09185d + 4e123a1 commit 48287bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/adaptation/precond.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function Base.resize!(
if length(θ) != length(dpc.var)
@assert dpc.ve.n == 0 "Cannot resize a var estimator when it contains samples."
dpc.ve = WelfordVar(T, length(θ))
dpc.var = zeros(T, length(θ))
dpc.var = ones(T, length(θ))
end
end
function Base.resize!(
Expand Down
4 changes: 2 additions & 2 deletions test/adaptation/precond.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
AdvancedHMC.adapt!(pc1, θ, 1.)
AdvancedHMC.adapt!(pc2, θ, 1.)
AdvancedHMC.adapt!(pc3, θ, 1.)
@test AdvancedHMC.Adaptation.getM⁻¹(pc2) == zeros(length(θ))
@test AdvancedHMC.Adaptation.getM⁻¹(pc2) == ones(length(θ))
@test AdvancedHMC.Adaptation.getM⁻¹(pc3) == LinearAlgebra.diagm(0 => ones(length(θ)))
end

Expand All @@ -75,6 +75,6 @@ end
AdvancedHMC.adapt!(adaptor1, θ, 1.)
AdvancedHMC.adapt!(adaptor2, θ, 1.)
AdvancedHMC.adapt!(adaptor3, θ, 1.)
@test AdvancedHMC.Adaptation.getM⁻¹(adaptor2) == zeros(length(θ))
@test AdvancedHMC.Adaptation.getM⁻¹(adaptor2) == ones(length(θ))
@test AdvancedHMC.Adaptation.getM⁻¹(adaptor3) == LinearAlgebra.diagm(0 => ones(length(θ)))
end

0 comments on commit 48287bc

Please sign in to comment.