Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add repr for empty multidimensional arrays #19862

Merged
merged 1 commit into from Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions base/show.jl
Expand Up @@ -1630,6 +1630,9 @@ end

show(io::IO, X::AbstractArray) = showarray(io, X, true)

repremptyarray{T}(io::IO, X::Array{T}) = print(io, "Array{$T}(", join(size(X),','), ')')
repremptyarray(io, X) = nothing # by default, we don't know this constructor

function showarray(io::IO, X::AbstractArray, repr::Bool = true; header = true)
if repr && ndims(X) == 1
return show_vector(io, X, "[", "]")
Expand Down Expand Up @@ -1667,6 +1670,8 @@ function showarray(io::IO, X::AbstractArray, repr::Bool = true; header = true)
!repr)
end
end
elseif repr
repremptyarray(io, X)
end
end

Expand Down
7 changes: 7 additions & 0 deletions test/show.jl
Expand Up @@ -211,6 +211,13 @@ export A, B, C
export D, E, F
end"

# issue #19840
@test_repr "Array{Int}(0)"
@test_repr "Array{Int}(0,0)"
@test_repr "Array{Int}(0,0,0)"
@test_repr "Array{Int}(0,1)"
@test_repr "Array{Int}(0,0,1)"

# issue #8994
@test_repr "get! => 2"
@test_repr "(<) : 2"
Expand Down