-
Notifications
You must be signed in to change notification settings - Fork 51
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
Wrong result for sum of SparseVector with UInt indices #285
Comments
That seems fixed on nightly/v1.9: julia> using SparseArrays
julia> x = SparseVector{Int, UInt8}(6, UInt8[1], [-1])
6-element SparseVector{Int64, UInt8} with 1 stored entry:
[1] = -1
julia> sum(x)
-1
julia> versioninfo()
Julia Version 1.9.0-DEV.1680
Commit 822c9cf2d2* (2022-10-28 08:45 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin21.6.0)
CPU: 4 × Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
Threads: 1 on 4 virtual cores
julia> x = SparseVector{Int, UInt8}(6, UInt8[1], [-1]); sum(x)
-1
julia> x = SparseVector{Int, UInt8}(1, UInt8[1], [-1]); sum(x)
-1 There has been some rework of sparse reductions, in particular #63 (may have) fixed it. The only question is whether we should backport that fix to v1.8. |
I consider this a serious bug: julia> x = SparseVector{Int, UInt8}(6, UInt8[1], [-1]); sum(x) == -1
false so a backport would be nice; however if this is too much intertwined what would be a sensible workaround I could apply to in package? (pirating is not sensible ;) btw. this mentod (removed in #63) gives correct results: |
On the other hand:
This is because on julia-1.6.7
size(x)
is aTuple{Int64}
but on julia-1.8.2 it'sTuple{UInt8}
.as a bonus now sum is type unstable:
I understand that preserving the type of indices is useful for a very long sp vectors as per
#262
so I don't have a good solution for this one.
The text was updated successfully, but these errors were encountered: