JuliaMath / NaNMath.jl

Julia math built-ins which return NaN and accumulator functions which ignore NaN
Other
52 stars 26 forks source link

Dispatch non Float-arrays to Base methods #21

Closed mkborregaard closed 7 years ago

mlubin commented 7 years ago

This seems potentially misleading. What if someone calls NaNMath.sum() on a non-AbstractArray collection that has NaN in it? I'd rather throw a missing method error than give an unexpected answer.

mkborregaard commented 7 years ago

I agree with that philosophy - I'd convinced myself that only a subtype of AbstractArray{<:AbstractFloat} could possibly contain NaNs, and thus it was safe. Can you give an example? (presently 1am so off to bed)

mlubin commented 7 years ago
julia> isa((1.0,2.0,NaN),AbstractArray{<:AbstractFloat})
false

julia> sum((1.0,2.0,NaN))
NaN
mkborregaard commented 7 years ago

Hah, I didn't realize those functions worked on Tuples too. Then I agree this is too dangerous. Sorry for the bad PR! I'll deal with it downstream. I am now officially happy with this, so a release would be great :-)