Skip to content

Commit

Permalink
Check if log density supports LogDensityProblems (#111)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
devmotion and github-actions[bot] authored Dec 29, 2022
1 parent 18ea3f1 commit 50cdf04
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/IntegrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
fail-fast: false
matrix:
package:
- {user: TuringLang, repo: AdvancedHMC.jl}
- {user: TuringLang, repo: AdvancedMH.jl}
- {user: TuringLang, repo: EllipticalSliceSampling.jl}
- {user: TuringLang, repo: MCMCChains.jl}
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
keywords = ["markov chain monte carlo", "probablistic programming"]
license = "MIT"
desc = "A lightweight interface for common MCMC methods."
version = "4.2"
version = "4.2.1"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
ConsoleProgressMonitor = "88cd18e8-d9cc-4ea6-8889-5259c0d15c8b"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
Expand All @@ -20,6 +21,7 @@ Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
[compat]
BangBang = "0.3.19"
ConsoleProgressMonitor = "0.1"
LogDensityProblems = "2"
LoggingExtras = "0.4, 0.5"
ProgressLogging = "0.1"
StatsBase = "0.32, 0.33"
Expand Down
1 change: 1 addition & 0 deletions src/AbstractMCMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module AbstractMCMC

using BangBang: BangBang
using ConsoleProgressMonitor: ConsoleProgressMonitor
using LogDensityProblems: LogDensityProblems
using LoggingExtras: LoggingExtras
using ProgressLogging: ProgressLogging
using StatsBase: StatsBase
Expand Down
12 changes: 12 additions & 0 deletions src/logdensityproblems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ that the wrapped object implements the LogDensityProblems.jl interface.
"""
struct LogDensityModel{L} <: AbstractModel
logdensity::L
function LogDensityModel{L}(logdensity::L) where {L}
if LogDensityProblems.capabilities(logdensity) === nothing
throw(
ArgumentError(
"The log density function does not support the LogDensityProblems.jl interface",
),
)
end
return new{L}(logdensity)
end
end

LogDensityModel(logdensity::L) where {L} = LogDensityModel{L}(logdensity)

2 comments on commit 50cdf04

@devmotion
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74775

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v4.2.1 -m "<description of version>" 50cdf04980ebed131d19768453a2ff3226dc068f
git push origin v4.2.1

Please sign in to comment.