SciML / SciML/ComponentArrays.jl
hcat: type unstable based on the number of arguments
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 375
- Forks
- 42
- Avg merge
- 7h 25m
- Merged PRs (30d)
- 17
Description
Hi, thanks for the very useful package!
I noticed that when doing hcat, I get varying output type based on the number of arguments. That is hcat(v, v) (where v is a ComponentVector) gives a ComponentMatrix, while hcat(v, v, v) gives a Matrix.
I think adding a method like below could resolve this:
function Base.hcat(vectors::ComponentVector{T,A,Tuple{Ax}}...) where {T,A,Ax}
return ComponentMatrix(hcat((getdata(v) for v in vectors)...), Ax(), FlatAxis())
end
happy to open a PR if you think that would work.
Minimal Example:
using ComponentArrays
c = ComponentVector(a=1)
display(hcat(c, c))
display(hcat(c, c, c))
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 with the minimal Julia example in the issue and inspect the existing hcat behavior for ComponentVector, including the proposed getdata-based approach. Compare the results for two and three arguments, then verify that both preserve the component-aware output type and remain consistent with the package's existing array behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100