Skip to content

Commit 14cf191

Browse files
committed
Move the show functionality into summary
`summary` gets called by `show`. This approach improves modularity.
1 parent b334d90 commit 14cf191

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

src/core.jl

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -343,28 +343,21 @@ dropax(ax) = ()
343343
# A simple display method to include axis information. It might be nice to
344344
# eventually display the axis labels alongside the data array, but that is
345345
# much more difficult.
346-
if VERSION < v"0.5.0-dev"
347-
function Base.writemime{T,N}(io::IO, m::MIME"text/plain", A::AxisArray{T,N})
348-
println(io, "$N-dimensional AxisArray{$T,$N,...} with axes:")
349-
for (name, val) in zip(axisnames(A), axisvalues(A))
350-
print(io, " :$name, ")
351-
Base.showlimited(io, val)
352-
println(io)
353-
end
354-
print(io, "And data, a ")
355-
writemime(io, m, A.data)
356-
end
357-
else
358-
function Base.show{T,N}(io::IO, m::MIME"text/plain", A::AxisArray{T,N})
359-
println(io, "$N-dimensional AxisArray{$T,$N,...} with axes:")
360-
for (name, val) in zip(axisnames(A), axisvalues(A))
361-
print(io, " :$name, ")
362-
show(IOContext(io, :limit=>true), val)
363-
println(io)
364-
end
365-
print(io, "And data, a ")
366-
show(io, m, A.data)
346+
function summaryio(io::IO, A::AxisArray)
347+
_summary(io, A)
348+
for (name, val) in zip(axisnames(A), axisvalues(A))
349+
print(io, " :$name, ")
350+
show(IOContext(io, :limit=>true), val)
351+
println(io)
367352
end
353+
print(io, "And data, a ", summary(A.data))
354+
end
355+
_summary{T,N}(io, A::AxisArray{T,N}) = println(io, "$N-dimensional AxisArray{$T,$N,...} with axes:")
356+
357+
function Base.summary(A::AxisArray)
358+
io = IOBuffer()
359+
summaryio(io, A)
360+
String(io)
368361
end
369362

370363
# Custom methods specific to AxisArrays

0 commit comments

Comments
 (0)