Skip to content

Commit 310c50d

Browse files
authored
fix bugs and add test (#114)
1 parent f1ffda1 commit 310c50d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
33
keywords = ["probablistic programming"]
44
license = "MIT"
55
desc = "Common interfaces for probabilistic programming"
6-
version = "0.10.0"
6+
version = "0.10.1"
77

88
[deps]
99
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

src/abstractprobprog.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ end
128128
Draw a sample from the predictive distribution specified by `model` with its parameters fixed to `params`.
129129
"""
130130
function StatsBase.predict(model::AbstractProbabilisticProgram, params)
131-
return predict(Random.default_rng(), NamedTuple, model, params)
131+
return StatsBase.predict(Random.default_rng(), model, params)
132132
end

test/abstractprobprog.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ function Base.rand(rng::Random.AbstractRNG, ::Type{T}, model::RandModel) where {
1313
return nothing
1414
end
1515

16+
struct PredModel <: AbstractProbabilisticProgram end
17+
18+
function AbstractPPL.predict(rng::Random.AbstractRNG, model::PredModel, params)
19+
return rng
20+
end
21+
1622
@testset "AbstractProbabilisticProgram" begin
1723
@testset "rand defaults" begin
1824
model = RandModel(nothing, nothing)
@@ -34,4 +40,9 @@ end
3440
@test model.T === NamedTuple
3541
end
3642
end
43+
44+
@testset "predict defaults" begin
45+
model = PredModel()
46+
@test AbstractPPL.predict(model, nothing) == Random.default_rng()
47+
end
3748
end

0 commit comments

Comments
 (0)