Open jd-lara opened 3 years ago
it seems it shouldn't
Why should this be disallowed? If e.g. hcat
is going to work, then it will inevitably sometimes produce duplicates. Lookup works by findfirst
I think:
julia> t = AxisArray(rand(Int8, 3, 4), ['a', 'a', 'b'], 0:3)
2-dimensional AxisArray{Int8,2,...} with axes:
:row, ['a', 'a', 'b']
:col, 0:3
And data, a 3×4 Matrix{Int8}:
60 -4 -80 -17
-92 -8 -42 93
19 -41 -106 -72
julia> t['a',4]
-17
it seems it shouldn't
Why should this be disallowed? If e.g.
hcat
is going to work, then it will inevitably sometimes produce duplicates. Lookup works byfindfirst
I think:julia> t = AxisArray(rand(Int8, 3, 4), ['a', 'a', 'b'], 0:3) 2-dimensional AxisArray{Int8,2,...} with axes: :row, ['a', 'a', 'b'] :col, 0:3 And data, a 3×4 Matrix{Int8}: 60 -4 -80 -17 -92 -8 -42 93 19 -41 -106 -72 julia> t['a',4] -17
I think that's the problem -- AxisArrays allows you to look up keys that aren't unique, which (I assume) very often indicates a bug, rather than being the user's actual intention.
which (I assume) very often
But just asserting this doesn't answer the question. Why shouldn't the labels attached to axes be categories or dates or some other information, which may have duplicates?
If you want to ensure they are unique, you can call unique
. But if that were built in, then it would be hard to avoid.
It seems that AxisArrays doesn't check that the names in an axis are unique. The MWE currently works and it seems it shouldn't
MWE