Skip to content

Commit 78f1b6f

Browse files
authored
Merge pull request #36 from JuliaArrays/teh/fix_35
Fix display of 0-d OffsetArrays on 0.7 and higher
2 parents 9058120 + 5d57c37 commit 78f1b6f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/OffsetArrays.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ if VERSION >= v"0.7.0-DEV.1790"
228228
function Base.showarg(io::IO, a::OffsetArray, toplevel)
229229
print(io, "OffsetArray(")
230230
Base.showarg(io, parent(a), false)
231-
print(io, ", ")
232-
printindices(io, indices(a)...)
231+
if ndims(a) > 0
232+
print(io, ", ")
233+
printindices(io, indices(a)...)
234+
end
233235
print(io, ')')
234236
toplevel && print(io, " with eltype ", eltype(a))
235237
end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ if VERSION >= v"0.7.0-DEV.1790"
358358
a = OffsetArray([1 2; 3 4], -1:0, 5:6)
359359
@test summary(a) == "OffsetArray(::Array{$(Int),2}, -1:0, 5:6) with eltype $(Int) with indices -1:0×5:6"
360360
@test summary(view(a, :, 5)) == "view(OffsetArray(::Array{Int64,2}, -1:0, 5:6), :, 5) with eltype Int64 with indices -1:0"
361+
a = OffsetArray(reshape([1]))
362+
@test summary(a) == "0-dimensional OffsetArray(::Array{Int64,0}) with eltype Int64"
361363
end
362364

363365
@testset "OffsetVector constructors" begin

0 commit comments

Comments
 (0)