-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
I would like to look up non-integer values in my IndirectArray. LabelledArrays.jl supports noninteger indexes, but IndirectArrays currently enforces ::Int
for the index type. Could IndirectArrays allow this type restriction to be loosened?
using LabelledArrays
using IndirectArrays
indexes = Symbol.(["a", "b", "b", "c", "c", "c"])
values = [10, 20, 30]
label_dict = Dict(v=>k for (k,v) in enumerate(unique(indexes)))
label_array = LVector(;label_dict...)
@assert label_array[:c] == 3
lookup = IndirectArray(label_array, values)
lookup[:c] == 30
ArgumentError: invalid index: :c of type Symbol
Stacktrace:
[1] to_index(::Symbol) at ./indices.jl:297
[2] to_index(::IndirectArray{Int64,1,LArray{Int64,1,Array{Int64,1},(:a, :b, :c)},Array{Int64,1}}, ::Symbol) at ./indices.jl:274
[3] to_indices at ./indices.jl:325 [inlined]
[4] to_indices at ./indices.jl:322 [inlined]
[5] getindex(::IndirectArray{Int64,1,LArray{Int64,1,Array{Int64,1},(:a, :b, :c)},Array{Int64,1}}, ::Symbol) at ./abstractarray.jl:1060