Skip to content

Commit

Permalink
Merge pull request #19931 from Sacha0/devecifelse
Browse files Browse the repository at this point in the history
Deprecate vectorized ifelse in favor of dot syntax
  • Loading branch information
JeffBezanson authored Jan 8, 2017
2 parents 69c1c8f + 53581b2 commit dbff9fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
6 changes: 6 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,12 @@ end
@deprecate (|)(A::AbstractArray, b::Number) A .| b
@deprecate (|)(A::AbstractArray, B::AbstractArray) A .| B

# Deprecate vectorized ifelse
@deprecate ifelse(c::AbstractArray{Bool}, x, y) ifelse.(c, x, y)
@deprecate ifelse(c::AbstractArray{Bool}, x, y::AbstractArray) ifelse.(c, x, y)
@deprecate ifelse(c::AbstractArray{Bool}, x::AbstractArray, y) ifelse.(c, x, y)
@deprecate ifelse(c::AbstractArray{Bool}, x::AbstractArray, y::AbstractArray) ifelse.(c, x, y)

function frexp{T<:AbstractFloat}(A::Array{T})
depwarn("`frexp(x::Array)` is discontinued.", :frexp)
F = similar(A)
Expand Down
18 changes: 0 additions & 18 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -931,24 +931,6 @@ for f in (:+, :-)
end
end

# vectorized ifelse

function ifelse(c::AbstractArray{Bool}, x, y)
[ifelse(ci, x, y) for ci in c]
end

function ifelse(c::AbstractArray{Bool}, x::AbstractArray, y::AbstractArray)
[ifelse(c_elem, x_elem, y_elem) for (c_elem, x_elem, y_elem) in zip(c, x, y)]
end

function ifelse(c::AbstractArray{Bool}, x::AbstractArray, y)
[ifelse(c_elem, x_elem, y) for (c_elem, x_elem) in zip(c, x)]
end

function ifelse(c::AbstractArray{Bool}, x, y::AbstractArray)
[ifelse(c_elem, x, y_elem) for (c_elem, y_elem) in zip(c, y)]
end

# Pair

immutable Pair{A,B}
Expand Down
8 changes: 4 additions & 4 deletions test/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ false ? push!(s, 3) : push!(s, 4)
@test s == Set([1, 4])

B = [true true false]
@test ifelse(B, 1, 2) == [1 1 2]
@test ifelse(B, 1, [2 3 4]) == [1 1 4]
@test ifelse(B, [2 3 4], 1) == [2 3 1]
@test ifelse(B, [2 3 4], [5 6 7]) == [2 3 7]
@test ifelse.(B, 1, 2) == [1 1 2]
@test ifelse.(B, 1, [2 3 4]) == [1 1 4]
@test ifelse.(B, [2 3 4], 1) == [2 3 1]
@test ifelse.(B, [2 3 4], [5 6 7]) == [2 3 7]

@test reverse(Pair(1,2)) == Pair(2,1)
@test reverse(Pair("13","24")) == Pair("24","13")
Expand Down

2 comments on commit dbff9fd

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.