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

KeyedDistribution allows mismatch between the keys and the underlying distribution keys #41

Open
mzgubic opened this issue Nov 3, 2022 · 2 comments · May be fixed by #46
Open

KeyedDistribution allows mismatch between the keys and the underlying distribution keys #41

mzgubic opened this issue Nov 3, 2022 · 2 comments · May be fixed by #46

Comments

@mzgubic
Copy link
Collaborator

mzgubic commented Nov 3, 2022

julia> ka = KeyedArray(rand(3), down=["a", "b", "c"]);

julia> mvn = MvNormal(ka, [1, 1, 1]);

julia> mean(mvn)
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   down  3-element Vector{String}
And data, 3-element Vector{Float64}:
 ("a")  0.8185032515167808
 ("b")  0.2940895403871865
 ("c")  0.7714754947104043

julia> kd = KeyedDistribution(mvn, [1, 2, 3]);

julia> mean(kd)
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   _  3-element Vector{Int64}
And data, 3-element Vector{Float64}:
 (1)  0.8185032515167808
 (2)  0.2940895403871865
 (3)  0.7714754947104043

Should this be allowed? It bit me recently where I've accidentally constructed the KeyedDistribution without naming the dimension. Maybe we want to check this when constructing the KeyedDistribution?

(Similar thing for var)

Similar to #17

@mjp98
Copy link
Member

mjp98 commented Nov 3, 2022

I think it would be sensible to enforce consistency

@mjp98
Copy link
Member

mjp98 commented Nov 7, 2022

This would likely need to be done explicitly for each distribution in order to find any/all underlying keyed arrays - the check could only guarantee consistency for supported distributions?

@mzgubic mzgubic linked a pull request Nov 8, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants