Skip to content

Commit 50cdf04

Browse files
Check if log density supports LogDensityProblems (#111)
* Check if log density supports LogDensityProblems * Load LogDensityProblems * Update Project.toml * Update src/logdensityproblems.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Add AdvancedHMC to downstream tests Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 18ea3f1 commit 50cdf04

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

.github/workflows/IntegrationTest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
package:
17+
- {user: TuringLang, repo: AdvancedHMC.jl}
1718
- {user: TuringLang, repo: AdvancedMH.jl}
1819
- {user: TuringLang, repo: EllipticalSliceSampling.jl}
1920
- {user: TuringLang, repo: MCMCChains.jl}

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
33
keywords = ["markov chain monte carlo", "probablistic programming"]
44
license = "MIT"
55
desc = "A lightweight interface for common MCMC methods."
6-
version = "4.2"
6+
version = "4.2.1"
77

88
[deps]
99
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
1010
ConsoleProgressMonitor = "88cd18e8-d9cc-4ea6-8889-5259c0d15c8b"
1111
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
12+
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
1213
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1314
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
1415
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
@@ -20,6 +21,7 @@ Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
2021
[compat]
2122
BangBang = "0.3.19"
2223
ConsoleProgressMonitor = "0.1"
24+
LogDensityProblems = "2"
2325
LoggingExtras = "0.4, 0.5"
2426
ProgressLogging = "0.1"
2527
StatsBase = "0.32, 0.33"

src/AbstractMCMC.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module AbstractMCMC
22

33
using BangBang: BangBang
44
using ConsoleProgressMonitor: ConsoleProgressMonitor
5+
using LogDensityProblems: LogDensityProblems
56
using LoggingExtras: LoggingExtras
67
using ProgressLogging: ProgressLogging
78
using StatsBase: StatsBase

src/logdensityproblems.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,16 @@ that the wrapped object implements the LogDensityProblems.jl interface.
1212
"""
1313
struct LogDensityModel{L} <: AbstractModel
1414
logdensity::L
15+
function LogDensityModel{L}(logdensity::L) where {L}
16+
if LogDensityProblems.capabilities(logdensity) === nothing
17+
throw(
18+
ArgumentError(
19+
"The log density function does not support the LogDensityProblems.jl interface",
20+
),
21+
)
22+
end
23+
return new{L}(logdensity)
24+
end
1525
end
26+
27+
LogDensityModel(logdensity::L) where {L} = LogDensityModel{L}(logdensity)

0 commit comments

Comments
 (0)