Skip to content

Commit dbff9fd

Browse files
authored
Merge pull request #19931 from Sacha0/devecifelse
Deprecate vectorized ifelse in favor of dot syntax
2 parents 69c1c8f + 53581b2 commit dbff9fd

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

base/deprecated.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,12 @@ end
14861486
@deprecate (|)(A::AbstractArray, b::Number) A .| b
14871487
@deprecate (|)(A::AbstractArray, B::AbstractArray) A .| B
14881488

1489+
# Deprecate vectorized ifelse
1490+
@deprecate ifelse(c::AbstractArray{Bool}, x, y) ifelse.(c, x, y)
1491+
@deprecate ifelse(c::AbstractArray{Bool}, x, y::AbstractArray) ifelse.(c, x, y)
1492+
@deprecate ifelse(c::AbstractArray{Bool}, x::AbstractArray, y) ifelse.(c, x, y)
1493+
@deprecate ifelse(c::AbstractArray{Bool}, x::AbstractArray, y::AbstractArray) ifelse.(c, x, y)
1494+
14891495
function frexp{T<:AbstractFloat}(A::Array{T})
14901496
depwarn("`frexp(x::Array)` is discontinued.", :frexp)
14911497
F = similar(A)

base/operators.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -931,24 +931,6 @@ for f in (:+, :-)
931931
end
932932
end
933933

934-
# vectorized ifelse
935-
936-
function ifelse(c::AbstractArray{Bool}, x, y)
937-
[ifelse(ci, x, y) for ci in c]
938-
end
939-
940-
function ifelse(c::AbstractArray{Bool}, x::AbstractArray, y::AbstractArray)
941-
[ifelse(c_elem, x_elem, y_elem) for (c_elem, x_elem, y_elem) in zip(c, x, y)]
942-
end
943-
944-
function ifelse(c::AbstractArray{Bool}, x::AbstractArray, y)
945-
[ifelse(c_elem, x_elem, y) for (c_elem, x_elem) in zip(c, x)]
946-
end
947-
948-
function ifelse(c::AbstractArray{Bool}, x, y::AbstractArray)
949-
[ifelse(c_elem, x, y_elem) for (c_elem, y_elem) in zip(c, y)]
950-
end
951-
952934
# Pair
953935

954936
immutable Pair{A,B}

test/operators.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ false ? push!(s, 3) : push!(s, 4)
1313
@test s == Set([1, 4])
1414

1515
B = [true true false]
16-
@test ifelse(B, 1, 2) == [1 1 2]
17-
@test ifelse(B, 1, [2 3 4]) == [1 1 4]
18-
@test ifelse(B, [2 3 4], 1) == [2 3 1]
19-
@test ifelse(B, [2 3 4], [5 6 7]) == [2 3 7]
16+
@test ifelse.(B, 1, 2) == [1 1 2]
17+
@test ifelse.(B, 1, [2 3 4]) == [1 1 4]
18+
@test ifelse.(B, [2 3 4], 1) == [2 3 1]
19+
@test ifelse.(B, [2 3 4], [5 6 7]) == [2 3 7]
2020

2121
@test reverse(Pair(1,2)) == Pair(2,1)
2222
@test reverse(Pair("13","24")) == Pair("24","13")

0 commit comments

Comments
 (0)