-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add indmin
/indmax
#41339
base: master
Are you sure you want to change the base?
Add indmin
/indmax
#41339
Conversation
d5460f0
to
a2eb4b2
Compare
9785b13
to
229d14d
Compare
Why git doesn't strip trailing whitespace by default escapes me. Should be final now. |
Uh.. CI failures are not originating in the code of this PR..? 😬 |
It is related: LoadError("sysimg.jl", 19, LoadError("/usr/home/julia/worker/package_freebsd64/build/usr/share/julia/stdlib/v1.8/Dates/src/Dates.jl", 3, LoadError("/usr/home/julia/worker/package_freebsd64/build/usr/share/julia/stdlib/v1.8/Dates/src/io.jl", 448, MethodError(argmin, ((1,),), 0x0000000000005bc9)))) Likely because the Dates stdlib uses |
Uh - I didn't touch |
Oooh, I see what's happening! |
6b4ab5b
to
331c612
Compare
331c612
to
8846297
Compare
Ok, there we go - I really shouldn't write PRs without eating dinner.. |
For reference: #25654 |
The funny thing is (as far as I understand), So I've arrived at "let's keep both", which I haven't seen written out from other people yet 🤷♂️ |
Though it's probably best in that case if we make the distinction between |
(I am aware that there's been a lot of noise around this. Sorry...) "key" and "index" are used a bit interchangeably.
instead of keymax(itr) = findmax(itr)[2]
keymax(f, itr) = findmax(f, itr)[2] I do think when all you want is the key/index, that |
Comparison to wrong value, misplaced findmin instead of findmax
There slipped another one through - next failure will be fixed tomorrow 😭
I personally prefer |
This might have been proposed before but maybe findmax should return a named tuple? Then you could do |
That makes pipeability harder though and broadcasting nigh impossible. |
I think it's safe to say that the failure truly is unrelated now. |
You mean like |
Right - or just As for piping:
vs.
and
vs.
or
In either case, I prefer the short version. Though the _ anonymous function PR would help with |
To develop a bit, the root of the issue IMO is that |
I don't think we're necessarily trapped - I think just adding |
I don't know if Julia has a canonical abbreviation of "index" but in Pandas the name is |
I really don't think we're trapped. Merging this and deprecating single-arg
I don't mind changing this to |
I normally don't like abbreviations in APIs at all since then users have to remember which abbreviation it is. In that case |
Sure. don't really have an opinion about that. The trap I referred to is that |
Adds
indmin
andindmax
methods which return the index into a collection, minimizing/maximizing a given function (oridentity
if none is given).This came out of the discussion surrounding #39203.