Skip to content

Commit

Permalink
Remove +-(UniformScaling, Number) to avoid ambiguous behavior as pointed
Browse files Browse the repository at this point in the history
out in #17083
  • Loading branch information
andreasnoack committed Aug 18, 2016
1 parent 57df5f1 commit 12fdfae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 5 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -790,4 +790,9 @@ function delete!(::EnvHash, k::AbstractString, def)
haskey(ENV,k) ? delete!(ENV,k) : def
end

@deprecate (+)(J::UniformScaling, x::Number) J.λ + x
@deprecate (+)(x::Number, J::UniformScaling) x + J.λ
@deprecate (-)(J::UniformScaling, x::Number) J.λ - x
@deprecate (-)(x::Number, J::UniformScaling) x - J.λ

# End deprecations scheduled for 0.6
4 changes: 0 additions & 4 deletions base/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ ishermitian(J::UniformScaling) = isreal(J.λ)
(+){T}(B::BitArray{2},J::UniformScaling{T}) = Array(B) + J
(+)(J::UniformScaling, B::BitArray{2}) = J + Array(B)
(+)(J::UniformScaling, A::AbstractMatrix) = A + J
(+)(J::UniformScaling, x::Number) = J.λ + x
(+)(x::Number, J::UniformScaling) = x + J.λ

(-)(J::UniformScaling) = UniformScaling(-J.λ)
(-)(J1::UniformScaling, J2::UniformScaling) = UniformScaling(J1.λ-J2.λ)
(-)(B::BitArray{2}, J::UniformScaling) = Array(B) - J
(-)(J::UniformScaling, B::BitArray{2}) = J - Array(B)
(-)(J::UniformScaling, x::Number) = J.λ - x
(-)(x::Number, J::UniformScaling) = x - J.λ

for (t1, t2) in ((:UnitUpperTriangular, :UpperTriangular),
(:UnitLowerTriangular, :LowerTriangular))
Expand Down
2 changes: 0 additions & 2 deletions test/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ srand(123)
α = randn()
@test α .* UniformScaling(1.0) == UniformScaling(1.0) .* α
@test UniformScaling(α)./α == UniformScaling(1.0)
@test α + UniformScaling(1.0) == UniformScaling(1.0) + α
@test α - UniformScaling(1.0) == -(UniformScaling(1.0) - α)
@test copy(UniformScaling(one(Float64))) == UniformScaling(one(Float64))
@test sprint(show,UniformScaling(one(Float32))) == "UniformScaling{Float32}\n1.0*I"

Expand Down

0 comments on commit 12fdfae

Please sign in to comment.