From 0180410e229909ed6c095d9701f8d59ba5136d06 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Fri, 25 Feb 2022 16:10:53 -0500 Subject: [PATCH] fix stacktrace too long (#149) * fix stacktrace too long * fix stacktrace too long try 2 * fix stacktrace too long try 3 * fix before 1.6 --- src/UnROOT.jl | 1 + src/displays.jl | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/UnROOT.jl b/src/UnROOT.jl index 17c966b8..aea5830f 100644 --- a/src/UnROOT.jl +++ b/src/UnROOT.jl @@ -17,6 +17,7 @@ import LibDeflate: zlib_decompress!, Decompressor import Tables, TypedTables, PrettyTables @static if VERSION < v"1.6" + Base.first(itr, n::Integer) = collect(Iterators.take(itr, n)) Base.first(a::AbstractVector{S}, n::Integer) where S<: AbstractString = a[1:(length(a) > n ? n : end)] Base.first(a::S, n::Integer) where S<: AbstractString = a[1:(length(a) > n ? n : end)] end diff --git a/src/displays.jl b/src/displays.jl index 6c82e270..6335a85b 100644 --- a/src/displays.jl +++ b/src/displays.jl @@ -77,6 +77,15 @@ function _show(io::IO, tree::LazyTree; kwargs...) ) nothing end + +# stop crazy stracktrace +function Base.show(io::IO, + ::Type{<:LazyTree{<:UnROOT.TypedTables.Table{NamedTuple{Ns, Vs}}}}) where {T, Ns, Vs} + elip = length(Ns) > 5 ? "..." : "" + println(io, "LazyTree with $(length(Ns)) branches:") + println(io, join(first(Ns, 5), ", "), elip) +end + function Base.show(io::IO, ::MIME"text/html", tree::LazyTree) _hs = _make_header(tree) maxrows = 10