Skip to content

Commit be48fbf

Browse files
authored
Fix show for rectangular Eye (#328)
1 parent 5840fc6 commit be48fbf

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FillArrays"
22
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3-
version = "1.9.2"
3+
version = "1.9.3"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/FillArrays.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,13 @@ function Base.show(io::IO, x::AbstractFill) # for example (Fill(π,3),)
742742
join(io, size(x), ", ")
743743
print(io, ")")
744744
end
745-
Base.show(io::IO, x::Eye) = print(io, "Eye(", size(x,1), ")")
745+
function Base.show(io::IO, x::Eye)
746+
print(io, "Eye(", size(x,1))
747+
if size(x,1) != size(x,2)
748+
print(io, ",", size(x,2))
749+
end
750+
print(io, ")")
751+
end
746752

747753
Base.array_summary(io::IO, ::Zeros{T}, inds::Tuple{Vararg{Base.OneTo}}) where T =
748754
print(io, Base.dims2string(length.(inds)), " Zeros{$T}")

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ end
11141114
@test Zeros(S, 10) .* (T(1):T(10)) Zeros(U, 10)
11151115
@test_throws DimensionMismatch Zeros(S, 10) .* (T(1):T(11))
11161116
end
1117-
end
1117+
end
11181118
end
11191119
end
11201120

@@ -1818,6 +1818,7 @@ end
18181818
@test repr(Fill(1f0,10)) == "Fill(1.0f0, 10)" # Float32!
18191819
@test repr(Fill(0)) == "Fill(0)"
18201820
@test repr(Eye(9)) == "Eye(9)"
1821+
@test repr(Eye(9,4)) == "Eye(9,4)"
18211822
# also used for arrays of arrays:
18221823
@test occursin("Eye(2) ", stringmime("text/plain", [Eye(2) for i in 1:2, j in 1:2]))
18231824
end
@@ -2291,4 +2292,3 @@ end
22912292
@test a.value == first(diag)
22922293
end
22932294
end
2294-

0 commit comments

Comments
 (0)