Skip to content

Support for different kinds of missing values in Julia

License

Notifications You must be signed in to change notification settings

nalimilan/TypedMissings.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypedMissings.jl

CI codecov

Support for different kinds of missing values in Julia

Note : This package is currently experimental. It relies on overwriting some fundamental Julia Base methods until they are changed to use ismissing(x) instead of hardcoding x === missing.

TypedMissings.jl provides the TypedMissing type which is similar to Missing but allows representing multiple kinds of missing values. Values of type TypedMissing behave identically to missing, except that isequal(TypedMissing(kind), missing) is true if and only if kind == MissingKinds.NI. The default kind is MissingKinds.NI ("No information"), which is equivalent to missing.

TypedMissing values propagate their kind across operations which involve only missing values of the same kind or non-missing values. Operations mixing TypedMissing values of different kinds fall back to the MissingKinds.NI kind.

If provided, kind must be an instance of the MissingKind enum. Supported kinds are NI, lowercase letters from a to z, and "null flavour" values defined by FHIR HL7 v3/ISO 21090:

  • NI: No information
  • INV: Invalid
  • OTH: Other
  • NINF: Negative infinity
  • PINF: Positive infinity
  • UNC: Unencoded
  • DER: Derived
  • UNK: Unknown
  • ASKU: Asked but unknown
  • NAV: Temporarily not available
  • NAVU: Not available
  • QS: Sufficient quantity
  • NASK: Not asked
  • TRC: Trace
  • MSK: Masked
  • NA: Not applicable

Examples

julia> TypedMissing()
TypedMissing()

julia> TypedMissing(MissingKinds.NI)
TypedMissing()

julia> TypedMissing() + 1
TypedMissing()

julia> TypedMissing(MissingKinds.a) + 1
TypedMissing(MissingKinds.a)

julia> TypedMissing(MissingKinds.NASK) + 1
TypedMissing(MissingKinds.NASK)

julia> TypedMissing(MissingKinds.NASK) + TypedMissing(MissingKinds.INV)
TypedMissing()

julia> TypedMissing(MissingKinds.NASK) + missing
TypedMissing()

julia> TypedMissing(MissingKinds.NASK) + 1
TypedMissing(MissingKinds.NASK)

julia> isequal(TypedMissing(MissingKinds.NASK), TypedMissing(MissingKinds.NASK))
true

julia> isequal(TypedMissing(MissingKinds.NASK), TypedMissing(MissingKinds.INV))
false

julia> isequal(TypedMissing(MissingKinds.NASK), missing)
false

julia> isequal(TypedMissing(MissingKinds.NI), missing)
true

About

Support for different kinds of missing values in Julia

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages