SciML / SciML/ComponentArrays.jl
Should the underlying Arraytype be preserved during KeepIndex subsetting?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 375
- Forks
- 42
- Avg merge
- 7h 25m
- Merged PRs (30d)
- 17
Description
Currently, KeepIndex subsetting on a ComponentVector based on LabelledVector or OffsetArray returns a ComponenVector based on plain Vector.
using OffsetArrays, LabelledArrays
oaca = ComponentArray(OffsetArray(collect(1:5), -1), Axis(a = 0, b=1:2, c=3, d=4))
oaca[KeepIndex(:b)] |> typeof # does not preserve underlying OffsetArray
na = SLVector(a1=1.1, a2=2.2, a3=3.3)
cv = ComponentVector(na, Axis(:b1,:b2,:b3))
cv[KeepIndex(:b2)] |> typeof # does not preserve underlying AbstractArray
Contrary, it does preserve the type for NamedArrays.
na = NamedArray(1:3, ([:a1,:a2,:a3],))
cv = ComponentVector(na, Axis(:b1,:b2,:b3))
c2 = cv[KeepIndex(:b2)]
@test getdata(c2)[:a2] == 2
When should the underlying AbstractArray type be preserved and when not?
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 reproducing the KeepIndex subsetting examples for OffsetArray, LabelledVector, and NamedArray, comparing the resulting ComponentVector and getdata types. Read the KeepIndex and ComponentVector subsetting paths to determine which underlying AbstractArray types are expected to survive. Done means the preservation rule is explicit and the affected examples have matching tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100