Skip to content

Commit

Permalink
Remove argument restriction on dims2string and inds2string (JuliaLang…
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Apr 15, 2018
1 parent b6d81e3 commit c24ed75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 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" :
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 "BigInt summary #26799" 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

0 comments on commit c24ed75

Please sign in to comment.