JuliaArrays / JuliaArrays/StructArrays.jl
Add `splice!` for StructArrays?
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 402
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
At a first glance, this seems to work. But maybe there are other corner cases or more performant versions...
using StructArrays
function Base.splice!(s::StructVector{T}, index::Integer, vals=T[]) where T
valsT = StructVector(vals)
t = map((v, val) -> splice!(v, index, val), StructArrays.components(s), StructArrays.components(valsT))
return StructArrays.createinstance(T, t...)
end
function Base.splice!(s::StructVector{T}, indexes, vals=T[]) where T
valsT = StructVector(vals)
t = map((v, val) -> splice!(v, indexes, val), StructArrays.components(s), StructArrays.components(valsT))
return StructVector{T}(t)
end
a = [(1,'a'),(2,'b'),(3,'c')] |> StructVector
new = (0,'x')
splice!(a, 1, [new]) == (1, 'a')
splice!(a, 1:0, [new,new]) |> isempty
splice!(a, 4:5) == [(2,'b'),(3,'c')]
a == [(0,'x'),(0,'x'),(0,'x')]
Contributor guide
No contributing guide indexed for this repository
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
The issue names no files or tests; start by reviewing StructVector, StructArrays.components, StructArrays.createinstance, and Base.splice! behavior for scalar and range indexes. Done means the shown examples pass and relevant corner cases are covered without changing expected splice! return values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100