# Inconsistent behaviour of argmax

**URL:** https://discourse.julialang.org/t/inconsistent-behaviour-of-argmax/134373
**Category:** General Usage
**Created:** [December 5, 2025, 9:57am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-argmax/134373 "2025-12-05T09:57:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jsjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jsjie/32/22477_2.png) [@jsjie](https://discourse.julialang.org/u/jsjie)
#### Post date: [December 5, 2025, 9:57am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-argmax/134373/1 "2025-12-05T09:57:38Z")

</div>

An MWE:

```julia-auto
julia> using Random

julia> a = rand(5, 5)
5×5 Matrix{Float64}:
 0.304673 0.659002 0.223237 0.189379 0.735553
 0.423152 0.844487 0.599046 0.60839 0.653539
 0.808406 0.146324 0.866515 0.717432 0.353227
 0.829093 0.0249944 0.501509 0.619801 0.542704
 0.458972 0.682252 0.762093 0.260897 0.611253

julia> argmax(a)
CartesianIndex(3, 3)

julia> argmax(x-> x<0.5 ? x : -Inf, a)
0.45897230687902646

julia> findmax(x-> x<0.5 ? x : -Inf, a)
(0.45897230687902646, CartesianIndex(5, 1))

julia> findmax(a)
(0.8665152659983258, CartesianIndex(3, 3))

```

Without predicate, `argmax` returns the index of the maximum value, but with predicate, it returns the value.  
I’ve checked Julia 1.10.2 and 1.9.4, both with this behaviour.

---

<div class="post-metadata">

### Author: ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)
#### Post date: [December 5, 2025, 10:31am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-argmax/134373/2 "2025-12-05T10:31:19Z")

</div>

> [@jsjie](#):
>
> Without predicate, `argmax` returns the index of the maximum value, but with predicate, it returns the value.

You are right: [`argmax` behaves differently from other higher-order functions · Issue #48502 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/48502)

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [December 5, 2025, 12:10pm UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-argmax/134373/3 "2025-12-05T12:10:25Z")

</div>

> [@\`findmax\` and friends: confusing behaviour to be introduced in 1.7](https://discourse.julialang.org/t/findmax-and-friends-confusing-behaviour-to-be-introduced-in-1-7/61904):
>
> Several people, including myself, have tried to raise this issue during last months. There were multiple posts on slack, and even a GH issue ([https://github.com/JuliaLang/julia/issues/39203](https://github.com/JuliaLang/julia/issues/39203)). I’ll try to raise it once more, here on discourse, hoping that it gets more traction. The findmax(A) function, which everyone is used to, returns the maximum value in the array A and its index. However, Julia 1.7 will introduce a findmax(f, A) version, that doesn’t return any index at all: julia\> A = [5, …
