diff --git a/README.md b/README.md index a588f80fa..c8b1474ee 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,8 @@ Currently, the `@compat` macro supports the following syntaxes: * Constructors for `Matrix{T}`, `Array{T}`, and `SparseMatrixCSC{T}` from `UniformScaling` ([#24372], [#24657]) +* Constructor for `Matrix` from `UniformScaling` ([#24372], [#24657]). + * `Uninitialized` and `uninitialized` with corresponding `Array` constructors ([#24652]). * `BitArray` constructors for `uninitialized` ([#24785]). diff --git a/src/Compat.jl b/src/Compat.jl index 4cf974ea8..a1703ce99 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1310,6 +1310,10 @@ end export parentmodule end +@static if VERSION < v"0.7.0-DEV.2541" + (::Type{Matrix}){T}(I::UniformScaling{T}, dims...) = eye(T, dims...) +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 9cf0dbc25..7fd3b4aff 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1168,6 +1168,10 @@ end # 0.7.0-DEV.3415 @test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] +# 0.7.0-DEV.2541 +@test Matrix(I, 2, 2) == [1 0; 0 1] +@test eltype(Matrix(1.0I, 3, 3)) == Float64 + if VERSION < v"0.6.0" include("deprecated.jl") end