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

Can sparse cat apply only to numbers? #71

Open
mcabbott opened this issue Oct 14, 2021 · 2 comments
Open

Can sparse cat apply only to numbers? #71

mcabbott opened this issue Oct 14, 2021 · 2 comments

Comments

@mcabbott
Copy link

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.

@ViralBShah ViralBShah transferred this issue from JuliaLang/julia Jan 17, 2022
@vtjnash vtjnash closed this as completed Dec 13, 2023
@vtjnash
Copy link
Contributor

vtjnash commented Dec 13, 2023

I believe this is done now

@vtjnash vtjnash reopened this Dec 13, 2023
@vtjnash
Copy link
Contributor

vtjnash commented Dec 13, 2023

Actually, no, I tested and it is fixed for _SparseConcatGroup but not _SparseVecConcatGroup

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