jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
287 stars 34 forks source link

Indexing over length-1 vector of symbols fails #175

Closed nrontsis closed 1 year ago

nrontsis commented 1 year ago
julia> using ComponentArrays
julia> ComponentVector(;a=1.0,b=1.0)[[:a]]

Gives:

ERROR: MethodError: no method matching ComponentArray(::Float64, ::Tuple{Axis{(a = 1,)}})
Closest candidates are:
  ComponentArray(::A, ::Axes) where {T, N, A<:AbstractArray{T, N}, Axes<:Tuple{Vararg{AbstractAxis}}} at ~/.julia/packages/ComponentArrays/YyD7i/src/componentarray.jl:35
  ComponentArray(::UndefInitializer, ::Axes) where Axes<:Tuple at ~/.julia/packages/ComponentArrays/YyD7i/src/componentarray.jl:41
  ComponentArray(::Any, ::FlatAxis...) at ~/.julia/packages/ComponentArrays/YyD7i/src/componentarray.jl:50
  ...
Stacktrace:
 [1] ComponentArray(data::Float64, ax::Axis{(a = 1,)})
   @ ComponentArrays ~/.julia/packages/ComponentArrays/YyD7i/src/componentarray.jl:51
 [2] macro expansion
   @ ~/.julia/packages/ComponentArrays/YyD7i/src/array_interface.jl:0 [inlined]
 [3] _getindex(index_fun::typeof(getindex), x::ComponentVector{Float64, Vector{Float64}, Tuple{Axis{(a = 1, b = 2)}}}, idx::Val{(:a,)})
   @ ComponentArrays ~/.julia/packages/ComponentArrays/YyD7i/src/array_interface.jl:121
 [4] getindex
   @ ~/.julia/packages/ComponentArrays/YyD7i/src/array_interface.jl:105 [inlined]
 [5] getindex(x::ComponentVector{Float64, Vector{Float64}, Tuple{Axis{(a = 1, b = 2)}}}, idx::Vector{Symbol})
   @ ComponentArrays ~/.julia/packages/ComponentArrays/YyD7i/src/array_interface.jl:104
 [6] top-level scope
   @ REPL[11]:1
nrontsis commented 1 year ago

Closed via #180