Skip to content

sort!(::SparseMatrixCSC; dims) produces incorrect results #305

@LilithHafner

Description

@LilithHafner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions