Skip to content

Commit 2e08102

Browse files
martinholterstkelman
authored andcommitted
Remove broadcast_elwise_op and deprecate promote_eltype_op (#19814)
* Remove broadcast_elwise_op and deprecate promote_eltype_op * Fix typo in comment
1 parent 5d2e538 commit 2e08102

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

base/abstractarray.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,12 +1790,6 @@ function mapslices(f, A::AbstractArray, dims::AbstractVector)
17901790
return R
17911791
end
17921792

1793-
# These are needed because map(eltype, As) is not inferrable
1794-
promote_eltype_op(::Any) = Any
1795-
promote_eltype_op(op, A) = (@_inline_meta; promote_op(op, eltype(A)))
1796-
promote_eltype_op(op, A, B) = (@_inline_meta; promote_op(op, eltype(A), eltype(B)))
1797-
promote_eltype_op(op, A, B, C, D...) = (@_inline_meta; promote_eltype_op(op, eltype(A), promote_eltype_op(op, B, C, D...)))
1798-
17991793
## 1 argument
18001794

18011795
function map!{F}(f::F, dest::AbstractArray, A::AbstractArray)

base/broadcast.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Broadcast
44

55
using Base.Cartesian
6-
using Base: promote_eltype_op, linearindices, tail, OneTo, to_shape,
6+
using Base: linearindices, tail, OneTo, to_shape,
77
_msk_end, unsafe_bitgetindex, bitcache_chunks, bitcache_size, dumpbitcache,
88
nullable_returntype, null_safe_eltype_op, hasvalue
99
import Base: broadcast, broadcast!
@@ -267,11 +267,6 @@ function broadcast_t(f, ::Type{Bool}, shape, iter, As...)
267267
return B
268268
end
269269

270-
# broadcast method that uses inference to find the type, but preserves abstract
271-
# container types when possible (used by binary elementwise operators)
272-
@inline broadcast_elwise_op(f, As...) =
273-
broadcast!(f, similar(Array{promote_eltype_op(f, As...)}, broadcast_indices(As...)), As...)
274-
275270
eltypestuple(a) = (Base.@_pure_meta; Tuple{eltype(a)})
276271
eltypestuple(T::Type) = (Base.@_pure_meta; Tuple{Type{T}})
277272
eltypestuple(a, b...) = (Base.@_pure_meta; Tuple{eltypestuple(a).types..., eltypestuple(b...).types...})

base/deprecated.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ for (Bsig, A1sig, A2sig, gbb, funcname) in
12391239
end # let broadcast_cache
12401240
end
12411241
_broadcast_zpreserving!(args...) = broadcast!(args...)
1242-
_broadcast_zpreserving(args...) = Base.Broadcast.broadcast_elwise_op(args...)
1242+
_broadcast_zpreserving(f, As...) = broadcast!(f, similar(Array{promote_op(f, map(eltype, As)...)}, Base.Broadcast.broadcast_indices(As...)), As...)
12431243
_broadcast_zpreserving{Tv1,Ti1,Tv2,Ti2}(f::Function, A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2}) =
12441244
_broadcast_zpreserving!(f, spzeros(promote_type(Tv1, Tv2), promote_type(Ti1, Ti2), Base.to_shape(Base.Broadcast.broadcast_indices(A_1, A_2))), A_1, A_2)
12451245
_broadcast_zpreserving{Tv,Ti}(f::Function, A_1::SparseMatrixCSC{Tv,Ti}, A_2::Union{Array,BitArray,Number}) =
@@ -1470,4 +1470,7 @@ end
14701470
@deprecate (|)(A::AbstractArray, b::Number) A .| b
14711471
@deprecate (|)(A::AbstractArray, B::AbstractArray) A .| B
14721472

1473+
# Calling promote_op is likely a bad idea, so deprecate its convenience wrapper promote_eltype_op
1474+
@deprecate promote_eltype_op(op, As...) promote_op(op, map(eltype, As)...)
1475+
14731476
# End deprecations scheduled for 0.6

0 commit comments

Comments
 (0)