Skip to content

Commit 5ee67b8

Browse files
authored
Remove trailing comma in 0-dim reshape summary (#56853)
Currently, there is an extra comma in displaying the summary for a 0-dim `ReshapedArray`: ```julia julia> reshape(1:1) 0-dimensional reshape(::UnitRange{Int64}, ) with eltype Int64: 1 ``` This PR only prints the comma if `dims` isn't empty, so that we now obtain ```julia julia> reshape(1:1) 0-dimensional reshape(::UnitRange{Int64}) with eltype Int64: 1 ```
1 parent 9d80765 commit 5ee67b8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/show.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,9 @@ showindices(io) = nothing
32653265
function showarg(io::IO, r::ReshapedArray, toplevel)
32663266
print(io, "reshape(")
32673267
showarg(io, parent(r), false)
3268-
print(io, ", ", join(r.dims, ", "))
3268+
if !isempty(r.dims)
3269+
print(io, ", ", join(r.dims, ", "))
3270+
end
32693271
print(io, ')')
32703272
toplevel && print(io, " with eltype ", eltype(r))
32713273
return nothing

test/show.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,9 @@ end
18611861
B = @view ones(2)[r]
18621862
Base.showarg(io, B, false)
18631863
@test String(take!(io)) == "view(::Vector{Float64}, $(repr(r)))"
1864+
1865+
Base.showarg(io, reshape(UnitRange{Int64}(1,1)), false)
1866+
@test String(take!(io)) == "reshape(::UnitRange{Int64})"
18641867
end
18651868

18661869
@testset "Methods" begin

0 commit comments

Comments
 (0)