You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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) inenumerate(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
The text was updated successfully, but these errors were encountered:
As long as LabelledArrays doesn't permit the labels to be real values, I think that could be doable. Just create the necessary getindex methods in parallel to the existing ones.
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?The text was updated successfully, but these errors were encountered: