Skip to content

Commit 222230e

Browse files
author
Andy Ferris
committed
Deprecate +/- methods for array+scalar etc
The elementwise definition is incorrect for linear algebra.
1 parent 7287321 commit 222230e

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ Deprecated or removed
221221
* The function `showall` is deprecated. Showing entire values is the default, unless an
222222
`IOContext` specifying `:limit=>true` is in use ([#22847]).
223223

224+
* Automatically broadcasted `+` and `-` for `array + scalar`, `scalar - array`, and so-on have
225+
been deprecated due to inconsistency with linear algebra. Use `.+` and `.-` for these operations
226+
instead.
227+
224228

225229
Julia v0.6.0 Release Notes
226230
==========================

base/arraymath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ for f in (:+, :-)
4040
end
4141
end
4242

43-
for f in (:/, :\, :*, :+, :-)
43+
for f in (:/, :\, :*)
4444
if f != :/
4545
@eval ($f)(A::Number, B::AbstractArray) = broadcast($f, A, B)
4646
end

base/dates/periods.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ GeneralPeriod = Union{Period, CompoundPeriod}
358358

359359
for op in (:+, :-)
360360
@eval begin
361-
($op)(x::GeneralPeriod, Y::StridedArray{<:GeneralPeriod}) = broadcast($op, x, Y)
362-
($op)(Y::StridedArray{<:GeneralPeriod}, x::GeneralPeriod) = broadcast($op, Y, x)
363361
($op)(X::StridedArray{<:GeneralPeriod}, Y::StridedArray{<:GeneralPeriod}) =
364362
reshape(CompoundPeriod[($op)(x, y) for (x, y) in zip(X, Y)], promote_shape(size(X), size(Y)))
365363
end

base/deprecated.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,11 @@ end
15911591
@deprecate readstring(filename::AbstractString) read(filename, String)
15921592
@deprecate readstring(cmd::AbstractCmd) read(cmd, String)
15931593

1594+
@deprecate +(a::Number, b::AbstractArray) a .+ b
1595+
@deprecate +(a::AbstractArray, b::Number) a .+ b
1596+
@deprecate -(a::Number, b::AbstractArray) a .- b
1597+
@deprecate -(a::AbstractArray, b::Number) a .- b
1598+
15941599
# END 0.7 deprecations
15951600

15961601
# BEGIN 1.0 deprecations

base/linalg/symmetric.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ A_mul_Bt(A::AbstractTriangular, B::RealHermSymComplexSym) = A*B
321321
Ac_mul_B(A::RealHermSymComplexHerm, B::AbstractTriangular) = A*B
322322
A_mul_Bc(A::AbstractTriangular, B::RealHermSymComplexHerm) = A*B
323323

324-
for T in (:Symmetric, :Hermitian), op in (:+, :-, :*, :/)
324+
for T in (:Symmetric, :Hermitian), op in (:*, :/)
325325
# Deal with an ambiguous case
326326
@eval ($op)(A::$T, x::Bool) = ($T)(($op)(A.data, x), Symbol(A.uplo))
327327
S = T == :Hermitian ? :Real : :Number

base/random.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ srand(r::MersenneTwister, n::Integer) = srand(r, make_seed(n))
274274

275275
function dsfmt_gv_srand()
276276
# Temporary fix for #8874 and #9124: update global RNG for Rmath
277-
dsfmt_gv_init_by_array(GLOBAL_RNG.seed+UInt32(1))
277+
dsfmt_gv_init_by_array(GLOBAL_RNG.seed .+ UInt32(1))
278278
return GLOBAL_RNG
279279
end
280280

0 commit comments

Comments
 (0)