-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Hello,
I was recently surprised to find that when sorting a column I read from a CSV ...the numbers changed?
Using Julia 1.11 and the latest releases of SentinelArrays, CSV, and DataFrames, I executed:
CSV.read("my.csv", DataFrame).column |> unique! |> sortThis produced some really surprising values, and turned up some incredibly buggy behavior:
julia> cv = ChainedVector([rand(1:100, 20) for _ in 1:10])
[...]
julia> unique!(cv)
[...]
julia> sum(cv)
5073
julia> sum(sort(cv))
2236548265497175If I keep on running sum(sort(cv)) the result bounces around a bit, it seems like there's something stochastic happening?
julia> sum(sort(cv))
4399
julia> sum(sort(cv))
4378
julia> sum(sort(cv))
4400This can also produce an error instead of an incorrect result sometimes.
julia> sum(cv)
4414
julia> sum(sort(cv))
ERROR: ArgumentError: out of range arguments to copyto! on ChainedVector
Stacktrace:
[1] copyto!(dest::ChainedVector{…}, doffs::Int64, src::ChainedVector{…}, soffs::Int64, n::Int64)
@ SentinelArrays ~/.julia/packages/SentinelArrays/ob2QK/src/chainedvector.jl:475
[2] copyto!
@ ~/.julia/packages/SentinelArrays/ob2QK/src/chainedvector.jl:465 [inlined]
[3] copymutable
@ ./abstractarray.jl:1192 [inlined]
[4] sort(v::ChainedVector{Int64, Vector{Int64}})
@ Base.Sort ./sort.jl:1720
[5] top-level scope
@ REPL[39]:1
Some type information was truncated. Use `show(err)` to see complete types.Metadata
Metadata
Assignees
Labels
No labels