Skip to content

Commit

Permalink
Deprecate vectorized sign methods in favor of dot syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 committed Jan 25, 2017
1 parent b45f443 commit 63be162
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/arraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See also [`conj`](@ref).
"""
conj!{T<:Number}(A::AbstractArray{T}) = (@inbounds broadcast!(conj, A, A); A)

for f in (:-, :~, :conj, :sign, :real, :imag)
for f in (:-, :~, :conj, :real, :imag)
@eval ($f)(A::AbstractArray) = broadcast($f, A)
end

Expand Down
2 changes: 1 addition & 1 deletion base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ function (-)(B::BitArray)
end
return A
end
sign(B::BitArray) = copy(B)
broadcast(sign, B::BitArray) = copy(B)

function (~)(B::BitArray)
C = similar(B)
Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,9 @@ end
# Deprecate manually vectorized abs2 methods in favor of compact broadcast syntax
@deprecate abs2(x::AbstractSparseVector) abs2.(x)

# Deprecate manually vectorized sign methods in favor of compact broadcast syntax
@deprecate sign(A::AbstractArray) sign.(A)

# Deprecate manually vectorized trigonometric and hyperbolic functions in favor of compact broadcast syntax
for f in (:sec, :sech, :secd, :asec, :asech,
:csc, :csch, :cscd, :acsc, :acsch,
Expand Down
8 changes: 4 additions & 4 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1824,10 +1824,10 @@ end
B = [-10.0,0.0,3.0]
C = [1,im,0]

@test sign(A) == [-1,0,1]
@test sign(B) == [-1,0,1]
@test typeof(sign(A)) == Vector{Int}
@test typeof(sign(B)) == Vector{Float64}
@test sign.(A) == [-1,0,1]
@test sign.(B) == [-1,0,1]
@test typeof(sign.(A)) == Vector{Int}
@test typeof(sign.(B)) == Vector{Float64}

@test conj(A) == A
@test conj(B) == A
Expand Down
4 changes: 2 additions & 2 deletions test/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ timesofar("dequeue")
@check_bit_operation (~)(b1) BitMatrix
@check_bit_operation (!)(b1) BitMatrix
@check_bit_operation (-)(b1) Matrix{Int}
@check_bit_operation sign(b1) BitMatrix
@check_bit_operation broadcast(sign, b1) BitMatrix
@check_bit_operation real(b1) BitMatrix
@check_bit_operation imag(b1) BitMatrix
@check_bit_operation conj(b1) BitMatrix
Expand All @@ -733,7 +733,7 @@ timesofar("dequeue")
@check_bit_operation (~)(b0) BitVector
@check_bit_operation (!)(b0) BitVector
@check_bit_operation (-)(b0) Vector{Int}
@check_bit_operation sign(b0) BitVector
@check_bit_operation broadcast(sign, b0) BitVector

@testset "flipbits!" begin
b1 = bitrand(n1, n2)
Expand Down

0 comments on commit 63be162

Please sign in to comment.