-
Notifications
You must be signed in to change notification settings - Fork 19
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
Shorthand for AbstractArray conversions #60
Comments
Your 1. there is
Missings.T(U::Type{Union{S,Missing}}) where {S} =
Union{filter!(t -> !(t <: Missing), Base.uniontypes(U))...} but I don't know how practically useful that would be. |
Thanks for a prompt answer. Clear with Regarding the main issue of conversions:
|
The problem with That's why toeltype(::Type{T}, x::AbstractArray) where {T} = convert(Array{T}, x) Then we could define: allowmissing(x::AbstractArray) = toeltype(Union{eltype(x), Missing}, x) We could possibly be even more ambitious and introduce a function like Overall it seems this will need to be in Base to be fully generic, which makes sense since |
Actually it looks like the needed functionality is already there. We could just define this function: allowmissing(x::AbstractArray) = convert(AbstractArray{Union{eltype(x), Missing}}, x) We should start using this immediately in DataFrames too, since it fixes the problem with (The current issue is simpler than |
@nalimilan - excellent solution. I was unaware that this would work. |
It would be nice to be have the following two functions:
AbstractArray{T}
and returnsAbstractArray{Union{T, Missing}}
;AbstractArray{Union{T, Missing}}
and returnsAbstractArray{T}
or throws an error if it contained any `missing.It now can be achieved e.g. using
convert
but I could not think of any more compact and handy conversion method (if there is such it would be great to document it).If it is considered to be worth to add such methods there are two corner cases that is also currently present in
Missings.T
function:This should probably return
Union{Int, Float64}
.The other is:
which should probably be
Int
and not error.The text was updated successfully, but these errors were encountered: