-
Notifications
You must be signed in to change notification settings - Fork 14
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
Indexing by name when multiple dimensions have same name #52
Comments
The more I think about this, the more I like it, and think we should document it. Although I'm still not sure I would want to actually use this behaviour for anything serious... it's a bit magic. |
Having the same name twice seems fairly natural for The other place this seems likely to occur is an outer product, like so:
Indexing that down the diagonal seems wrong to me. One idea might be to forbid the creation of such objects, and insist that (Presumably creation by hand like |
this is an error becuase you cannot index a
It is definitely an aim of this package to support duplicate names. If that's not written down publicly yet, then it should be (either in the readme or when we add docs #30) :) e.g. we want behaviour like julia> using Statistics, NamedDims
julia> nda = NamedDimsArray(rand(4, 2), (:x, :y));
julia> Σ = cov(nda)
2×2 NamedDimsArray{(:y, :y),Float64,2,Array{Float64,2}}:
0.0258206 -0.00923985
-0.00923985 0.0569803 The only question is whether we should officially support |
OK. Then I would vote that (Perhaps things like |
We currently consider this undefined behaviour -- and i wonder if that's an unfortunate middle ground.
In practice (using v0.2) we have consistent and reasonable behaviour: when there are duplciate names. indexing by name indexes both dimenstions
I wonder if we should commit to supporting this (and document it)?
Alternatively, we could go the other direction - perhaps we think this could become a source of subtle bugs for users - and error upon "ambiguous" indexing, i.e. with
naems(nda) == (:a, :b, :b)
, shouldnda[a=2, b=3]
throw an informative error?The text was updated successfully, but these errors were encountered: