Merge pull request #1731 from mkborregaard/missings

rudimentary missings support
This commit is contained in:
Michael Krabbe Borregaard 2018-09-07 15:54:22 +02:00 committed by GitHub
commit 187a19bfd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,11 +21,14 @@ convertToAnyVector(n::Integer, plotattributes::KW) = Any[zeros(0) for i in 1:n],
# numeric vector # numeric vector
convertToAnyVector(v::AVec{T}, plotattributes::KW) where {T<:Number} = Any[v], nothing convertToAnyVector(v::AVec{T}, plotattributes::KW) where {T<:Number} = Any[v], nothing
convertToAnyVector(v::AVec{Union{Missing, T}}, plotattributes::KW) where {T<:Number} = Any[replace(v, missing => NaN)], nothing
# string vector # string vector
convertToAnyVector(v::AVec{T}, plotattributes::KW) where {T<:AbstractString} = Any[v], nothing convertToAnyVector(v::AVec{T}, plotattributes::KW) where {T<:AbstractString} = Any[v], nothing
convertToAnyVector(v::AVec{Union{Missing, T}}, plotattributes::KW) where {T<:AbstractString} = Any[replace(v, missing => "")], nothing
function convertToAnyVector(v::AMat, plotattributes::KW) function convertToAnyVector(v::AMat, plotattributes::KW)
v = handlemissings(v)
if all3D(plotattributes) if all3D(plotattributes)
Any[Surface(v)] Any[Surface(v)]
else else
@ -33,6 +36,10 @@ function convertToAnyVector(v::AMat, plotattributes::KW)
end, nothing end, nothing
end end
handlemissings(v::AMat) = v
handlemissings(v::AMat{T}) where T <: Number = replace(v, missing => NaN)
handlemissings(v::AMat{T}) where T <: String = replace(v, missing => "")
# function # function
convertToAnyVector(f::Function, plotattributes::KW) = Any[f], nothing convertToAnyVector(f::Function, plotattributes::KW) = Any[f], nothing