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

Fix manual about propagation of missing values #35264

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions doc/src/manual/missing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ and behaves like them in most situations.

## Propagation of Missing Values

The behavior of `missing` values follows one basic rule: `missing`
values *propagate* automatically when passed to standard operators and functions,
in particular mathematical functions. Uncertainty about the value of one of the operands
induces uncertainty about the result. In practice, this means an operation involving
a `missing` value generally returns `missing`
`missing` values *propagate* automatically when passed to standard mathematical
operators and functions.
For these functions, uncertainty about the value of one of the operands
induces uncertainty about the result. In practice, this means a math operation
involving a `missing` value generally returns `missing`
```jldoctest
julia> missing + 1
missing
Expand All @@ -31,12 +31,17 @@ As `missing` is a normal Julia object, this propagation rule only works
for functions which have opted in to implement this behavior. This can be
achieved either via a specific method defined for arguments of type `Missing`,
or simply by accepting arguments of this type, and passing them to functions
which propagate them (like standard operators). Packages should consider
which propagate them (like standard math operators). Packages should consider
whether it makes sense to propagate missing values when defining new functions,
and define methods appropriately if that is the case. Passing a `missing` value
to a function for which no method accepting arguments of type `Missing` is defined
throws a [`MethodError`](@ref), just like for any other type.

Functions that do not propagate `missing` values can be made to do so by wrapping
them in the `passmissing` function provided by the
[Missings.jl](https://github.com/JuliaData/Missings.jl) package.
For example, `f(x)` becomes `passmissing(f)(x)`.

## Equality and Comparison Operators

Standard equality and comparison operators follow the propagation rule presented
Expand Down