SparseArrays.jl
SparseArrays.jl copied to clipboard
`sort!(::SparseMatrixCSC; dims)` produces incorrect results
This is a problem on both 1.8.3 and nightly:
julia> using SparseArrays
julia> s = spzeros(30, 5); for i in eachindex(s); if rand() < .4; s[i] = 1; s[i] = rand([-1, -0.0, 0.0, 1]); end; end;
julia> sort!(s, dims=1)
30×5 SparseMatrixCSC{Float64, Int64} with 91 stored entries:
⣷⠿⡇
⢶⠏⡇
⣎⢲⠁
⢀⠳⡄
⡈⣤⡅
⡇⣾⠀
⡯⣿⠂
⠋⠛⠃
julia> Matrix(s)
30×5 Matrix{Float64}:
0.0 0.0 0.0 0.0 0.0
-1.0 0.0 -1.0 -1.0 -1.0
-1.0 -1.0 -1.0 -0.0 -1.0
-1.0 -1.0 0.0 0.0 -1.0
0.0 0.0 -1.0 -0.0 -1.0
0.0 -1.0 -1.0 0.0 -1.0
0.0 -0.0 -0.0 0.0 -0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0 0.0
1.0 0.0 1.0 1.0 0.0
1.0 0.0 1.0 1.0 0.0
1.0 0.0 1.0 1.0 1.0