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

argmax returns incorrect results #97

Closed
yurivish opened this issue Apr 6, 2024 · 3 comments · Fixed by #98
Closed

argmax returns incorrect results #97

yurivish opened this issue Apr 6, 2024 · 3 comments · Fixed by #98

Comments

@yurivish
Copy link

yurivish commented Apr 6, 2024

This package incorrectly implements argmax for ChainedVectors. It returns the maximum value, rather than its index.

julia> using SentinelArrays

julia> arrays = [
         [18, 70, 92, 15, 65],
         [25, 14, 95, 54, 57]
       ];

julia> cv = ChainedVector(arrays);

julia> argmax(cv)
95

julia> argmax(collect(cv))
8

The implementation is here and is tested, though the test only tests a simple special case for which the values and indices are exactly equal.

This issue was initially reported upstream.

@Moelf
Copy link

Moelf commented May 10, 2024

huh....

julia> using SentinelArrays
Precompiling SentinelArrays
  1 dependency successfully precompiled in 2 seconds

julia> x2 = ChainedVector([[2,1,3], [4,5,6], [7,8,10,9]])
10-element ChainedVector{Int64, Vector{Int64}}:
  2
  1
  3
  4
  5
  6
  7
  8
 10
  9

julia> findmin(x2)
(1, 1)

julia> findmin(x2 |> collect)
(1, 2)

is this just completely wrong? even the findmin seems to be wrong.

@quinnj
Copy link
Member

quinnj commented May 10, 2024

PRs welcome!

@Moelf
Copy link

Moelf commented May 10, 2024

I will try tmr but this is a pretty critical problem that also runs somewhat deep, you sure you trust first timer PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants