jonniedie / ComponentArrays.jl

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

FR: Preserve CA-ness when indexing component matrix with shaped components #257

Open marius311 opened 3 months ago

marius311 commented 3 months ago

Would it be possible to make this not fall back to Array so you could more easily work with the result when slicing a subset of blocks?:

julia> c = ComponentVector(x=rand(2,2), y=rand(3), z=4);

julia> m = c * c';

julia> m[:x]
2×2×2×2 Array{Float64, 4}:
[:, :, 1, 1] = ...

Specifically I'm also interested in slicing multiple sub-blocks like m[[:x,:y]], although I'm imagining making the thing above work would be the first step. Thanks.

jonniedie commented 2 months ago

I don't think it's falling back. It's just that the m[:x, :x] block is a plain array. Just like c.x is a plain array. Or maybe I'm missing what you're saying?