Open fredcallaway opened 4 years ago
This seems like a bug to me, since it has an explicit atvalue
. Compare:
julia> z = AxisArray(rand(3), sy=[:a, :b, :c]);
julia> z[atvalue(:b)] # explicit
0.5205382494635875
julia> z[:b] # this can guess based on type
0.5205382494635875
julia> y = AxisArray(rand(3), bar=[10,20,30]);
julia> y[atvalue(20)] # explicit
0.6526959443703837
julia> y[20] # interpreted as an index
ERROR: BoundsError: attempt to access 3-element Array{Float64,1} at index [20]
Rewrites without the bug:
julia> using DimensionalData
julia> d = DimensionalArray(rand(3), Dim{:foo}([1//2, 1//3, 1//4]));
julia> d[Dim{:foo} <| At(1//3)]
0.8922925051403834
julia> using AxisKeys
julia> k = KeyedArray(rand(3), foo=[1//2, 1//3, 1//4]);
julia> k[foo = Key(1//3)]
0.8963527992711511
julia> k(foo = 1//3)
0.8963527992711511
@mcabbott Ah the growing pains of a new language... AxisKeys looks great, will give that a shot.
Example:
Seems to me that this should work the same way it does for symbols.