Skip to content

Commit eea384c

Browse files
committed
Merge remote-tracking branch 'origin/main' into breaking
2 parents ff8d01e + d8fbe78 commit eea384c

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

.github/workflows/Tests.yml

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,47 +66,33 @@ jobs:
6666

6767
steps:
6868
- name: Print matrix variables
69+
6970
run: |
7071
echo "OS: ${{ matrix.runner.os }}"
7172
echo "Julia version: ${{ matrix.runner.version }}"
7273
echo "Number of threads: ${{ matrix.runner.num_threads }}"
7374
echo "Test arguments: ${{ matrix.test.args }}"
74-
- name: (De)activate coverage analysis
75-
run: echo "COVERAGE=${{ matrix.runner.version == '1' && matrix.runner.os == 'ubuntu-latest' && matrix.runner.num_threads == 2 }}" >> "$GITHUB_ENV"
76-
shell: bash
75+
7776
- uses: actions/checkout@v4
77+
7878
- uses: julia-actions/setup-julia@v2
7979
with:
8080
version: '${{ matrix.runner.version }}'
81+
8182
- uses: julia-actions/cache@v2
83+
8284
- uses: julia-actions/julia-buildpkg@v1
83-
# TODO: Use julia-actions/julia-runtest when test_args are supported
84-
# Custom calls of Pkg.test tend to miss features such as e.g. adjustments for CompatHelper PRs
85-
# Ref https://github.com/julia-actions/julia-runtest/pull/73
86-
- name: Call Pkg.test
87-
run: julia --color=yes --inline=yes --depwarn=yes --check-bounds=yes --threads=${{ matrix.runner.num_threads }} --project=@. -e 'import Pkg; Pkg.test(; coverage=parse(Bool, ENV["COVERAGE"]), test_args=ARGS)' -- ${{ matrix.test.args }}
85+
86+
- uses: julia-actions/julia-runtest@v1
87+
with:
88+
test_args: ${{ matrix.test.args }}
89+
env:
90+
JULIA_NUM_THREADS: ${{ matrix.runner.num_threads }}
91+
8892
- uses: julia-actions/julia-processcoverage@v1
89-
if: ${{ env.COVERAGE }}
90-
- uses: codecov/codecov-action@v4
91-
if: ${{ env.COVERAGE }}
93+
94+
- uses: codecov/codecov-action@v5
9295
with:
93-
fail_ci_if_error: true
96+
files: lcov.info
9497
token: ${{ secrets.CODECOV_TOKEN }}
95-
file: lcov.info
96-
- uses: coverallsapp/github-action@v2
97-
if: ${{ env.COVERAGE }}
98-
with:
99-
github-token: ${{ secrets.GITHUB_TOKEN }}
100-
path-to-lcov: lcov.info
101-
flag-name: run-${{ join(matrix.*, '-') }}
102-
parallel: true
103-
104-
finish:
105-
needs: test
106-
if: ${{ always() }}
107-
runs-on: ubuntu-latest
108-
steps:
109-
- name: Coveralls Finished
110-
uses: coverallsapp/github-action@v2
111-
with:
112-
parallel-finished: true
98+
fail_ci_if_error: true

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Note that if the initial sample is included, the corresponding sampler statistic
77
Due to a technical limitation of MCMCChains.jl, this causes all indexing into MCMCChains to return `Union{Float64, Missing}` or similar.
88
If you want the old behaviour, you can discard the first sample (e.g. using `discard_initial=1`).
99

10+
# 0.40.4
11+
12+
Fixes a bug where `initial_state` was not respected for NUTS if `resume_from` was not also specified.
13+
1014
# 0.40.3
1115

1216
This patch makes the `resume_from` keyword argument work correctly when sampling multiple chains.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a href="https://turinglang.org/"><img src="https://img.shields.io/badge/docs-tutorials-blue.svg" alt="Tutorials" /></a>
66
<a href="https://turinglang.org/Turing.jl/stable"><img src="https://img.shields.io/badge/docs-API-blue.svg" alt="API docs" /></a>
77
<a href="https://github.com/TuringLang/Turing.jl/actions/workflows/Tests.yml"><img src="https://github.com/TuringLang/Turing.jl/actions/workflows/Tests.yml/badge.svg" alt="Tests" /></a>
8-
<a href="https://coveralls.io/github/TuringLang/Turing.jl?branch=main"><img src="https://coveralls.io/repos/github/TuringLang/Turing.jl/badge.svg?branch=main" alt="Coverage" /></a>
8+
<a href="https://codecov.io/gh/TuringLang/Turing.jl"><img src="https://codecov.io/gh/TuringLang/Turing.jl/branch/main/graph/badge.svg" alt="Code Coverage" /></a>
99
<a href="https://github.com/SciML/ColPrac"><img src="https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet" alt="ColPrac: Contributor's Guide on Collaborative Practices for Community Packages" /></a>
1010
</p>
1111

src/mcmc/hmc.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ function AbstractMCMC.sample(
120120
sampler,
121121
N;
122122
chain_type=chain_type,
123+
initial_state=initial_state,
123124
progress=progress,
124125
nadapts=_nadapts,
125126
discard_initial=_discard_initial,

test/mcmc/hmc.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,27 @@ using Turing
219219
@test_throws ErrorException sample(demo_impossible(), NUTS(), 5)
220220
end
221221

222+
@testset "NUTS initial parameters" begin
223+
@model function f()
224+
x ~ Normal()
225+
return 10 ~ Normal(x)
226+
end
227+
chn1 = sample(StableRNG(468), f(), NUTS(), 100; save_state=true)
228+
# chn1 should end up around x = 5.
229+
chn2 = sample(
230+
StableRNG(468),
231+
f(),
232+
NUTS(),
233+
10;
234+
nadapts=0,
235+
discard_adapt=false,
236+
initial_state=chn1.info.samplerstate,
237+
)
238+
# if chn2 uses initial_state, its first sample should be somewhere around 5. if
239+
# initial_state isn't used, it will be sampled from [-2, 2] so this test should fail
240+
@test isapprox(chn2[:x][1], 5.0; atol=2.0)
241+
end
242+
222243
@testset "(partially) issue: #2095" begin
223244
@model function vector_of_dirichlet((::Type{TV})=Vector{Float64}) where {TV}
224245
xs = Vector{TV}(undef, 2)

0 commit comments

Comments
 (0)