Skip to content

Commit 44c55bb

Browse files
committed
Merge branch 'master' into torfjelde/step-warmup
2 parents 6e8f88e + 8431b31 commit 44c55bb

File tree

5 files changed

+82
-7
lines changed

5 files changed

+82
-7
lines changed

.github/workflows/DocsNav.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Add Navbar
2+
3+
on:
4+
page_build: # Triggers the workflow on push events to gh-pages branch
5+
workflow_dispatch: # Allows manual triggering
6+
schedule:
7+
- cron: '0 0 * * 0' # Runs every week on Sunday at midnight (UTC)
8+
9+
jobs:
10+
add-navbar:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Checkout gh-pages
16+
uses: actions/checkout@v4
17+
with:
18+
ref: gh-pages
19+
fetch-depth: 0
20+
21+
- name: Download insert_navbar.sh
22+
run: |
23+
curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh
24+
chmod +x insert_navbar.sh
25+
26+
- name: Update Navbar
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
git config user.name github-actions[bot]
31+
git config user.email github-actions[bot]@users.noreply.github.com
32+
33+
# Define the URL of the navbar to be used
34+
NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/TuringNavbar.html"
35+
36+
# Update all HTML files in the current directory (gh-pages root)
37+
./insert_navbar.sh . $NAVBAR_URL
38+
39+
# Remove the insert_navbar.sh file
40+
rm insert_navbar.sh
41+
42+
# Check if there are any changes
43+
if [[ -n $(git status -s) ]]; then
44+
git add .
45+
git commit -m "Added navbar and removed insert_navbar.sh"
46+
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages
47+
else
48+
echo "No changes to commit"
49+
fi

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name = "AbstractMCMC"
22
uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
3-
keywords = ["markov chain monte carlo", "probablistic programming"]
3+
keywords = ["markov chain monte carlo", "probabilistic programming"]
44
license = "MIT"
55
desc = "A lightweight interface for common MCMC methods."
6-
version = "5.0.0"
6+
version = "5.3.0"
77

88
[deps]
99
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
@@ -20,7 +20,7 @@ TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
2020
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
2121

2222
[compat]
23-
BangBang = "0.3.19"
23+
BangBang = "0.3.19, 0.4"
2424
ConsoleProgressMonitor = "0.1"
2525
FillArrays = "1"
2626
LogDensityProblems = "2"

src/AbstractMCMC.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ include("stepper.jl")
8888
include("transducer.jl")
8989
include("logdensityproblems.jl")
9090

91+
if isdefined(Base.Experimental, :register_error_hint)
92+
function __init__()
93+
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, _
94+
if Base.parentmodule(exc.f) == LogDensityProblems &&
95+
any(a -> a <: LogDensityModel, argtypes)
96+
print(
97+
io,
98+
"\n`AbstractMCMC.LogDensityModel` is a wrapper and does not itself implement the LogDensityProblems.jl interface. To use LogDensityProblems.jl methods, access the inner type with (e.g.) `logdensity(model.logdensity, params)` instead of `logdensity(model, params)`.",
99+
)
100+
end
101+
end
102+
end
103+
end
104+
91105
end # module AbstractMCMC

src/sample.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
const PROGRESS = Ref(true)
33

44
"""
5-
setprogress!(progress::Bool)
5+
setprogress!(progress::Bool; silent::Bool=false)
66
7-
Enable progress logging globally if `progress` is `true`, and disable it otherwise.
7+
Enable progress logging globally if `progress` is `true`, and disable it otherwise.
8+
Optionally disable informational message if `silent` is `true`.
89
"""
9-
function setprogress!(progress::Bool)
10-
@info "progress logging is $(progress ? "enabled" : "disabled") globally"
10+
function setprogress!(progress::Bool; silent::Bool=false)
11+
if !silent
12+
@info "progress logging is $(progress ? "enabled" : "disabled") globally"
13+
end
1114
PROGRESS[] = progress
1215
return progress
1316
end

test/logdensityproblems.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
@test model.logdensity ===
2323

2424
@test_throws ArgumentError AbstractMCMC.LogDensityModel(mylogdensity)
25+
26+
try
27+
LogDensityProblems.logdensity(model, ones(10))
28+
catch exc
29+
@test exc isa MethodError
30+
if isdefined(Base.Experimental, :register_error_hint)
31+
@test occursin("is a wrapper", sprint(showerror, exc))
32+
end
33+
end
2534
end
2635

2736
@testset "fallback for log densities" begin

0 commit comments

Comments
 (0)