nicer display, share more code

This commit is contained in:
Mike J Innes 2017-06-05 18:10:43 +01:00
parent ce6c96c2be
commit 7505ee3a16
2 changed files with 6 additions and 14 deletions

View File

@ -11,12 +11,6 @@ Batch(xs) = Batch(Storage(xs))
convert{T,S}(::Type{Batch{T,S}},storage::S) =
Batch{T,S}(storage)
@render Juno.Inline b::Batch begin
Tree(Row(Text("Batch of "), eltype(b),
Juno.fade("[$(length(b))]")),
Juno.trim(collect(b)))
end
# TODO: figure out how to express this as a generic convert
function rebatch(xs)
dims = ndims(xs)-1
@ -48,12 +42,6 @@ Seq(xs) = Seq(Storage(xs))
convert{T,S}(::Type{Seq{T,S}},storage::S) =
Seq{T,S}(storage)
@render Juno.Inline b::Seq begin
Tree(Row(Text("Seq of "), eltype(b),
Juno.fade("[$(length(b))]")),
Juno.trim(collect(b)))
end
BatchSeq{T<:Seq} = Batch{T}
function rebatchseq(xs)

View File

@ -46,8 +46,12 @@ function Storage(xs)
Storage{eltype(xs)}(xs)
end
@render Juno.Inline b::Storage begin
Tree(Row(Text("Storage of "), eltype(b),
typename(b::Type) = b
typename(b::Type{<:BatchLike}) =
Row(Juno.typ("$(b.name.name)"), text"{", typename(eltype(b)), text"}")
@render Juno.Inline b::BatchLike begin
Tree(Row(typename(typeof(b)),
Juno.fade("[$(length(b))]")),
Juno.trim(collect(b)))
end