From 65a8c29d4f323711dbbefc9a3d7c69e3b7c98035 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Mon, 11 Dec 2023 18:50:03 +0530 Subject: [PATCH] Fix show for rectangular `Eye` --- Project.toml | 2 +- src/FillArrays.jl | 8 +++++++- test/runtests.jl | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index b221840d..59a804ca 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FillArrays" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "1.9.2" +version = "1.9.3" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/FillArrays.jl b/src/FillArrays.jl index ac4f4ee6..e55f6fc9 100644 --- a/src/FillArrays.jl +++ b/src/FillArrays.jl @@ -742,7 +742,13 @@ function Base.show(io::IO, x::AbstractFill) # for example (Fill(π,3),) join(io, size(x), ", ") print(io, ")") end -Base.show(io::IO, x::Eye) = print(io, "Eye(", size(x,1), ")") +function Base.show(io::IO, x::Eye) + print(io, "Eye(", size(x,1)) + if size(x,1) != size(x,2) + print(io, ",", size(x,2)) + end + print(io, ")") +end Base.array_summary(io::IO, ::Zeros{T}, inds::Tuple{Vararg{Base.OneTo}}) where T = print(io, Base.dims2string(length.(inds)), " Zeros{$T}") diff --git a/test/runtests.jl b/test/runtests.jl index e67b62b5..2e8fe0df 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1114,7 +1114,7 @@ end @test Zeros(S, 10) .* (T(1):T(10)) ≡ Zeros(U, 10) @test_throws DimensionMismatch Zeros(S, 10) .* (T(1):T(11)) end - end + end end end @@ -1818,6 +1818,7 @@ end @test repr(Fill(1f0,10)) == "Fill(1.0f0, 10)" # Float32! @test repr(Fill(0)) == "Fill(0)" @test repr(Eye(9)) == "Eye(9)" + @test repr(Eye(9,4)) == "Eye(9,4)" # also used for arrays of arrays: @test occursin("Eye(2) ", stringmime("text/plain", [Eye(2) for i in 1:2, j in 1:2])) end @@ -2291,4 +2292,3 @@ end @test a.value == first(diag) end end -