Skip to content

Commit f1377e8

Browse files
committed
amazing new printing
due to sebastian
1 parent a083c82 commit f1377e8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/dynamicalsystem/dynamicalsystem.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,27 @@ paramname(p::AbstractArray) = string(p)
254254
paramname(p::Nothing) = repr(p)
255255
paramname(p) = nameof(typeof(p))
256256

257+
# Credit to Sebastian Pfitzner
258+
function printlimited(io, x; Δx = 0, Δy = 0)
259+
sz = displaysize(io)
260+
io2 = IOBuffer(); ctx = IOContext(io2, :limit => true, :compact => true,
261+
:displaysize => (sz[1]-Δy, sz[2]-Δx))
262+
Base.print_array(ctx, x)
263+
s = String(take!(io2))
264+
s = replace(s[2:end], " " => ", ")
265+
Base.print(io, "["*s*"]")
266+
end
267+
257268
function Base.show(io::IO, ds::DS)
258269
ps = 14
259270
text = summary(ds)
260-
u0 = get_state(ds)
271+
u0 = get_state(ds)'
261272

262273
ctx = IOContext(io, :limit => true, :compact => true, :displaysize => (10,50))
263274

264-
print(io, text*"\n")
265-
println(ctx, rpad(" state: ", ps), get_state(ds))
275+
println(io, text)
276+
prefix = rpad(" state: ", ps)
277+
print(io, prefix); printlimited(io, u0, Δx = length(prefix)); println()
266278
println(io, rpad(" e.o.m.: ", ps), eomstring(ds.f))
267279
println(io, rpad(" in-place? ", ps), isinplace(ds))
268280
println(io, rpad(" jacobian: ", ps), jacobianstring(ds)),

0 commit comments

Comments
 (0)