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

Remove argument restriction on dims2string and inds2string (#26799) #26817

Merged
merged 2 commits into from
Apr 16, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1835,11 +1835,11 @@ end

## `summary` for AbstractArrays
# sizes such as 0-dimensional, 4-dimensional, 2x3
dims2string(d::Dims) = isempty(d) ? "0-dimensional" :
length(d) == 1 ? "$(d[1])-element" :
join(map(string,d), '×')
dims2string(d) = isempty(d) ? "0-dimensional" :
length(d) == 1 ? "$(d[1])-element" :
join(map(string,d), '×')

inds2string(inds::Indices) = join(map(string,inds), '×')
inds2string(inds) = join(map(string,inds), '×')

# anything array-like gets summarized e.g. 10-element Array{Int64,1}
summary(io::IO, a::AbstractArray) = summary(io, a, axes(a))
Expand Down
7 changes: 7 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1189,3 +1189,10 @@ end
@test repr("text/plain", context=:compact=>true) == "\"text/plain\""
@test repr(MIME("text/plain"), context=:compact=>true) == "MIME type text/plain"
end

@testset "#26799 BigInt summary" begin
@test Base.dims2string(tuple(BigInt(10))) == "10-element"
@test Base.inds2string(tuple(BigInt(10))) == "10"
@test summary(BigInt(1):BigInt(10)) == "10-element UnitRange{BigInt}"
@test summary(Base.OneTo(BigInt(10))) == "10-element Base.OneTo{BigInt}"
end