Open NilsKintscher opened 1 year ago
It’s kinda tough to have components be different array types like this. In theory, you should be able to store the component’s type for reconstruction, but in practice it just doesn’t work at all because other array types don’t all follow the same interface for reconstruction via type.
But I guess I’d also have to see an example of something that would be accomplished with ComponentArrays + BlockArrays that can’t just be accomplished with ComponentArrays.
How would you handle components c1,c2,...,cN for varying N right now??
You could do something like this:
julia> N = 5
5
julia> ca = ComponentArray(NamedTuple(Symbol(:c, i) => rand(3) for i in 1:N))
ComponentVector{Float64}(c1 = [0.5482904644627941, 0.13909008040255955, 0.013857229990063002], c2 = [0.3497491172730053, 0.323080764846305, 0.5759352391226321], c3 = [0.30645828956848165, 0.49153219318714503, 0.5192535821238988], c4 = [0.557607879404576, 0.4721650175935741, 0.2839147469190002], c5 = [0.44203806768864384, 0.20414854972570728, 0.8787506621852561])
But hopefully the blocks would have better names.
It would be awesome to get some compatibility between BlockArrays and ComponentArrays. Either BlockArrays of ComponentArrays, such that I'm able to access some vector at
x[Block(i)].componentName
or/and ComponentArrays of BlockArrays, in order to access some vector atx.componentName[Block(i)]