Skip to content

Commit

Permalink
Rename init_params keyword argument to initial_params (#33)
Browse files Browse the repository at this point in the history
* Rename `init_params` keyword argument to `initial_params`

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
devmotion and github-actions[bot] committed Oct 27, 2023
1 parent ca4babb commit 0a0853d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Project.toml
@@ -1,7 +1,7 @@
name = "EllipticalSliceSampling"
uuid = "cad2338a-1db2-11e9-3401-43bc07c9ede2"
authors = ["David Widmann <david.widmann@it.uu.se>"]
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
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
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
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

2 comments on commit 0a0853d

@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/94202

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 v2.0.0 -m "<description of version>" 0a0853deedc90831572cff381b3649005955e849
git push origin v2.0.0

Please sign in to comment.