Skip to content

findmin(A; dims) ignores first value if index is 0 #38660

@cmcaine

Description

@cmcaine

Index can be zero if you're using OffsetArrays.jl or similar. Also
affects findmax, argmin, argmax.

If dims is omitted or : then you don't get this bug :)

Found while working on #35316 and I'll fix it there edit: I might fix it later, PR already too big.

Reproducible example:

julia> using OffsetArrays

julia> ov = OffsetVector([-1, 1], 0:1)
2-element OffsetArray(::Vector{Int64}, 0:1) with eltype Int64 with indices 0:1:
 -1
  1

julia> findmin(ov, dims=1) # Should be ([-1], [0])
([1], [1])

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingsearch & findThe find* family of functions

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions