Skip to content
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

Support for Missings #188

Closed
cstjean opened this issue Nov 7, 2018 · 10 comments
Closed

Support for Missings #188

cstjean opened this issue Nov 7, 2018 · 10 comments

Comments

@cstjean
Copy link
Contributor

cstjean commented Nov 7, 2018

We're transitioning to missing values in our code base, instead of NaN, and find that there are some... missing... methods, like uconvert(::Unitful.FreeUnits, ::Missing). I assume that it just hasn't been implemented yet? If so, I'll make a PR.

@ajkeller34
Copy link
Collaborator

Missing support sounds like a good idea but I haven't been following along with the latest thinking about it. What would you propose this method should do? Just return missing?

@cstjean
Copy link
Contributor Author

cstjean commented Nov 7, 2018

Yeah. We already have that 1u"m" * missing === missing, because Quantity <: Number.

@ajkeller34
Copy link
Collaborator

Sounds good, thanks!

@nicoleepp
Copy link
Contributor

Additionally methods like:

*(y::Missing, x::T) where {T<:Units} = missing
ustrip(x::Missing) = missing

would be good to have

@rafaqz
Copy link
Contributor

rafaqz commented Feb 8, 2019

Any idea of the set of methods needed for a complete Unitful missings PR?

@cstjean
Copy link
Contributor Author

cstjean commented Feb 8, 2019

I've been using

Unitful.uconvert(::Any, ::Missing) = missing
Unitful.ustrip(::Missing) = missing
Unitful.unit(::Type{Union{Missing, T}}) where T = unit(T)
Base.:*(::Missing, ::Unitful.Units) = missing
Base.:/(::Missing, ::Unitful.Units) = missing

and it works fine. It has been heavily tested. If anyone wants to PR that code, please do.

@rafaqz
Copy link
Contributor

rafaqz commented Feb 9, 2019

Also

Base.:^(::Unitful.Units, ::Missing) = missing

?

@rafaqz
Copy link
Contributor

rafaqz commented Feb 9, 2019

Should unit(x::Missing) return missing or NoUnit?

The same question also applies to absoluteunit, anddimension(::Missing) returning missing or NoDims

@cstjean
Copy link
Contributor Author

cstjean commented Feb 9, 2019

missing. Otherwise unit.([1.0m, missing, 3.3m]) would be strange.

rafaqz added a commit to rafaqz/Unitful.jl that referenced this issue Feb 9, 2019
rafaqz added a commit to rafaqz/Unitful.jl that referenced this issue Feb 9, 2019
rafaqz added a commit to rafaqz/Unitful.jl that referenced this issue Feb 9, 2019
@ajkeller34
Copy link
Collaborator

Closed by #208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants