Skip to content

argmin/argmax not defined for Tuples and maybe others #621

@anowacki

Description

@anowacki

Although argmin/argmax on v0.7+ are defined on anything you can iterate (via findmin/findmax), that's not the case within Compat at the moment. Currently, they are defined for:

  1. AbstractArray
  2. AbstractVector
  3. Associative

Therefore, you can't currently write compatible code if you want to use Tuples:

julia> VERSION
v"0.6.3"

julia> using Compat

julia> argmin((1, 2, 3.0))
ERROR: MethodError: no method matching argmin(::Tuple{Int64,Int64,Int64})
Closest candidates are:
  argmin(::AbstractArray{T,1} where T) at /Users/nowacki/.julia/v0.6/Compat/src/Compat.jl:1401
  argmin(::AbstractArray) at /Users/nowacki/.julia/v0.6/Compat/src/Compat.jl:1400
  argmin(::Associative) at /Users/nowacki/.julia/v0.6/Compat/src/Compat.jl:1402

Works fine with indmin/indmax, of course:

julia> indmin((1, 2, 3.0))
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions