From fa6c84225d9cd2be4771eb70f36ebf30afa55d72 Mon Sep 17 00:00:00 2001 From: Jasper Behrensdorf Date: Thu, 5 Dec 2024 17:48:26 +0100 Subject: [PATCH] Fix broadcasting of inputs (#238) --- src/inputs/inputs.jl | 2 ++ test/inputs/inputs.jl | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/inputs/inputs.jl b/src/inputs/inputs.jl index bdffcdede..03ad4b162 100644 --- a/src/inputs/inputs.jl +++ b/src/inputs/inputs.jl @@ -56,3 +56,5 @@ function sns_zero_point(inputs::AbstractVector{<:UQInput}) return sns end + +Base.broadcastable(i::T) where {T<:UQInput} = Ref(i) diff --git a/test/inputs/inputs.jl b/test/inputs/inputs.jl index af61c2ebf..79a77d534 100644 --- a/test/inputs/inputs.jl +++ b/test/inputs/inputs.jl @@ -31,4 +31,10 @@ inputs = [pi, jd, z] @testset "count_rvs" begin @test count_rvs(inputs) == 3 end + + @testset "broadcasting" begin + x = RandomVariable(Normal(), :x) + u = rand(10) + @test pdf.(x.dist, u) == pdf.(x, u) + end end