-
Notifications
You must be signed in to change notification settings - Fork 65
Closed
Description
Hello,
I've observed some inconsistencies between julia 1.7 and 1.8 with the SparseArrays module:
- Concatenation of sparse vectors:
julia> VERSION
v"1.7.2"
julia> using SparseArrays
julia> x = sparsevec([1], [3])
1-element SparseVector{Int64, Int64} with 1 stored entry:
[1] = 3
julia> vcat(x, zero(eltype(x)))
2-element SparseVector{Int64, Int64} with 1 stored entry: # <- a sparse vector is returned as expected
[1] = 3julia> VERSION
v"1.8.0"
julia> using SparseArrays
julia> x = sparsevec([1], [3])
1-element SparseVector{Int64, Int64} with 1 stored entry:
[1] = 3
julia> vcat(x, zero(eltype(x)))
2×1 SparseMatrixCSC{Int64, Int64} with 1 stored entry: # <- a sparse matrix CSC is returned
3
⋅- Failure to use
sumwith types not supporting integer multiplication:
julia> VERSION
v"1.7.2"
julia> using SparseArrays
julia> using Semirings
julia> K = LogSemiring{Float64} # This type cannot be multiplied with an integer
LogSemiring{Float64}
julia> sum(sparse([2], [3], K[one(K)], 10, 10))
0.0julia> VERSION
v"1.8.0"
julia> using SparseArrays
julia> using Semirings
julia> K = LogSemiring{Float64} # This type cannot be multiplied with an integer
LogSemiring{Float64}
julia> sum(sparse([2], [3], K[one(K)], 10, 10))
ERROR: promotion of types LogSemiring{Float64} and Int64 failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String)
@ Base ./error.jl:44
[2] sametype_error(input::Tuple{LogSemiring{Float64}, Int64})
@ Base ./promotion.jl:383
[3] not_sametype(x::Tuple{LogSemiring{Float64}, Int64}, y::Tuple{LogSemiring{Float64}, Int64})
@ Base ./promotion.jl:377
[4] promote
@ ./promotion.jl:360 [inlined]
[5] *(x::LogSemiring{Float64}, y::Int64)
@ Base ./promotion.jl:389
[6] _mapreducezeros
@ ~/Julia/julia-1.8.0/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:1918 [inlined]
[7] _mapreduce
@ ~/Julia/julia-1.8.0/share/julia/stdlib/v1.8/SparseArrays/src/sparsematrix.jl:1913 [inlined]
[8] _mapreduce_dim
@ ./reducedim.jl:365 [inlined]
[9] #mapreduce#764
@ ./reducedim.jl:357 [inlined]
[10] mapreduce
@ ./reducedim.jl:357 [inlined]
[11] #_sum#774
@ ./reducedim.jl:999 [inlined]
[12] _sum
@ ./reducedim.jl:999 [inlined]
[13] #_sum#773
@ ./reducedim.jl:998 [inlined]
[14] _sum
@ ./reducedim.jl:998 [inlined]
[15] #sum#771
@ ./reducedim.jl:994 [inlined]
[16] sum(a::SparseMatrixCSC{LogSemiring{Float64}, Int64})
@ Base ./reducedim.jl:994
[17] top-level scope
@ REPL[11]:1MartinKocour
Metadata
Metadata
Assignees
Labels
No labels