Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the kind of indices returned by findmin/findmax/argmin/argmax #46705

Merged
merged 3 commits into from
Oct 31, 2023

Conversation

nalimilan
Copy link
Member

@nalimilan nalimilan commented Sep 11, 2022

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.)

…/`argmax`

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`.
@nalimilan nalimilan added docs This change adds or pertains to documentation search & find The find* family of functions labels Sep 11, 2022
base/reduce.jl Outdated
@@ -870,12 +870,15 @@ end
"""
findmax(f, domain) -> (f(x), index)

Returns a pair of a value in the codomain (outputs of `f`) and the index of
Returns a pair of a value in the codomain (outputs of `f`) and the index or key of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the index vs key difference explained or at least mentioned anywhere in the docs? I've always seen them used interchangeably in julia and package docs.
Is there any difference at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indicies are a special case of keys. For Arrays they are the same, but Dicts have keys but not indices. If we just mentioned keys here, that would be correct but obtuse because folks shouldn't need to know that Arrays as have keys to understand findmax(::Function, ::Array).

I'm not sure if the difference is explicitly mentioned or explained elsewhere, but I don't think this PR is the place for it.

Copy link
Contributor

@aplavin aplavin Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Arrays they are the same, but Dicts have keys but not indices.

Interesting, I've always thought they are synonyms! Why getindex and not getkey then?
UPD: getkey exists but does a very different operation.

(of course not for this PR specifically, but in general)

Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Oct 30, 2023
@giordano giordano merged commit 85ed34c into master Oct 31, 2023
@giordano giordano deleted the nl/find branch October 31, 2023 00:14
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation search & find The find* family of functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants