From 523263a081e973c57ad75988d8d8dc09b14282ad Mon Sep 17 00:00:00 2001 From: "Tamas K. Papp" Date: Mon, 26 Dec 2022 21:16:02 +0100 Subject: [PATCH] add missing eltype method (#21) * add missing eltype method w/ test * version bump --- Project.toml | 2 +- src/AltDistributions.jl | 4 ++++ test/runtests.jl | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 699981e..5546de7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AltDistributions" uuid = "875e7ca2-ab9d-5828-93ae-a098eac53262" authors = ["Tamas K. Papp "] -version = "0.3.0" +version = "0.3.1" [deps] ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" diff --git a/src/AltDistributions.jl b/src/AltDistributions.jl index 965a80b..e6582c3 100644 --- a/src/AltDistributions.jl +++ b/src/AltDistributions.jl @@ -151,6 +151,10 @@ function rand(rng::AbstractRNG, sampler::SamplerTrivial{<:AltMvNormal}) L * randn(rng, length(μ)) .+ μ end +function Base.eltype(::Type{<:AltMvNormal{M,T}}) where {M,T} + Vector{promote_type(eltype(M), eltype(T))} +end + #### #### LKJL #### diff --git a/test/runtests.jl b/test/runtests.jl index f191ef9..9bdef84 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -141,6 +141,8 @@ end zs = reduce(hcat, rand(d, N)) @test vec(mean(zs, dims = 2)) ≈ μ atol = 0.02 @test cov(zs, dims = 2) ≈ Σ atol = 0.03 + z = rand(d) + @test z isa Vector{Float64} && all(isfinite, z) end end