Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename init_params keyword argument to initial_params #33

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EllipticalSliceSampling"
uuid = "cad2338a-1db2-11e9-3401-43bc07c9ede2"
authors = ["David Widmann <[email protected]>"]
version = "1.1.0"
version = "2.0.0"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand All @@ -11,7 +11,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
AbstractMCMC = "3.2, 4"
AbstractMCMC = "5"
ArrayInterface = "7"
Distributions = "0.22, 0.23, 0.24, 0.25"
julia = "1.6"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ AbstractMCMC.steps(
gives you access to an iterator from which you can generate an unlimited
number of samples.

You can define the starting point of your chain using the `init_params` keyword argument.
You can define the starting point of your chain using the `initial_params` keyword argument.

For more details regarding `sample` and `steps` please check the documentation of
[AbstractMCMC.jl](https://github.com/TuringLang/AbstractMCMC.jl).
Expand Down
4 changes: 2 additions & 2 deletions src/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function AbstractMCMC.step(
rng::Random.AbstractRNG,
model::AbstractMCMC.AbstractModel,
::ESS;
init_params=nothing,
initial_params=nothing,
kwargs...,
)
# initial sample from the Gaussian prior
f = init_params === nothing ? initial_sample(rng, model) : init_params
f = initial_params === nothing ? initial_sample(rng, model) : initial_params

# compute log-likelihood of the initial sample
loglikelihood = Distributions.loglikelihood(model, f)
Expand Down
32 changes: 24 additions & 8 deletions test/simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
# initial parameter
init_x = randn(5)
samples = sample(
ESSModel(prior, ℓ), ESS(), alg, 10, 5; progress=false, init_params=init_x
ESSModel(prior, ℓ), ESS(), alg, 10, 5; progress=false, initial_params=init_x
)
@test map(first, samples) == init_x
end

# initial parameter
init_x = randn()
samples = sample(ESSModel(prior, ℓ), ESS(), 10; progress=false, init_params=init_x)
samples = sample(
ESSModel(prior, ℓ), ESS(), 10; progress=false, initial_params=init_x
)
@test first(samples) == init_x
end

Expand Down Expand Up @@ -77,14 +79,16 @@
# initial parameter
init_x = randn(5)
samples = sample(
ESSModel(prior, ℓ), ESS(), alg, 10, 5; progress=false, init_params=init_x
ESSModel(prior, ℓ), ESS(), alg, 10, 5; progress=false, initial_params=init_x
)
@test map(first, samples) == init_x
end

# initial parameter
init_x = randn()
samples = sample(ESSModel(prior, ℓ), ESS(), 10; progress=false, init_params=init_x)
samples = sample(
ESSModel(prior, ℓ), ESS(), 10; progress=false, initial_params=init_x
)
@test first(samples) == init_x
end

Expand Down Expand Up @@ -118,15 +122,21 @@
# initial parameter
init_x = [randn(1) for _ in 1:5]
samples = sample(
ESSModel(prior, ℓvec), ESS(), alg, 10, 5; progress=false, init_params=init_x
ESSModel(prior, ℓvec),
ESS(),
alg,
10,
5;
progress=false,
initial_params=init_x,
)
@test map(first, samples) == init_x
end

# initial parameter
init_x = randn(1)
samples = sample(
ESSModel(prior, ℓvec), ESS(), 10; progress=false, init_params=init_x
ESSModel(prior, ℓvec), ESS(), 10; progress=false, initial_params=init_x
)
@test first(samples) == init_x
end
Expand Down Expand Up @@ -161,15 +171,21 @@
# initial parameter
init_x = [randn(1) for _ in 1:5]
samples = sample(
ESSModel(prior, ℓvec), ESS(), alg, 10, 5; progress=false, init_params=init_x
ESSModel(prior, ℓvec),
ESS(),
alg,
10,
5;
progress=false,
initial_params=init_x,
)
@test map(first, samples) == init_x
end

# initial parameter
init_x = randn(1)
samples = sample(
ESSModel(prior, ℓvec), ESS(), 10; progress=false, init_params=init_x
ESSModel(prior, ℓvec), ESS(), 10; progress=false, initial_params=init_x
)
@test first(samples) == init_x
end
Expand Down
Loading