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

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

Closed
LilithHafner opened this issue Nov 28, 2022 · 0 comments · Fixed by #296
Closed

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

LilithHafner opened this issue Nov 28, 2022 · 0 comments · Fixed by #296
Labels
bug Something isn't working

Comments

@LilithHafner
Copy link
Member

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant