Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #212 from yuyichao/invoke
Browse files Browse the repository at this point in the history
Fix use of `invoke`
  • Loading branch information
nalimilan authored Sep 11, 2016
2 parents f17e4e3 + abeadcb commit 0f324c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
34 changes: 17 additions & 17 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,13 @@ end

# ambiguity
@swappable (==)(a::DataArray{Bool}, b::BitArray) =
invoke(==, (DataArray, AbstractArray), a, b)
invoke(==, Tuple{DataArray,AbstractArray}, a, b)
@swappable (==)(a::DataArray, b::BitArray) =
invoke(==, (DataArray, AbstractArray), a, b)
invoke(==, Tuple{DataArray,AbstractArray}, a, b)
@swappable (==)(a::AbstractDataArray{Bool}, b::BitArray) =
invoke(==, (DataArray, AbstractArray), a, b)
invoke(==, Tuple{DataArray,AbstractArray}, a, b)
@swappable (==)(a::AbstractDataArray, b::BitArray) =
invoke(==, (DataArray, AbstractArray), a, b)
invoke(==, Tuple{DataArray,AbstractArray}, a, b)

function (==)(a::DataArray, b::DataArray)
size(a) == size(b) || return false
Expand All @@ -552,7 +552,7 @@ end

# ambiguity
@swappable (==)(a::DataArray, b::AbstractDataArray) =
invoke(==, (AbstractDataArray, AbstractDataArray), a, b)
invoke(==, Tuple{AbstractDataArray,AbstractDataArray}, a, b)

@swappable function (==)(a::DataArray, b::AbstractArray)
size(a) == size(b) || return false
Expand Down Expand Up @@ -672,31 +672,31 @@ function (-){TA,TJ<:Number}(J::UniformScaling{TJ},A::DataArray{TA,2})
end

(+)(A::DataArray{Bool,2},J::UniformScaling{Bool}) =
invoke(+, (AbstractArray{Bool,2}, UniformScaling{Bool}), A, J)
invoke(+, Tuple{AbstractArray{Bool,2},UniformScaling{Bool}}, A, J)
(+)(J::UniformScaling{Bool},A::DataArray{Bool,2}) =
invoke(+, (UniformScaling{Bool}, AbstractArray{Bool,2}), J, A)
invoke(+, Tuple{UniformScaling{Bool},AbstractArray{Bool,2}}, J, A)
(-)(A::DataArray{Bool,2},J::UniformScaling{Bool}) =
invoke(-, (AbstractArray{Bool,2}, UniformScaling{Bool}), A, J)
invoke(-, Tuple{AbstractArray{Bool,2},UniformScaling{Bool}}, A, J)
(-)(J::UniformScaling{Bool},A::DataArray{Bool,2}) =
invoke(-, (UniformScaling{Bool}, AbstractArray{Bool,2}), J, A)
invoke(-, Tuple{UniformScaling{Bool},AbstractArray{Bool,2}}, J, A)

(+){TA,TJ}(A::AbstractDataArray{TA,2},J::UniformScaling{TJ}) =
invoke(+, (AbstractArray{TA,2}, UniformScaling{TJ}), A, J)
invoke(+, Tuple{AbstractArray{TA,2},UniformScaling{TJ}}, A, J)
(+){TA}(J::UniformScaling,A::AbstractDataArray{TA,2}) =
invoke(+, (UniformScaling, AbstractArray{TA,2}), J, A)
invoke(+, Tuple{UniformScaling,AbstractArray{TA,2}}, J, A)
(-){TA,TJ<:Number}(A::AbstractDataArray{TA,2},J::UniformScaling{TJ}) =
invoke(-, (AbstractArray{TA,2}, UniformScaling{TJ}), A, J)
invoke(-, Tuple{AbstractArray{TA,2},UniformScaling{TJ}}, A, J)
(-){TA,TJ<:Number}(J::UniformScaling{TJ},A::AbstractDataArray{TA,2}) =
invoke(-, (UniformScaling{TJ}, AbstractArray{TA,2}), J, A)
invoke(-, Tuple{UniformScaling{TJ},AbstractArray{TA,2}}, J, A)

(+)(A::AbstractDataArray{Bool,2},J::UniformScaling{Bool}) =
invoke(+, (AbstractArray{Bool,2}, UniformScaling{Bool}), A, J)
invoke(+, Tuple{AbstractArray{Bool,2},UniformScaling{Bool}}, A, J)
(+)(J::UniformScaling{Bool},A::AbstractDataArray{Bool,2}) =
invoke(+, (UniformScaling{Bool}, AbstractArray{Bool,2}), J, A)
invoke(+, Tuple{UniformScaling{Bool},AbstractArray{Bool,2}}, J, A)
(-)(A::AbstractDataArray{Bool,2},J::UniformScaling{Bool}) =
invoke(-, (AbstractArray{Bool,2}, UniformScaling{Bool}), A, J)
invoke(-, Tuple{AbstractArray{Bool,2},UniformScaling{Bool}}, A, J)
(-)(J::UniformScaling{Bool},A::AbstractDataArray{Bool,2}) =
invoke(-, (UniformScaling{Bool}, AbstractArray{Bool,2}), J, A)
invoke(-, Tuple{UniformScaling{Bool},AbstractArray{Bool,2}}, J, A)

end # if isdefined(Base, :UniformScaling)

Expand Down
2 changes: 1 addition & 1 deletion src/pooleddataarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ end
# # Need setindex!()'s to make this work
# This is broken now because the inner show returns to the outer show.
# function show(io::IO, pda::PooledDataArray)
# invoke(show, (Any, AbstractArray), io, pda)
# invoke(show, Tuple{Any,AbstractArray}, io, pda)
# print(io, "\nlevels: ")
# print(io, levels(pda))
# end
Expand Down
4 changes: 2 additions & 2 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ as_pda(x) = convert(PooledDataArray, x)
as_pda_bigfloat(x) = convert(PooledDataArray{BigFloat}, x)

bittest(f::Function, ewf::Function, a...) = (@test ewf(a...) ==
invoke(broadcast, tuple(Function, ntuple(x->AbstractArray, length(a))...), f, a...))
invoke(broadcast, Tuple{Function,ntuple(x->AbstractArray, length(a))...}, f, a...))
n1 = 21
n2 = 32
n3 = 17
Expand Down Expand Up @@ -131,4 +131,4 @@ rt = Base.return_types(broadcast!, (Function, DataArray{Float64, 3}, Array{Float
@test map!(abs, @data([-1, -2])) == @data([1, 2])
@test isequal(map!(+, DataArray(Float64, 3), @data([1, NA, 3]), @data([NA, 2, 3])), @data([NA, NA, 6]))
@test map!(isequal, DataArray(Float64, 3), @data([1, NA, NA]), @data([1, NA, 3])) == @data([true, true, false])
end
end

0 comments on commit 0f324c6

Please sign in to comment.