Skip to content

Commit 85ed34c

Browse files
nalimilanvtjnashLilithHafner
authored
Document the kind of indices returned by findmin/findmax/argmin/argmax (#46705)
This is the sentence used for `find*` functions, introduced by #25577. Also change "the domain of `f`" to "`domain`" as the domain of `f` can be a superset of the passed `domain`. (Spotted at JuliaData/DataFrames.jl#3139.) --------- Co-authored-by: Jameson Nash <[email protected]> Co-authored-by: Lilith Orion Hafner <[email protected]>
1 parent 96147bb commit 85ed34c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

base/reduce.jl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,12 @@ end
877877
"""
878878
findmax(f, domain) -> (f(x), index)
879879
880-
Return a pair of a value in the codomain (outputs of `f`) and the index of
880+
Return a pair of a value in the codomain (outputs of `f`) and the index or key of
881881
the corresponding value in the `domain` (inputs to `f`) such that `f(x)` is maximised.
882882
If there are multiple maximal points, then the first one will be returned.
883883
884-
`domain` must be a non-empty iterable.
884+
`domain` must be a non-empty iterable supporting [`keys`](@ref). Indices
885+
are of the same type as those returned by [`keys(domain)`](@ref).
885886
886887
Values are compared with `isless`.
887888
@@ -915,6 +916,9 @@ Return the maximal element of the collection `itr` and its index or key.
915916
If there are multiple maximal elements, then the first one will be returned.
916917
Values are compared with `isless`.
917918
919+
Indices are of the same type as those returned by [`keys(itr)`](@ref)
920+
and [`pairs(itr)`](@ref).
921+
918922
See also: [`findmin`](@ref), [`argmax`](@ref), [`maximum`](@ref).
919923
920924
# Examples
@@ -936,12 +940,15 @@ _findmax(a, ::Colon) = findmax(identity, a)
936940
"""
937941
findmin(f, domain) -> (f(x), index)
938942
939-
Return a pair of a value in the codomain (outputs of `f`) and the index of
943+
Return a pair of a value in the codomain (outputs of `f`) and the index or key of
940944
the corresponding value in the `domain` (inputs to `f`) such that `f(x)` is minimised.
941945
If there are multiple minimal points, then the first one will be returned.
942946
943947
`domain` must be a non-empty iterable.
944948
949+
Indices are of the same type as those returned by [`keys(domain)`](@ref)
950+
and [`pairs(domain)`](@ref).
951+
945952
`NaN` is treated as less than all other values except `missing`.
946953
947954
!!! compat "Julia 1.7"
@@ -975,6 +982,9 @@ Return the minimal element of the collection `itr` and its index or key.
975982
If there are multiple minimal elements, then the first one will be returned.
976983
`NaN` is treated as less than all other values except `missing`.
977984
985+
Indices are of the same type as those returned by [`keys(itr)`](@ref)
986+
and [`pairs(itr)`](@ref).
987+
978988
See also: [`findmax`](@ref), [`argmin`](@ref), [`minimum`](@ref).
979989
980990
# Examples
@@ -1027,6 +1037,9 @@ If there are multiple maximal elements, then the first one will be returned.
10271037
10281038
The collection must not be empty.
10291039
1040+
Indices are of the same type as those returned by [`keys(itr)`](@ref)
1041+
and [`pairs(itr)`](@ref).
1042+
10301043
Values are compared with `isless`.
10311044
10321045
See also: [`argmin`](@ref), [`findmax`](@ref).
@@ -1082,6 +1095,9 @@ If there are multiple minimal elements, then the first one will be returned.
10821095
10831096
The collection must not be empty.
10841097
1098+
Indices are of the same type as those returned by [`keys(itr)`](@ref)
1099+
and [`pairs(itr)`](@ref).
1100+
10851101
`NaN` is treated as less than all other values except `missing`.
10861102
10871103
See also: [`argmax`](@ref), [`findmin`](@ref).

0 commit comments

Comments
 (0)