Skip to content

Commit

Permalink
Undeprecate +/- for UniformScaling and Number
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Sep 28, 2017
1 parent 056b374 commit efbea46
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ Language changes
of the `:quote` expression head (though `:quote` `Expr`s are still used for quoted
expressions) ([#23885]).

* The + and - methods for Number and UniformScaling are not ambiguous anumore since + and -
no longer do automatix broadcasting. Hence the methods for UniformScaling and Number are
no longer deprecated ([#XXXXX]).

Breaking changes
----------------

Expand Down
5 changes: 0 additions & 5 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ 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.λ

# Deprecate methods that convert Diagonal and Bidiagonal to <:AbstractTriangular.
function convert(::Type{UpperTriangular}, A::Diagonal)
depwarn(string("`convert(::Type{UpperTriangular}, A::Diagonal)` and other methods ",
Expand Down
5 changes: 5 additions & 0 deletions base/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ istril(::UniformScaling) = true
issymmetric(::UniformScaling) = true
ishermitian(J::UniformScaling) = isreal(J.λ)

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

(+)(J1::UniformScaling, J2::UniformScaling) = UniformScaling(J1.λ+J2.λ)
(+)(B::BitArray{2}, J::UniformScaling) = Array(B) + J
(+)(J::UniformScaling, B::BitArray{2}) = J + Array(B)
Expand Down
8 changes: 7 additions & 1 deletion test/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ end
@test UniformScaling(4.32) 4.3*ones(2,2) rtol=0.1 atol=0.01
end

@testset "* and / with number" begin
@testset "arithmetic with Number" begin
α = randn()
@test α + I == α + 1
@test I + α == α + 1
@test α - I == α - 1
@test I - α == 1 - α
@test α .* UniformScaling(1.0) == UniformScaling(1.0) .* α
@test UniformScaling(α)./α == UniformScaling(1.0)
@test α * UniformScaling(1.0) == UniformScaling(1.0) * α
@test UniformScaling(α)/α == UniformScaling(1.0)
end

@testset "det and logdet" begin
Expand Down

0 comments on commit efbea46

Please sign in to comment.