Open
Description
When extracting a Sub-ComponentVector by indexing with a set of symbols, I sometimes encounter the case that the set of indices (computed somewhere else) is empty. For consistency, I expect the indexing to return the same type, i.e. an empty ComponentVector. But currently it returns a plain vector.
using ComponentArrays
using Test
cv = ComponentVector(k1 = 1.0, k2 = 2.0)
@test cv[(:k1, :k2)] == cv
@test cv[(:k1, )] == ComponentVector(k1 = 1.0)
@test cv[NTuple{0,Symbol}()] == ComponentVector{eltype(cv)}() # fails, should return ComponentVector
@test cv[()] == ComponentVector{eltype(cv)}() # discuss meaning
What are the arguments for returning a plain vector instead of an empty ComponentVector?
Extending the KeepIndex
to the empty tuple does not work for me, because I need a method to extract Sub-ComponentVectors that work consistently with a NTuple{N, Symbol}
for any N.
Metadata
Assignees
Labels
No labels
Activity