Skip to content

Commit

Permalink
Fix display of 0-d OffsetArrays on 0.7 and higher
Browse files Browse the repository at this point in the history
Fixes #35
  • Loading branch information
timholy committed Dec 5, 2017
1 parent 9058120 commit 5d57c37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ if VERSION >= v"0.7.0-DEV.1790"
function Base.showarg(io::IO, a::OffsetArray, toplevel)
print(io, "OffsetArray(")
Base.showarg(io, parent(a), false)
print(io, ", ")
printindices(io, indices(a)...)
if ndims(a) > 0
print(io, ", ")
printindices(io, indices(a)...)
end
print(io, ')')
toplevel && print(io, " with eltype ", eltype(a))
end
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ if VERSION >= v"0.7.0-DEV.1790"
a = OffsetArray([1 2; 3 4], -1:0, 5:6)
@test summary(a) == "OffsetArray(::Array{$(Int),2}, -1:0, 5:6) with eltype $(Int) with indices -1:0×5:6"
@test summary(view(a, :, 5)) == "view(OffsetArray(::Array{Int64,2}, -1:0, 5:6), :, 5) with eltype Int64 with indices -1:0"
a = OffsetArray(reshape([1]))
@test summary(a) == "0-dimensional OffsetArray(::Array{Int64,0}) with eltype Int64"
end

@testset "OffsetVector constructors" begin
Expand Down

0 comments on commit 5d57c37

Please sign in to comment.