From 5b1e48f6b74b039fd509fc6ef419e67f8975772d Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Mon, 30 Oct 2017 16:33:28 -0700 Subject: [PATCH] Deprecate eye(::Type{Diagonal{T}}, m::Integer) method. --- NEWS.md | 3 +++ base/deprecated.jl | 2 ++ base/linalg/diagonal.jl | 2 -- base/linalg/uniformscaling.jl | 2 +- test/linalg/diagonal.jl | 1 - 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index cdf940755907fc..89b3f555e8cdd7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -302,6 +302,9 @@ Library improvements * The `crc32c` function for CRC-32c checksums is now exported ([#22274]). + * `eye(::Type{Diagonal{T}}, m::Integer)` has been deprecated in favor of + `Diagonal{T}(I, m)` ([#24413]). + * The output of `versioninfo` is now controlled with keyword arguments ([#21974]). * The function `LibGit2.set_remote_url` now always sets both the fetch and push URLs for a diff --git a/base/deprecated.jl b/base/deprecated.jl index 1582e8bb8df37f..c6a6561a3304c5 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1786,6 +1786,8 @@ end @deprecate get_creds!(cache::CachedCredentials, credid, default) get!(cache, credid, default) end +@deprecate eye(::Type{Diagonal{T}}, n::Int) where {T} Diagonal{T}(I, n) + export tic, toq, toc function tic() depwarn("tic() is deprecated, use @time, @elapsed, or calls to time_ns() instead.", :tic) diff --git a/base/linalg/diagonal.jl b/base/linalg/diagonal.jl index 93533a4b02f64b..a6555164568786 100644 --- a/base/linalg/diagonal.jl +++ b/base/linalg/diagonal.jl @@ -341,8 +341,6 @@ function logdet(D::Diagonal{<:Complex}) # make sure branch cut is correct z = sum(log, D.diag) complex(real(z), rem2pi(imag(z), RoundNearest)) end -# identity matrices via eye(Diagonal{type},n) -eye(::Type{Diagonal{T}}, n::Int) where {T} = Diagonal(ones(T,n)) # Matrix functions for f in (:exp, :log, :sqrt, diff --git a/base/linalg/uniformscaling.jl b/base/linalg/uniformscaling.jl index 479fb3dcafed9b..e0b837de439fab 100644 --- a/base/linalg/uniformscaling.jl +++ b/base/linalg/uniformscaling.jl @@ -374,4 +374,4 @@ chol(J::UniformScaling, args...) = ((C, info) = _chol!(J, nothing); @assertposde ## Diagonal construction from UniformScaling Diagonal{T}(s::UniformScaling, m::Integer) where {T} = Diagonal{T}(fill(T(s.λ), m)) -Diagonal(s::UniformScaling, m::Integer) where {T} = Diagonal{eltype(s)}(s, m) +Diagonal(s::UniformScaling, m::Integer) = Diagonal{eltype(s)}(s, m) diff --git a/test/linalg/diagonal.jl b/test/linalg/diagonal.jl index d57807c9eaf6cc..5319efd7a87428 100644 --- a/test/linalg/diagonal.jl +++ b/test/linalg/diagonal.jl @@ -29,7 +29,6 @@ srand(1) end @testset "Basic properties" begin - @test eye(Diagonal{elty},n) == Diagonal(ones(elty,n)) @test_throws ArgumentError size(D,0) @test typeof(convert(Diagonal{Complex64},D)) <: Diagonal{Complex64} @test typeof(convert(AbstractMatrix{Complex64},D)) <: Diagonal{Complex64}