Julia: eps(::Missing)

Created on 3 Jun 2019  ·  7Comments  ·  Source: JuliaLang/julia

many times in generic code i use stuff like: x > eps(x), if for some reason x happens to be a missing value, then i get a nasty error unless i define:

Base.eps(::Missing) = missing

is this a good idea? if so it could be default behavior in Base.

edit:

Pull Request: https://github.com/JuliaLang/julia/pull/32235

missing data

Most helpful comment

Also don't forget

lift(f) = x -> ismissing(x) ? missing : f(x)

All 7 comments

so x>Missing is always true?

x > missing is missing. So if that's used in a boolean context, it doesn't help.

I just think it makes sense to throw an error here, maybe just clean the data or check x===Missing

I think it still makes sense to add the method, since missing already propagates through many unary/binary functions of floats.

@JeffBezanson : my use case ofcourse is unimportant and irrelevant in the decision, but i needed to apply almost exactly that inequality by broadcasting on an array and i expected to get a Array{Union{Missing, Bool},1} but the method eps(::Missing) was missing :smiley:

@Moelf : data cannot always be simply cleaned, for example in a dataframe where a row has only partially missing information, to clean the data i should discard the whole row or coerce the missing to something else.

data cannot always be simply cleaned, for example in a dataframe where a row has only partially missing information, to clean the data i should discard the whole row or coerce the missing to something else.

You just apply the function to the non missing elements.

Also don't forget

lift(f) = x -> ismissing(x) ? missing : f(x)

Closing based on discussion in https://github.com/JuliaLang/julia/pull/32235.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m-j-w picture m-j-w  ·  3Comments

Keno picture Keno  ·  3Comments

dpsanders picture dpsanders  ·  3Comments

StefanKarpinski picture StefanKarpinski  ·  3Comments

StefanKarpinski picture StefanKarpinski  ·  3Comments