Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
sunxd3 and github-actions[bot] authored Jul 1, 2024
1 parent e978bc8 commit 5088996
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ext/DynamicPPLReverseDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ function LogDensityProblemsAD.ADgradient(
)
end

function DynamicPPL.setmodel(f::LogDensityProblemsAD.ReverseDiffLogDensity{L,Nothing}, model::DynamicPPL.Model) where {L}
function DynamicPPL.setmodel(
f::LogDensityProblemsAD.ReverseDiffLogDensity{L,Nothing}, model::DynamicPPL.Model
) where {L}
return Accessors.@set f.= setmodel(f.ℓ, model)
end

function DynamicPPL.setmodel(f::LogDensityProblemsAD.ReverseDiffLogDensity{L,C}, model::DynamicPPL.Model) where {L,C}
function DynamicPPL.setmodel(
f::LogDensityProblemsAD.ReverseDiffLogDensity{L,C}, model::DynamicPPL.Model
) where {L,C}
new_f = LogDensityProblemsAD.ADGradient(Val(:ReverseDiff), f.ℓ; compile=Val(true)) # TODO: without a input, can get error
return Accessors.@set new_f.= setmodel(f.ℓ, model)
end
Expand Down
1 change: 0 additions & 1 deletion test/logdensityfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ using Test, DynamicPPL, LogDensityProblems
∇ℓ = LogDensityProblems.ADgradient(:ReverseDiff, ℓ; compile=Val(false))
@test DynamicPPL.getmodel(∇ℓ) == model
@test getmodel(DynamicPPL.setmodel(∇ℓ, model)) == model

∇ℓ = LogDensityProblems.ADgradient(:ReverseDiff, ℓ; compile=Val(true))
new_∇ℓ = DynamicPPL.setmodel(∇ℓ, model)
@test DynamicPPL.getmodel(new_∇ℓ) == model
Expand Down

0 comments on commit 5088996

Please sign in to comment.