Skip to content

Commit

Permalink
Remove argument restriction on dims2string and inds2string (#26799) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty authored and JeffBezanson committed Apr 16, 2018
1 parent 890239f commit 3180efa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 3180efa

Please sign in to comment.