Skip to content

Commit

Permalink
removing AbstractContext def and importing from AbstractPPL (#382)
Browse files Browse the repository at this point in the history
* removing AbstractContext def and importing from AbstractPPL

* Update Project.toml

* Update Project.toml

* Update to AbstractPPL 0.5 (PR to #382) (#385)

This PR updates #382.

It
- removes the `import` statement and instead qualifies all extended functions explicitly
- updates test/Project.toml

* Update bors.toml

Co-authored-by: Hong Ge <[email protected]>
Co-authored-by: David Widmann <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2022
1 parent 7f4f990 commit 083dfa1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DynamicPPL"
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
version = "0.17.6"
version = "0.17.7"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand All @@ -18,7 +18,7 @@ ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[compat]
AbstractMCMC = "2, 3.0"
AbstractPPL = "0.3, 0.4"
AbstractPPL = "0.5.1"
BangBang = "0.3"
Bijectors = "0.5.2, 0.6, 0.7, 0.8, 0.9, 0.10"
ChainRulesCore = "0.9.7, 0.10, 1"
Expand Down
4 changes: 2 additions & 2 deletions bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ delete_merged_branches = true
required_approvals = 1
# Squash commits before merging.
use_squash_merge = true
# Uncomment this to use a three hour timeout.
# Uncomment this to use a four hour timeout.
# The default is one hour.
timeout_sec = 10800
timeout_sec = 14400
12 changes: 3 additions & 9 deletions src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ module DynamicPPL

using AbstractMCMC: AbstractSampler, AbstractChains
using AbstractPPL
using Distributions
using Bijectors
using Distributions

using AbstractMCMC: AbstractMCMC
using BangBang: BangBang, push!!, empty!!, setindex!!
using ChainRulesCore: ChainRulesCore
using MacroTools: MacroTools
using ZygoteRules: ZygoteRules
using BangBang: BangBang
using Setfield: Setfield

using Setfield: Setfield
using BangBang: BangBang
using ZygoteRules: ZygoteRules

using Random: Random

Expand All @@ -32,8 +29,6 @@ import Base:
keys,
haskey

using BangBang: push!!, empty!!, setindex!!

# VarInfo
export AbstractVarInfo,
VarInfo,
Expand Down Expand Up @@ -137,7 +132,6 @@ log joint probability of the model.
See also: [`VarInfo`](@ref)
"""
abstract type AbstractVarInfo <: AbstractModelTrace end
abstract type AbstractContext end

include("utils.jl")
include("selector.jl")
Expand Down
18 changes: 12 additions & 6 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,17 @@ Returns both the return-value of the original model, and the resulting varinfo.
The method resets the log joint probability of `varinfo` and increases the evaluation
number of `sampler`.
"""
function evaluate!!(model::Model, varinfo::AbstractVarInfo, context::AbstractContext)
function AbstractPPL.evaluate!!(
model::Model, varinfo::AbstractVarInfo, context::AbstractContext
)
return if use_threadsafe_eval(context, varinfo)
evaluate_threadsafe!!(model, varinfo, context)
else
evaluate_threadunsafe!!(model, varinfo, context)
end
end

function evaluate!!(
function AbstractPPL.evaluate!!(
model::Model,
rng::Random.AbstractRNG,
varinfo::AbstractVarInfo=VarInfo(),
Expand All @@ -415,21 +417,25 @@ function evaluate!!(
return evaluate!!(model, varinfo, SamplingContext(rng, sampler, context))
end

evaluate!!(model::Model, context::AbstractContext) = evaluate!!(model, VarInfo(), context)
function AbstractPPL.evaluate!!(model::Model, context::AbstractContext)
return evaluate!!(model, VarInfo(), context)
end

function evaluate!!(model::Model, args...)
function AbstractPPL.evaluate!!(model::Model, args...)
return evaluate!!(model, Random.GLOBAL_RNG, args...)
end

# without VarInfo
function evaluate!!(
function AbstractPPL.evaluate!!(
model::Model, rng::Random.AbstractRNG, sampler::AbstractSampler, args...
)
return evaluate!!(model, rng, VarInfo(), sampler, args...)
end

# without VarInfo and without AbstractSampler
function evaluate!!(model::Model, rng::Random.AbstractRNG, context::AbstractContext)
function AbstractPPL.evaluate!!(
model::Model, rng::Random.AbstractRNG, context::AbstractContext
)
return evaluate!!(model, rng, VarInfo(), SampleFromPrior(), context)
end

Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
AbstractMCMC = "2.1, 3.0"
AbstractPPL = "0.3, 0.4"
AbstractPPL = "0.5.1"
Bijectors = "0.9.5, 0.10"
Distributions = "0.25"
DistributionsAD = "0.6.3"
Expand Down

2 comments on commit 083dfa1

@devmotion
Copy link
Member

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/55654

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 v0.17.7 -m "<description of version>" 083dfa11447e762aaa74a07e08c39f40b39a7d0e
git push origin v0.17.7

Please sign in to comment.