Open
Description
Concatenation of a sparse and a dense array usually makes a sparse array. This fails completely when the resulting eltype cannot be used for a sparse array:
julia> hcat([1,2,3], sparse([1,0,0]))
3×2 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
1 1
2 ⋅
3 ⋅
julia> hcat(string.(1:3), sparse([1,0,0]))
ERROR: MethodError: no method matching zero(::String)
julia> invoke(hcat, Tuple{Vararg{AbstractVecOrMat}}, string.(1:3), sparse([1,0,0]))
3×2 Matrix{Any}:
"1" 1
"2" 0
"3" 0
Should the sparse methods be restricted to T<:Number
? Then I believe this would call the dense one. But perhaps Number
is too narrow, e.g. using StaticArrays; hcat(sparse([SA[1,2], SA[0,0]]))
?
Xref JuliaLang/julia#2326 for discussion of more elaborate promotion schemes.
Metadata
Metadata
Assignees
Labels
No labels