-
-
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
max and min of NaN return NaN #12563
Conversation
💯 |
Hitting the |
50515b4
to
0129abb
Compare
I had no idea this was not already the case. Glad it is becoming so. Also glad Small note: |
If this is merged, is there a function nanmax and nanmin that ignores nan values (like http://docs.scipy.org/doc/numpy/reference/generated/numpy.nanmax.html )? I would need this to ignore invalid or missing values in measurement data. |
Yes, this surprised me very much also that it wasn't already always promoting the NaN. 💯 |
@ufechner7, can't you just filter out NaNs first? |
@ufechner, wouldn't you also need |
Well, numpy defines the following functions, that ignore nan's: |
|
There's already a registered https://github.com/mlubin/NaNMath.jl but that kind of serves an alternate purpose (returning |
MissingNaN.jl? |
@stevengj Haha that's a great name! |
@iamed2, I fixed |
Using DataArrays.jl could also make sense, depending on .your use case. |
Just because I recently ran into this, is there a reason this is not merged? Seems like the discussion got off track, and then nothing happened. |
Now that it's open season for breaking changes on master, let's do this. |
afe7b8e
to
b1ecd56
Compare
Rebased. |
Excellent. Once CI passes, let's give this a day and then merge it unless there are objections. |
osx travis failure was a timeout, log backed up to https://gist.github.com/fa25ebd3a383d4bb64025e34b95d5328 and restarted |
@nanosoldier |
I don't think BaseBenchmarks.jl has much coverage of this, e.g. there is no benchmark of just |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
Lacking objections, I'm merging this :) |
As an experiment, this patch changes
max
andmin
(and related functions) to propagateNaN
values, as discussed in #7866. (I'm not sure whether #7866 was resolved in favor of this or not, but I thought I would see what it looked like.)While I agree with Kahan that, in principle, it makes some sense for
max(NaN,Inf)
to returnInf
, I agree with @danluu that it's not worth adding an extra branch to an inner-loop function like this for a "corner case of a corner case" in which the correct behavior is ambiguous.As a side-effect, this fixes #12552, although #12564 fixes that anyway.