Skip to content

Commit ef6522f

Browse files
committed
Remove initialstep, rework default_varinfo
1 parent a8a7026 commit ef6522f

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# DynamicPPL Changelog
22

3+
## 0.36.9
4+
5+
Removed the `DynamicPPL.initialstep` method. This method was unexported. If you were relying on this, you should directly use `AbstractMCMC.step`.
6+
7+
`DynamicPPL.default_varinfo` now takes two additional optional arguments, `initial_params` (an AbstractVector or nothing) and `link` (a Bool). These are used to generate the initial varinfo.
8+
39
## 0.36.8
410

511
Made `LogDensityFunction` a subtype of `AbstractMCMC.AbstractModel`.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DynamicPPL"
22
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
3-
version = "0.36.8"
3+
version = "0.36.9"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/sampler.jl

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,45 +71,25 @@ Return a default varinfo object for the given `model` and `sampler`.
7171
- `rng::Random.AbstractRNG`: Random number generator.
7272
- `model::Model`: Model for which we want to create a varinfo object.
7373
- `sampler::AbstractSampler`: Sampler which will make use of the varinfo object.
74-
- `context::AbstractContext`: Context in which the model is evaluated.
74+
- `initial_params::Union{AbstractVector,Nothing}`: Initial parameter values to
75+
be set in the varinfo object.
76+
- `link::Bool`: Whether to link the varinfo.
77+
- `context::AbstractContext`: Context in which the model is evaluated. Defaults
78+
to `DefaultContext()`.
7579
7680
# Returns
7781
- `AbstractVarInfo`: Default varinfo object for the given `model` and `sampler`.
7882
"""
79-
function default_varinfo(rng::Random.AbstractRNG, model::Model, sampler::AbstractSampler)
80-
return default_varinfo(rng, model, sampler, DefaultContext())
81-
end
8283
function default_varinfo(
8384
rng::Random.AbstractRNG,
8485
model::Model,
8586
sampler::AbstractSampler,
86-
context::AbstractContext,
87+
initial_params::Union{AbstractVector,Nothing}=nothing,
88+
link::Bool=false,
89+
context::AbstractContext=DefaultContext(),
8790
)
8891
init_sampler = initialsampler(sampler)
89-
return typed_varinfo(rng, model, init_sampler, context)
90-
end
91-
92-
function AbstractMCMC.sample(
93-
rng::Random.AbstractRNG,
94-
model::Model,
95-
sampler::Sampler,
96-
N::Integer;
97-
chain_type=default_chain_type(sampler),
98-
resume_from=nothing,
99-
initial_state=loadstate(resume_from),
100-
kwargs...,
101-
)
102-
return AbstractMCMC.mcmcsample(
103-
rng, model, sampler, N; chain_type, initial_state, kwargs...
104-
)
105-
end
106-
107-
# initial step: general interface for resuming and
108-
function AbstractMCMC.step(
109-
rng::Random.AbstractRNG, model::Model, spl::Sampler; initial_params=nothing, kwargs...
110-
)
111-
# Sample initial values.
112-
vi = default_varinfo(rng, model, spl)
92+
vi = typed_varinfo(rng, model, init_sampler, context)
11393

11494
# Update the parameters if provided.
11595
if initial_params !== nothing
@@ -122,7 +102,7 @@ function AbstractMCMC.step(
122102
vi = last(evaluate!!(model, vi, DefaultContext()))
123103
end
124104

125-
return initialstep(rng, model, spl, vi; initial_params, kwargs...)
105+
return vi
126106
end
127107

128108
"""

0 commit comments

Comments
 (0)