Skip to content

Commit dd4690f

Browse files
committed
Soss tests passing
1 parent 897511e commit dd4690f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/combinators/power.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ function Pretty.tile(μ::PowerMeasure)
2424
return Pretty.pair_layout(arg1, arg2; sep = " ^ ")
2525
end
2626

27-
function Base.rand(rng::AbstractRNG, ::Type{T}, d::PowerMeasure) where {T}
27+
function Base.rand(rng::AbstractRNG, ::Type{T}, d::PowerMeasure{M}) where {T, M<:AbstractMeasure}
2828
map(CartesianIndices(d.axes)) do _
2929
rand(rng, T, d.parent)
3030
end
3131
end
3232

33+
function Base.rand(rng::AbstractRNG, ::Type{T}, d::PowerMeasure) where {T}
34+
map(CartesianIndices(d.axes)) do _
35+
rand(rng, d.parent)
36+
end
37+
end
3338

3439
@inline function powermeasure(x::T, sz::Tuple{Vararg{<:Any,N}}) where {T, N}
3540
a = axes(Fill{T, N}(x, sz))

src/combinators/product.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,22 @@ Base.size(μ::AbstractProductMeasure) = size(marginals(μ))
2525
basemeasure(d::AbstractProductMeasure) = productmeasure(map(basemeasure, marginals(d)))
2626

2727
function Base.rand(rng::AbstractRNG, ::Type{T}, d::AbstractProductMeasure) where {T}
28-
map(marginals(d)) do dⱼ
28+
mar = marginals(d)
29+
_rand_product(rng, T, mar, eltype(mar))
30+
end
31+
32+
function _rand_product(rng::AbstractRNG, ::Type{T}, mar, ::Type{M}) where {T,M<:AbstractMeasure}
33+
map(mar) do dⱼ
2934
rand(rng, T, dⱼ)
3035
end
3136
end
3237

38+
function _rand_product(rng::AbstractRNG, ::Type{T}, mar, ::Type{M}) where {T,M}
39+
map(mar) do dⱼ
40+
rand(rng, dⱼ)
41+
end
42+
end
43+
3344
@inline function logdensity_def(d::AbstractProductMeasure, x)
3445
mapreduce(logdensity_def, +, marginals(d), x)
3546
end

0 commit comments

Comments
 (0)