Skip to content

Commit

Permalink
Fix summary for cases of mixed indices-types
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Feb 3, 2017
1 parent f66c866 commit 0eff50b
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -1533,8 +1533,8 @@ dims2string(d::Dims) = isempty(d) ? "0-dimensional" :
inds2string(inds::Indices) = join(map(string,inds), '×')

# anything array-like gets summarized e.g. 10-element Array{Int64,1}
summary(a::AbstractArray) = _summary(a, to_shape(indices(a)))
_summary(a, dims::Dims) = string(dims2string(dims), " ", typeof(a))
summary(a::AbstractArray) = _summary(a, indices(a))
_summary(a, inds::Tuple{Vararg{OneTo}}) = string(dims2string(length.(inds)), " ", typeof(a))
_summary(a, inds) = string(typeof(a), " with indices ", inds2string(inds))

# n-dimensional arrays
Expand Down
3 changes: 3 additions & 0 deletions test/offsetarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ for n = 0:4
show(IOContext(io, limit=true), MIME("text/plain"), (a,a))
@test String(take!(io)) == targets2[n+1]
end
P = OffsetArray(rand(8,8), (1,1))
PV = view(P, 2:3, :)
@test endswith(summary(PV), "with indices Base.OneTo(2)×2:9")

# Similar
B = similar(A, Float32)
Expand Down

0 comments on commit 0eff50b

Please sign in to comment.