Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hcat: type unstable based on the number of arguments #168

Open
nrontsis opened this issue Oct 19, 2022 · 3 comments
Open

hcat: type unstable based on the number of arguments #168

nrontsis opened this issue Oct 19, 2022 · 3 comments

Comments

@nrontsis
Copy link
Contributor

nrontsis commented Oct 19, 2022

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))
@jonniedie
Copy link
Collaborator

Oh yeah, if you wouldn't mind, I'd appreciate that PR!

@nrontsis
Copy link
Contributor Author

#113 is also related

@nrontsis
Copy link
Contributor Author

See #169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants