Skip to content

Commit

Permalink
Add transpose() and ctranspose()
Browse files Browse the repository at this point in the history
These used to be provided by DataArrays, and are needed to transpose an
Array{Union{T, Null}} since these functions are called recursively.
  • Loading branch information
nalimilan committed Oct 5, 2017
1 parent bda982e commit f54c091
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Nulls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ for f in (:(!), :(+), :(-), :(Base.identity), :(Base.zero),
:(Base.log2), :(Base.exponent), :(Base.sqrt), :(Base.gamma), :(Base.lgamma),
:(Base.iseven), :(Base.ispow2), :(Base.isfinite), :(Base.isinf), :(Base.isodd),
:(Base.isinteger), :(Base.isreal), :(Base.isimag), :(Base.isnan), :(Base.isempty),
:(Base.iszero))
:(Base.iszero), :(Base.transpose), :(Base.ctranspose))
@eval $(f)(d::Null) = null
end

Expand All @@ -84,7 +84,8 @@ end
for f in (:(Base.ceil), :(Base.floor), :(Base.round), :(Base.trunc))
@eval begin
($f)(::Null, digits::Integer=0, base::Integer=0) = null
($f)(::Type, ::Null) = null
($f)(::Type{>:Null}, ::Null) = null
($f)(::Type, ::Null) = throw(NullException())
end
end

Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using Base.Test, Nulls
iseven, isodd, ispow2,
isfinite, isinf, isnan, iszero,
isinteger, isreal, isimag,
isempty]
isempty, transpose, ctranspose]

rounding_functions = [ceil, floor, round, trunc]

Expand All @@ -52,7 +52,8 @@ using Base.Test, Nulls
@test isnull(f(null))
@test isnull(f(null, 1))
@test isnull(f(null, 1, 1))
@test isnull(f(Int, null))
@test isnull(f(Union{Int, Null}, null))
@test_throws NullException f(Int, null)
end

@test zero(Union{Int, Null}) === 0
Expand Down

0 comments on commit f54c091

Please sign in to comment.