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

eltype for Distribution type is ambiguous #223

Closed
bvdmitri opened this issue Oct 10, 2022 · 1 comment
Closed

eltype for Distribution type is ambiguous #223

bvdmitri opened this issue Oct 10, 2022 · 1 comment
Assignees

Comments

@bvdmitri
Copy link
Member

Now we use the Base.eltype option to determine the sample type of some Distribution. For example:

  • eltype(NormalMeanVariance(...)) === Float64
  • eltype(MvNormalMeanCovariance(...)) === Vector{Float64}
  • eltype(Wishart(...)) === Matrix{Float64}

This leads to ambiguities with the SampleList "distribution", which defines eltype both over its sample type and weight type, e.g.:

  • Tuple{Float64, Float64}
  • Tuple{Vector{Float64}, Float64}
  • Tuple{Matrix{Float64}, Float64}

We cannot really change the behaviour of the eltype function for the SampleList, because eltype is used by the Julia language itself for iteration.

To circumvent this ambiguity we probably need to implement sampletype function, where we can fallback:

sampletype(::Type{ T }) where {T} = eltype(T)
@bvdmitri
Copy link
Member Author

bvdmitri commented Feb 7, 2023

Fixed in #229

@bvdmitri bvdmitri closed this as completed Feb 7, 2023
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

4 participants