SciML / SciML/ComponentArrays.jl
Construct ComponentArray from containers for keys and values
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 375
- Forks
- 42
- Avg merge
- 7h 25m
- Merged PRs (30d)
- 17
Description
Hi,
My apologies if the following functionality already exists. In some cases, it might be convenient to construct a ComponentArray with a collection of keys and a collection of values. With this approach, you do not have to hard code the values into the constructor. NamedTuples provides this functionality:
using ComponentArrays
k = (:a,:b)
v = [1,2]
NamedTuple{k}(v)
(a = 1, b = 2)
Perhaps one annoyance is that the keys must be in a tuple. Using similar syntax, the returned object is a Vector{Int}
ComponentArray{k}(v)
An alternative syntax could be:
ComponentArray(k, v)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by checking the existing ComponentArray constructors and the NamedTuple behavior shown in the issue. Determine whether a keys-and-values constructor is supported or needs API design, then verify that the chosen form constructs the expected ComponentArray with the supplied keys and values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100