Skip to content

findmin does not handle NaN correctly #714

@odow

Description

@odow

x-ref https://discourse.julialang.org/t/julia-stability-vs-rust-for-scientific-computing/137094/11?u=odow

julia> findmin(sparsevec([1], [NaN], 2))
(0.0, 2)

julia> findmin([NaN, 0.0])
(NaN, 1)

Per the docstring:

 findmin(itr) -> (x, index)

  Return the minimal element of the collection itr and its index or key. If there are multiple minimal elements, then the first one will be returned. NaN is treated as less than all other values except missing.

  Indices are of the same type as those returned by keys(itr) and pairs(itr).

  See also: findmax, argmin, minimum.

  Examples
  ≡≡≡≡≡≡≡≡

  julia> findmin([8, 0.1, -9, pi])
  (-9.0, 3)
  
  julia> findmin([1, 7, 7, 6])
  (1, 1)
  
  julia> findmin([1, 7, 7, NaN])
  (NaN, 4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions