-
-
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
RFC: Added find_extrema, ind_extrema #7327
Conversation
Should we avoid the underscores in the name? |
I commented on this above. But I can remove the underscores altogether if that's preferred. |
I somehow missed the comment. Sorry about that. I think it is ok without the underscore. @StefanKarpinski ? |
I removed the underscores, and fixed the implementation to properly ignore nans (like |
Still needs docs and tests. Shall I go ahead? |
lgtm |
Is the |
So, the current naming scheme is something like this:
The |
The names are inconsistent. |
I think the |
I'm also in favor of |
Numpy uses argmin and argmax as well. On Fri, Jun 20, 2014 at 1:50 PM, Jeff Bezanson notifications@github.com
|
I'm ok with |
@johnmyleswhite, if you twist your thinking a little, array |
I have to say that I had hard times finding |
Yeah, I understand the contortion that gets used here. And I'm ok with it. Just noting that we're actually breaking consistency with math, not syncing up with it. I think the better argument is consistency with other systems, which started this wacky tradition. |
It would be really nice if Is the (Of course, I was just getting used to |
So for right now, how about the following:
(with cross references in the documentation among at least |
As a data point, |
I've implemented and documented the changes above:
The main exception is that there is no |
I agree that the Another thing this could be confusing is that As a data point, |
Suggestions welcome! :-) It's somewhat challenging to come up with a useful, consistent set of names here. This doesn't mean we shouldn't try, of course. One challenge is that we're naming separate concepts that most other languages don't concern themselves with, so we mostly can't just borrow names. At least with the names I proposed, we have consistency within and between But I agree that these are not consistent with I'll post a fuller list in a little while, so we can get the big picture and have a more meaningful discussion. |
Okay, the list of current I've filled in similar functions in matlab, python/numpy, and have a column for R. Could someone who knows R fill in this column? Some general concepts are below. I think it would be nice to reform the
Some specific notes:
|
I think the solution to this is to only define min, max etc on iterables and get rid of minimum, maximum, etc. Thus if you want to find |
For previous discussions, I should be linking to #4235, #5257, #5275. @BobPortmann, please see those discussions for why getting rid of minimum and maximum probably wound't work. |
Of course, it would be nice if there was an operator version of min and max although I'm not sure what symbols are a good choice ( |
@kmsquire Yes, I've seen those. But if min and max only worked for iterables, those issues would go away. |
The convention of writing To me, I don't see why there is a big problem of using |
The problem is this: when |
Just FYI:
I guess it was called Regarding how |
My apologies. I was not confused by regions versus dims. I must have looked in the old version of the manual, even though I have bookmarked the latest version. On 07 Jul 2014, at 17:10, Tim Holy notifications@github.com wrote:
|
I seemed to have been confused by more than just this today. Trying to do two things at the time ... |
* For parity with findmin/indmin, findmax/indmax * indmin/indmax -> argmin, argmax
Bump.
Cheers! |
6c7c7e3
to
1a4c02f
Compare
Bump. julia>a = [1 2;0 1]
ind2sub(size(a), indmax(a))
(1,2) Could we make a method of |
I'd say not to assume that @johnmyleswhite I don't really see why |
I haven't read through this entire thread, but what do people think about matlab's semantics for max? http://www.mathworks.com/help/matlab/ref/max.html Michael |
See #4235 for a history of the design. A more recent discussion is at #9439 (comment). I (as well as most folks here, I'd imagine) see Matlab's use of |
The basic issue is that Matlab's |
It looks like Viral approved this PR already, and the dust has (mostly?) settled on the naming surrounding min/max/minimum/extrema/minmax (e.g. eliminating indmin). So this just needs a rebase. |
Based on the original conversation, should I change |
Yes, that seems consistent. |
This is a simple extension of extant `findmin` and `findmax` methods. Depending on context (cost of `f`; whether reduction is over dims; size of array) the speedup increase is somewhere between 1.0-1.6 (no regressions). Interestingly, I noticed but could not locate a `findextrema`; there is some [mention](JuliaLang#7327) of it, but nothing in Base. If it was deemed unworthy, please excuse this errant PR.
This is a simple extension of extant `findmin` and `findmax` methods. Depending on context (cost of `f`; whether reduction is over dims; size of array) the speedup increase is somewhere between 1.0-1.6 (no regressions). Interestingly, I noticed but could not locate a `findextrema`; there is some [mention](JuliaLang#7327) of it, but nothing in Base. If it was deemed unworthy, please excuse this errant PR.
This is a simple extension of extant `findmin` and `findmax` methods. Depending on context (cost of `f`; whether reduction is over dims; size of array) the speedup increase is somewhere between 1.0-1.6 (no regressions). Interestingly, I noticed but could not locate a `findextrema`; there is some [mention](JuliaLang#7327) of it, but nothing in Base. If it was deemed unworthy, please excuse this errant PR.
Just adding parity:
findmin/indmin <=> minimum
findmax/indmin <=> maximum
findextrema/indextrema <=> extrema
It's named(Names no longer contain underscores.)find_extrema
becausefindextrema
(and particularlyindextrema
) seemed less readable to me.Just checking first if this is wanted. If so, I'll add docs. If not, please close.
Edit: large bikeshedding spreadsheet here