- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.7k
Open
Labels
missing dataBase.missing and related functionalityBase.missing and related functionality
Description
This works:
julia> v = [1,2,3,4]
4-element Array{Int64,1}:
 1
 2
 3
 4
julia> reinterpret(Some{Int64}, v)
4-element reinterpret(Some{Int64}, ::Array{Int64,1}):
 1
 2
 3
 4It would be very nice if this could be supported, too:
julia> v2 = [1,2,3,4,missing]
5-element Array{Union{Missing, Int64},1}:
 1       
 2       
 3       
 4       
  missing
julia> reinterpret(Union{Missing, Some{Int64}}, v)
ERROR: ArgumentError: cannot reinterpret `Int64` `Union{Missing, Some{Int64}}`, type `Union{Missing, Some{Int64}}` is not a bits type
Stacktrace:
 [1] (::getfield(Base, Symbol("#throwbits#200")))(::Type{Int64}, ::Type{Union{Missing, Some{Int64}}}, ::Type{Union{Missing, Some{Int64}}}) at ./reinterpretarray.jl:16
 [2] reinterpret(::Type{Union{Missing, Some{Int64}}}, ::Array{Int64,1}) at ./reinterpretarray.jl:33
 [3] top-level scope at none:0I've explained the use case on discourse. Briefly, when working with Unitful vectors, one often has to take out the units (eg. to make a linear regression), then tack them back on the result. Both operations could conceivably be done allocation-free with reinterpret, but are very slow on vectors that contain missings.
Metadata
Metadata
Assignees
Labels
missing dataBase.missing and related functionalityBase.missing and related functionality