Skip to content

Commit 680ad24

Browse files
authored
fix splatting problem (#218)
* fix splatting problem * bump version * add test
1 parent 7d20c0f commit 680ad24

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MeasureTheory"
22
uuid = "eadaa1a4-d27c-401d-8699-e962e1bbc33b"
33
authors = ["Chad Scherrer <[email protected]> and contributors"]
4-
version = "0.16.5"
4+
version = "0.16.6"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/combinators/for.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ as(d::For) = as(Array, as(first(marginals(d))), size(first(d.inds))...)
7070
end
7171

7272
function logdensity_def(d::For, x::AbstractVector)
73-
get_i(j) = tuple((getindex(ind, j) for ind in d.inds)...)
73+
get_i(j) = map(Base.Fix2(getindex, j), d.inds)
74+
# get_i(j) = (getindex(ind, j) for ind in d.inds)
75+
# get_i(j) = tuple((getindex(ind, j) for ind in d.inds)...)
7476
sum(eachindex(x)) do j
7577
i = get_i(j)
7678
@inbounds logdensity_def(d.f(i...), x[j])
@@ -117,9 +119,8 @@ end
117119
::False,
118120
) where {T,F,I,N,B}
119121
dim = size(first(d.inds))
120-
base = For(d.inds) do j
121-
basemeasure(d.f(j)).base
122-
end
122+
f(args...) = basemeasure(d.f(args...)).base
123+
base = For(f, d.inds...)
123124
weightedmeasure(static(N) * prod(dim), base)
124125
end
125126

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,13 @@ end
635635
a b
636636
end
637637
end
638+
639+
@testset "https://github.com/cscherrer/MeasureTheory.jl/issues/217" begin
640+
d = For(rand(3), rand(3)) do x, y
641+
Normal(x, y)
642+
end
643+
644+
x = rand(d)
645+
646+
@test logdensityof(d, x) isa Real
647+
end

0 commit comments

Comments
 (0)