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

sortperm broken on arrays that do not support reinterpret #48079

Closed
KristofferC opened this issue Jan 2, 2023 · 1 comment · Fixed by JuliaSparse/SparseArrays.jl#296
Closed
Labels
regression Regression in behavior compared to a previous version sorting Put things in order
Milestone

Comments

@KristofferC
Copy link
Member

KristofferC commented Jan 2, 2023

julia> sortperm(sprand(10^5, 0.1))
ERROR: `reinterpret` on sparse arrays is discontinued.
Try reinterpreting the value itself instead.

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] reinterpret(#unused#::Type, A::SparseVector{Float64, Int64})
    @ SparseArrays /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/SparseArrays/src/abstractsparse.jl:79
  [3] _sort!(v::Vector{Int64}, a::Base.Sort.IEEEFloatOptimization{Base.Sort.IsUIntMappable{Base.Sort.Small{40, Base.Sort.InsertionSortAlg, Base.Sort.CheckSorted{Base.Sort.ComputeExtrema{Base.Sort.ConsiderCountingSort{Base.Sort.CountingSort, Base.Sort.ConsiderRadixSort{Base.Sort.RadixSort, Base.Sort.Small{80, Base.Sort.InsertionSortAlg, Base.Sort.QuickerSort{Missing, Missing, Base.Sort.InsertionSortAlg}}}}}}}, Base.Sort.StableCheckSorted{Base.Sort.QuickerSort{Missing, Missing, Base.Sort.InsertionSortAlg}}}}, o::Base.Order.Perm{Base.Order.ForwardOrdering, SparseVector{Float64, Int64}}, kw::NamedTuple{(:scratch, :lo, :hi), Tuple{Nothing, Int64, Int64}})
    @ Base.Sort ./sort.jl:634
  [4] _sort!
    @ ./sort.jl:714 [inlined]
  [5] _sort!
    @ ./sort.jl:659 [inlined]
  [6] _sort!
    @ ./sort.jl:595 [inlined]
  [7] #sort!#28
    @ ./sort.jl:1374 [inlined]
  [8] _sortperm(A::SparseVector{Float64, Int64}; alg::Base.Sort.MissingOptimization{Base.Sort.BoolOptimization{Base.Sort.Small{10, Base.Sort.InsertionSortAlg, Base.Sort.IEEEFloatOptimization{Base.Sort.IsUIntMappable{Base.Sort.Small{40, Base.Sort.InsertionSortAlg, Base.Sort.CheckSorted{Base.Sort.ComputeExtrema{Base.Sort.ConsiderCountingSort{Base.Sort.CountingSort, Base.Sort.ConsiderRadixSort{Base.Sort.RadixSort, Base.Sort.Small{80, Base.Sort.InsertionSortAlg, Base.Sort.QuickerSort{Missing, Missing, Base.Sort.InsertionSortAlg}}}}}}}, Base.Sort.StableCheckSorted{Base.Sort.QuickerSort{Missing, Missing, Base.Sort.InsertionSortAlg}}}}}}}, order::Base.Order.ForwardOrdering, scratch::Nothing, dims::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base.Sort ./sort.jl:1582
  [9] #sortperm#32
    @ ./sort.jl:1566 [inlined]
 [10] sortperm(A::SparseVector{Float64, Int64})
    @ Base.Sort ./sort.jl:1555
 [11] top-level scope
    @ REPL[29]:1

Found in https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/7daffee_vs_00177eb/Recommenders.primary.log.

@KristofferC KristofferC added regression Regression in behavior compared to a previous version sorting Put things in order labels Jan 2, 2023
@KristofferC KristofferC added this to the 1.9 milestone Jan 2, 2023
@LilithHafner
Copy link
Member

This example is fixed in JuliaSparse/SparseArrays.jl#296 and there is a generic AbstractArray implementation of reinterpret so this should not be an issue for other AbstractArray types. I would appreciate your thoughts on that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version sorting Put things in order
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants