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

vcat/hcat/cat bug at edge case with one KeyedArray #114

Closed
mzgubic opened this issue Jun 27, 2022 · 2 comments · Fixed by #115
Closed

vcat/hcat/cat bug at edge case with one KeyedArray #114

mzgubic opened this issue Jun 27, 2022 · 2 comments · Fixed by #115
Labels
bug Something isn't working

Comments

@mzgubic
Copy link
Contributor

mzgubic commented Jun 27, 2022

julia> ka = wrapdims(rand(3), obs=1:3)
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   obs  3-element UnitRange{Int64}
And data, 3-element Vector{Float64}:
 (1)  0.16740473902785014
 (2)  0.17521465963627714
 (3)  0.05600551386851893

julia> vcat(ka, ka) # all good
1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   obs  6-element Vector{Int64}
And data, 6-element Vector{Float64}:
 (1)  0.16740473902785014
 (2)  0.17521465963627714
 (3)  0.05600551386851893
 (1)  0.16740473902785014
 (2)  0.17521465963627714
 (3)  0.05600551386851893

julia> vcat(ka) # turns into a NamedDimsArray
3-element NamedDimsArray(::Vector{Float64}, :obs):
 obs  0.16740473902785014
       0.17521465963627714
       0.05600551386851893

julia> hcat(ka) # turns into a Matrix
3×1 Matrix{Float64}:
 0.16740473902785014
 0.17521465963627714
 0.05600551386851893

julia> cat(ka; dims=1) # turns into a Vector
3-element Vector{Float64}:
 0.16740473902785014
 0.17521465963627714
 0.05600551386851893
@mcabbott mcabbott added the bug Something isn't working label Jun 27, 2022
@mcabbott
Copy link
Owner

That's an oversight, these loops

for (T, S) in [(:KeyedVecOrMat, :KeyedVecOrMat), # KeyedArray gives ambiguities
(:KeyedVecOrMat, :AbstractVecOrMat), (:AbstractVecOrMat, :KeyedVecOrMat),
(:NdaKaVoM, :NdaKaVoM),
(:NdaKaVoM, :KeyedVecOrMat), (:KeyedVecOrMat, :NdaKaVoM),
(:NdaKaVoM, :AbstractVecOrMat), (:AbstractVecOrMat, :NdaKaVoM),
]
@eval function Base.vcat(A::$T, B::$S, Cs::AbstractVecOrMat...)
and the similar ones for cat don't include the one-argument case.

@mzgubic
Copy link
Contributor Author

mzgubic commented Jun 27, 2022

I can make a PR this week if you'd like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants