Skip to content

Is it possible to convert a regular vector to a ComponentArray with the specified structure? #159

Answered by ForceBru
ForceBru asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like this is done by ComponentArrays.Axis:

https://github.com/jonniedie/ComponentArrays.jl/blob/f3a1b6d9e6d1549f7513579632d66597067eb93b/src/axis.jl#L20-L27


Yep, this seems to work and even has similar interface to what I envisioned:

julia> example = ComponentArray(a=1, b=5, c=[600,1000])
ComponentVector{Int64}(a = 1, b = 5, c = [600, 1000])

julia> ax, = getaxes(example)
(Axis(a = 1, b = 2, c = 3:4),)

julia> ComponentArray([2,3,9,8], ax)
ComponentVector{Int64}(a = 2, b = 3, c = [9, 8])

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ForceBru
Comment options

@NilsWildt
Comment options

Answer selected by ForceBru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants