From 1b55392a91dc903671c6b30cafaa38c723704dc8 Mon Sep 17 00:00:00 2001 From: Weicheng-mac Date: Fri, 23 Sep 2016 13:46:10 -0500 Subject: [PATCH] update List show method --- src/List.jl | 17 ++++++++++------- test/Listtest.jl | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/List.jl b/src/List.jl index 66fbff4..71a565b 100644 --- a/src/List.jl +++ b/src/List.jl @@ -142,21 +142,24 @@ List(A::Matrix)=convert(List, A) List(df::DataFrames.AbstractDataFrame) = convert(List, df) function show(io::IO, d::List) - print(io, showindent(d)) + showindent(io, d) end -function showindent(d::List, indent::String="") + +function showindent(io::IO, d::List, indent::String="") k = _names(d.colindex) - res=sprint(println, indent, "$(length(d)) elements List:") + println(io, indent, "$(length(d)) elements List:") for i in 1:length(d.columns) - res*=sprint(println, indent, "[$i] ", k[i], ": ") + println(io, indent, "[$i] ", k[i], ": ") if isa(d.columns[i], List) indent2 = indent*" " - res*=sprint(println, indent, showindent(d.columns[i], indent2)) + print(io, indent) + showindent(io, d.columns[i], indent2) else - res*=sprint(println, indent, " ", d.columns[i]) + print(io, indent, " ") + show(io, d.columns[i]) + println(io) end end - res end index(df::List) = df.colindex diff --git a/test/Listtest.jl b/test/Listtest.jl index 13fe026..8af91fc 100644 --- a/test/Listtest.jl +++ b/test/Listtest.jl @@ -1,6 +1,6 @@ using DataFrames, StatsBase -li = list(x=rand(10), y = rand(Int, 2,3), df = DataFrame(rand(5,2)), +li = list(x=rand(100), y = rand(Int, 2,3), df = DataFrame(rand(5,2)), fa = pool(sample([true, false], 100))) li2 = merge(li, list(f1=*, f2=-))