Skip to content

Commit 6fc6e0a

Browse files
authored
Merge pull request #27 from devmotion/abstractmcmc
Account for breaking changes in AbstractMCMC
2 parents 5dbf958 + 65527e3 commit 6fc6e0a

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "AdvancedMH"
22
uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170"
3-
version = "0.5.1"
3+
version = "0.6.0"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
@@ -9,7 +9,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
99
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1010

1111
[compat]
12-
AbstractMCMC = "0.4, 0.5, 1"
12+
AbstractMCMC = "1"
1313
Distributions = "0.20, 0.21, 0.22, 0.23"
1414
Requires = "1.0"
1515
julia = "1"

src/AdvancedMH.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module AdvancedMH
22

33
# Import the relevant libraries.
4-
import AbstractMCMC
4+
using AbstractMCMC
55
using Distributions
66
using Requires
77

@@ -11,8 +11,7 @@ import Random
1111
export MetropolisHastings, DensityModel, RWMH, StaticMH, StaticProposal, RandomWalkProposal
1212

1313
# Reexports
14-
using AbstractMCMC: sample, psample
15-
export sample, psample
14+
export sample, MCMCThreads, MCMCDistributed
1615

1716
# Abstract type for MH-style samplers.
1817
abstract type Metropolis <: AbstractMCMC.AbstractSampler end

test/runtests.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ using Test
5353
@test mean(chain2.σ) 1.0 atol=0.1
5454
end
5555

56-
if VERSION >= v"1.3"
57-
@testset "psample" begin
58-
spl1 = StaticMH([Normal(0,1), Normal(0, 1)])
59-
chain1 = psample(model, spl1, 10000, 4; param_names=["μ", "σ"], chain_type=Chains)
60-
@test mean(chain1["μ"].value) 0.0 atol=0.1
61-
@test mean(chain1["σ"].value) 1.0 atol=0.1
56+
@testset "parallel sampling" begin
57+
spl1 = StaticMH([Normal(0,1), Normal(0, 1)])
58+
59+
chain1 = sample(model, spl1, MCMCDistributed(), 10000, 4;
60+
param_names=["μ", "σ"], chain_type=Chains)
61+
@test mean(chain1["μ"].value) 0.0 atol=0.1
62+
@test mean(chain1["σ"].value) 1.0 atol=0.1
63+
64+
if VERSION >= v"1.3"
65+
chain2 = sample(model, spl1, MCMCThreads(), 10000, 4;
66+
param_names=["μ", "σ"], chain_type=Chains)
67+
@test mean(chain2["μ"].value) 0.0 atol=0.1
68+
@test mean(chain2["σ"].value) 1.0 atol=0.1
6269
end
6370
end
6471

0 commit comments

Comments
 (0)