From 0c29bcbcfad602ee3a70cdb196bb4b4f474ec8ff Mon Sep 17 00:00:00 2001 From: David Gold Date: Thu, 24 Sep 2015 11:03:09 -0700 Subject: [PATCH 1/2] Fix deprecated `Union()` syntax --- src/reduce.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reduce.jl b/src/reduce.jl index bb34c9c..512055c 100644 --- a/src/reduce.jl +++ b/src/reduce.jl @@ -140,7 +140,7 @@ for (fn, op) in ((:(Base.sum), Base.AddFun()), (:(Base.minimum), Base.MinFun()), (:(Base.maximum), Base.MaxFun())) @eval begin - $fn(f::Union(Function,Base.Func{1}), + $fn(f::Union{Function,Base.Func{1}}, X::NullableArray; skipnull::Bool = false) = mapreduce(f, $op, X; skipnull = skipnull) From 77ded140302fdcf5cad02a0f8283a062f02904af Mon Sep 17 00:00:00 2001 From: David Gold Date: Thu, 24 Sep 2015 11:07:48 -0700 Subject: [PATCH 2/2] Support conversion if `#undef` values are null --- src/primitives.jl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/primitives.jl b/src/primitives.jl index bdfb048..097b11c 100644 --- a/src/primitives.jl +++ b/src/primitives.jl @@ -321,9 +321,25 @@ function Base.convert(::Type{NullableArray}, return NullableArray(A) end +function Base.convert{S, T, N}(::Type{NullableArray{S}}, + X::NullableArray{T, N}) # -> NullableArray{S, N} + res = similar(X, Nullable{S}, size(X)) + for i in eachindex(X) + if !isassigned(X.values, i) + X.isnull[i] ? nothing : error() + else + res[i] = X[i] + end + end + return res +end + function Base.convert{S, T, N}(::Type{NullableArray{S, N}}, - A::NullableArray{T, N}) # -> NullableArray{S, N} - return NullableArray(convert(Array{S}, A.values), A.isnull) + X::NullableArray{T, N}) # -> NullableArray{S, N} + res = NullableArray(convert(Array{S}, X.values), X.isnull) + # res2 = convert(NullableArray{S}, X) + # println(isequal(res, res2)) + return res end @doc """