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 not type-stable with union types #26004

Open
cstjean opened this issue Feb 12, 2018 · 2 comments
Open

hcat not type-stable with union types #26004

cstjean opened this issue Feb 12, 2018 · 2 comments
Labels
arrays [a, r, r, a, y, s]

Comments

@cstjean
Copy link
Contributor

cstjean commented Feb 12, 2018

On 0.6.2, hcat has quite interesting behaviour with Vector{Union{...}}. It's particularly problematic with Missing values (it returns Matrix{Any}).

julia> hcat([1,2], Union{Int, Float64}[2, 3])     # type-stable
2×2 Array{Union{Float64, Int64},2}:
 1  2
 2  3

julia> hcat(Union{Int, Float64}[1,2], Union{Int, Float64}[2, 3])  # not stable
2×2 Array{Int64,2}:
 1  2
 2  3

julia> hcat(Union{Float64, Int}[1,2])   # not stable either
2×1 Array{Int64,2}:
 1
 2

AFAICT, this was supposed to be fixed in #19387 . vcat seems to work fine.

@nalimilan nalimilan added the arrays [a, r, r, a, y, s] label Feb 12, 2018
@nalimilan
Copy link
Member

Confirmed on master too. Cc: @pabloferz

@nalimilan
Copy link
Member

It's particularly problematic with Missing values (it returns Matrix{Any}).

Note that this particular use case has been fixed on master (#25553):

julia> hcat([1,missing])
2×1 Array{Union{Missing, Int64},2}:
 1       
  missing

(But of course due to the problem described above hcat(Union{Int,Missing}[1,2]) creates an Array{Int}.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

No branches or pull requests

2 participants