SparseArrays.jl
SparseArrays.jl copied to clipboard
Broadcasting type constructor over sparse array results in Any sparse array
julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
julia> using SparseArrays
julia> Float64.(sprand(4,5,0.4) .> 0.5)
4×5 SparseMatrixCSC{Any,Int64} with 4 stored entries:
[1, 1] = 1.0
[4, 3] = 1.0
[2, 5] = 1.0
[4, 5] = 1.0
I was expecting SparseMatrixCSC{Float64,Int64} obviously. Same thing happens in the Linux version too.
I think it has to do with the fusing of dot operations, since separating the two works:
julia> x = sprand(4,5,0.4) .> 0.5;
julia> Float64.(x)
4×5 SparseMatrixCSC{Float64,Int64} with 4 stored entries:
[1, 2] = 1.0
[2, 3] = 1.0
[2, 4] = 1.0
[3, 5] = 1.0
Basically duplicate of JuliaLang/julia#19595, I guess.
Yes, but this is a simpler case and could/should be handled directly and separately. It's likely that we're stashing the function into a tuple somewhere and just need a ::Type{T} specialization. Sparse broadcast is quite the ball of knots, but I think this should be an easier lift than the big JuliaLang/julia#19595 rewrite.