Skip to content

Commit

Permalink
Deprecate +/- methods for array+scalar etc
Browse files Browse the repository at this point in the history
The elementwise definition is incorrect for linear algebra.
  • Loading branch information
Andy Ferris committed Aug 7, 2017
1 parent ae17198 commit c50c41c
Show file tree
Hide file tree
Showing 26 changed files with 1,327 additions and 1,302 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ Deprecated or removed
* Calling `union` with no arguments is deprecated; construct an empty set with an appropriate
element type using `Set{T}()` instead ([#23144]).

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


Julia v0.6.0 Release Notes
==========================

Expand Down
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ function _cat(A, shape::NTuple{N}, catdims, X...) where N
for x in X
for i = 1:N
if concat[i]
inds[i] = offsets[i] + cat_indices(x, i)
inds[i] = broadcast(+, offsets[i], cat_indices(x, i))
offsets[i] += cat_size(x, i)
else
inds[i] = 1:shape[i]
Expand Down
2 changes: 1 addition & 1 deletion base/arraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ for f in (:+, :-)
end
end

for f in (:/, :\, :*, :+, :-)
for f in (:/, :\, :*)
if f != :/
@eval ($f)(A::Number, B::AbstractArray) = broadcast($f, A, B)
end
Expand Down
2 changes: 0 additions & 2 deletions base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ GeneralPeriod = Union{Period, CompoundPeriod}

for op in (:+, :-)
@eval begin
($op)(x::GeneralPeriod, Y::StridedArray{<:GeneralPeriod}) = broadcast($op, x, Y)
($op)(Y::StridedArray{<:GeneralPeriod}, x::GeneralPeriod) = broadcast($op, Y, x)
($op)(X::StridedArray{<:GeneralPeriod}, Y::StridedArray{<:GeneralPeriod}) =
reshape(CompoundPeriod[($op)(x, y) for (x, y) in zip(X, Y)], promote_shape(size(X), size(Y)))
end
Expand Down
Loading

0 comments on commit c50c41c

Please sign in to comment.