Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop lying about eltype #19

Open
kleinschmidt opened this issue Dec 6, 2017 · 0 comments
Open

Stop lying about eltype #19

kleinschmidt opened this issue Dec 6, 2017 · 0 comments

Comments

@kleinschmidt
Copy link
Member

kleinschmidt commented Dec 6, 2017

The eltype of, for instance, NormalInverseGamma should be Tuple{Float64, Float64}, but instead is given as Float64. This means that rand chokes because it allocates an array of floats instead of an array of tuples:

julia> d = ConjugatePriors.NormalInverseGamma(0., 1., 2, 2)
ConjugatePriors.NormalInverseGamma{Float64}(mu=0.0, v0=1.0, shape=2.0, scale=2.0)

julia> rand(d)
(-0.6216462947065958, 0.7004872075936253)

julia> rand(d, 2)
ERROR: MethodError: Cannot `convert` an object of type Tuple{Float64,Float64} to an object of type Float64
This may have arisen from a call to the constructor Float64(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] _rand!(::ConjugatePriors.NormalInverseGamma{Float64}, ::Array{Float64,1}) at /home/dave/.julia/v0.6/Distributions/src/genericrand.jl:37
 [2] rand(::ConjugatePriors.NormalInverseGamma{Float64}, ::Int64) at /home/dave/.julia/v0.6/Distributions/src/univariates.jl:182

julia> eltype(d)
Float64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant