Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with BlockArrays? #177

Open
NilsKintscher opened this issue Nov 18, 2022 · 4 comments
Open

Compatibility with BlockArrays? #177

NilsKintscher opened this issue Nov 18, 2022 · 4 comments

Comments

@NilsKintscher
Copy link

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 at
x.componentName[Block(i)]

@jonniedie
Copy link
Owner

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.

@jonniedie
Copy link
Owner

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.

@NilsKintscher
Copy link
Author

NilsKintscher commented Nov 24, 2022 via email

@jonniedie
Copy link
Owner

jonniedie commented Jan 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants