From 3d99e2122a0a1107c1dfa08636bebe9f8a93c9a2 Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 10:52:36 +0100 Subject: [PATCH 1/8] changes to PrettyTables printing --- Project.toml | 1 + src/TimeSeries.jl | 1 + src/timearray.jl | 189 +++++++-------------------------------------- test/timearray.jl | 190 +++++++++++++++++++++++----------------------- 4 files changed, 121 insertions(+), 260 deletions(-) diff --git a/Project.toml b/Project.toml index e8648813..7c19dd40 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "0.23.2" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" diff --git a/src/TimeSeries.jl b/src/TimeSeries.jl index 05d5e43e..01dafa70 100644 --- a/src/TimeSeries.jl +++ b/src/TimeSeries.jl @@ -9,6 +9,7 @@ using DocStringExtensions: SIGNATURES using RecipesBase using Reexport using Tables +import PrettyTables export TimeArray, AbstractTimeSeries, when, from, to, findwhen, timestamp, values, colnames, meta, head, tail, diff --git a/src/timearray.jl b/src/timearray.jl index 262f416d..68aa0efe 100644 --- a/src/timearray.jl +++ b/src/timearray.jl @@ -186,186 +186,49 @@ Base.eltype(::AbstractTimeSeries{T,1,D}) where {T,D} = Tuple{D,T} Base.eltype(::AbstractTimeSeries{T,2,D}) where {T,D} = Tuple{D,Vector{T}} ###### show ##################### +Base.summary(io::IO, ta::TimeArray) = show(io, ta) -@inline _showval(v::Any) = repr(v) -@inline _showval(v::Number) = string(v) -@inline _showval(v::AbstractFloat) = - ifelse(isnan(v), MISSING, string(round(v, digits=DECIMALS))) - -""" -calculate the paging - -``` -> using MarketData -> AAPL # this function will return `UnitRange{Int64}[1:9, 10:12]` -``` -""" -@inline function _showpages(dcol::Int, timewidth::Int, colwidth::Array{Int}) - ret = UnitRange{Int}[] - c = dcol - timewidth - 5 - last_i = 1 - for i in eachindex(colwidth) - w = colwidth[i] + 3 - if c - w < 0 - push!(ret, last_i:i-1) - # next page - c = dcol - timewidth - 5 - w - last_i = i - elseif i == length(colwidth) - push!(ret, last_i:i) - else - c -= w - end - end - ret -end - -function print_time_array(io::IO, ta::TimeArray{T}, short=false, allcols=false) where T - # summary line +function Base.show(io::IO, ta::TimeArray) nrow = size(values(ta), 1) ncol = size(values(ta), 2) - print(io, "$(nrow)×$(ncol) $(typeof(ta))") if nrow != 0 print(io, " $(timestamp(ta)[1]) to $(timestamp(ta)[end])") else # e.g. TimeArray(Date[], []) return end - - short && return - println(io) - - # calculate column widths - drow, dcol = displaysize(io) - res_row = 9 # number of reserved rows: summary line, label line ... etc - half_row = floor(Int, (drow - res_row) / 2) - add_row = (drow - res_row) % 2 - - if nrow > (drow - res_row) - tophalf = 1:(half_row + add_row) - bothalf = (nrow - half_row + 1):nrow - strs = _showval.(@view values(ta)[[tophalf; bothalf], :]) - ts = @view timestamp(ta)[[tophalf; bothalf]] - else - tophalf = 0 - bothalf = 0 - strs = _showval.(values(ta)) - ts = timestamp(ta) - end - - colwidth = maximum( - [textwidth.(string.(colnames(ta)))'; textwidth.(strs); fill(5, ncol)'], - dims = 1) - - # paging - spacetime = textwidth(string(ts[1])) - pages = _showpages(dcol, spacetime, colwidth) - - # print all columns? - if allcols - for p in pages - islastpage = p == last(pages) - _print_page(io, p, ta, - spacetime, colwidth, nrow, drow, res_row, tophalf, bothalf, - islastpage ? 1 : 2) - if length(pages) > 1 && !islastpage - print(io,"\n\n") - end - end - else - # print first page and omitted columns message - _print_page(io, pages[1], ta, - spacetime, colwidth, nrow, drow, res_row, tophalf, bothalf, - length(pages)) - - if length(pages) > 1 - pndtcols = last(last(pages)) - first(pages[2]) + 1 - println(io) - printstyled(io, lpad("$pndtcols columns omitted", dcol), color=:cyan) - end - end end +function Base.show(io::IO, ::MIME"text/plain", ta::TimeArray; allrows = !get(io, :limit, false), allcols = !get(io, :limit, false)) + nrow = size(values(ta), 1) + ncol = size(values(ta), 2) -""" - _print_page + show(io, ta) # summary line -Helper function to print a single page of the `TimeArray` -""" -function _print_page(io::IO, p::UnitRange{Int}, ta::TimeArray, spacetime, - colwidth, nrow, drow, res_row, tophalf, bothalf, pages) - - strs = _showval.(values(ta)) - ts = timestamp(ta) - last = pages > 1 ? "│\u22EF" : "│" - - # row label line - ## e.g. | Open | High | Low | Close | - print(io, "│", " "^(spacetime + 2)) - for (name, w) in zip(colnames(ta)[p], colwidth[p]) - print(io, "│ ", _rpad(name, w + 1)) - end - println(io, last) + nrow == 0 && return - ## e.g. ├───────┼───────┼───────┼────────┤ - print(io, "├", "─"^(spacetime + 2)) - for w in colwidth[p] - print(io, "┼", "─"^(w + 2)) - end - print(io, "┤") - - # timestamp and values line - if nrow > (drow - res_row) - - # print bottom part - for i in tophalf - println(io) - print(io, "│ ", ts[i], " ") - for j in p - print(io, "│ ", _rpad(strs[i, j], colwidth[j] + 1)) - end - print(io, i % 3 == 0 ? last : "│") - end - - # print vdots part - println(io) - print(io, "│ ", _rpad("\u22EE", spacetime + 1)) - for j in p - print(io, "│ ", _rpad("\u22EE", colwidth[j] + 1)) - end - # print(io, pages > 1 ? "│\u22F1" : "│") - print(io, "│") - - # print bottom part - for i in (length(bothalf) - 1):-1:0 - i = size(strs, 1) - i - println(io) - print(io, "│ ", ts[i], " ") - for j in p - print(io, "│ ", _rpad(strs[i, j], colwidth[j] + 1)) - end - print(io, i % 3 == 0 ? last : "│") - end + println(io) + if allcols && allrows + crop = :none + elseif allcols + crop = :vertical + elseif allrows + crop = :horizontal else - # print all rows - for i in 1:nrow - println(io) - print(io, "│ ", ts[i], " ") - for j in p - print(io, "│ ", _rpad(strs[i, j], colwidth[j] + 1)) - end - print(io, i % 3 == 0 ? last : "│") - end + crop = :both end -end - -Base.summary(io::IO, ta::TimeArray) = print_time_array(io, ta, true) - -Base.show(io::IO, ta::TimeArray) = - print_time_array(io, ta, false, get(io, :limit, true)) -Base.show(io::IO, ::MIME"text/plain", ta::TimeArray) = - print_time_array(io, ta, false, !get(io, :limit, false)) + data = hcat(timestamp(ta), values(ta)) + header = vcat("", string.(colnames(ta))) + PrettyTables.pretty_table(io, data; + header=header, + newline_at_end = false, + reserved_display_lines = 2, + row_label_alignment = :r, + header_alignment = :l, + crop, + ) +end ###### getindex ################# diff --git a/test/timearray.jl b/test/timearray.jl index 0379c27c..b38e32cd 100644 --- a/test/timearray.jl +++ b/test/timearray.jl @@ -502,27 +502,30 @@ end out = "500×1 $(disptype(cl)) 2000-01-03 to 2001-12-31" @test str == out end - show(io, "text/plain", cl) + show(IOContext(io, :limit => true), MIME("text/plain"), cl) let str = String(take!(io)) out = """500×1 $(disptype(cl)) 2000-01-03 to 2001-12-31 +┌────────────┬────────┐ │ │ Close │ ├────────────┼────────┤ │ 2000-01-03 │ 111.94 │ -│ 2000-01-04 │ 102.5 │ -│ 2000-01-05 │ 104.0 │ -│ 2000-01-06 │ 95.0 │ -│ 2000-01-07 │ 99.5 │ -│ 2000-01-10 │ 97.75 │ -│ 2000-01-11 │ 92.75 │ -│ 2000-01-12 │ 87.19 │ -│ ⋮ │ ⋮ │ -│ 2001-12-20 │ 20.67 │ -│ 2001-12-21 │ 21.0 │ -│ 2001-12-24 │ 21.36 │ -│ 2001-12-26 │ 21.49 │ -│ 2001-12-27 │ 22.07 │ -│ 2001-12-28 │ 22.43 │ -│ 2001-12-31 │ 21.9 │""" +│ 2000-01-04 │ 102.5 │ +│ 2000-01-05 │ 104.0 │ +│ 2000-01-06 │ 95.0 │ +│ 2000-01-07 │ 99.5 │ +│ 2000-01-10 │ 97.75 │ +│ 2000-01-11 │ 92.75 │ +│ 2000-01-12 │ 87.19 │ +│ 2000-01-13 │ 96.75 │ +│ 2000-01-14 │ 100.44 │ +│ 2000-01-18 │ 103.94 │ +│ 2000-01-19 │ 106.56 │ +│ 2000-01-20 │ 113.5 │ +│ 2000-01-21 │ 111.31 │ +│ 2000-01-24 │ 106.25 │ +│ ⋮ │ ⋮ │ +└────────────┴────────┘ + 485 rows omitted""" @test str == out end @@ -531,27 +534,30 @@ end out = "500×4 $(disptype(ohlc)) 2000-01-03 to 2001-12-31" @test str == out end - show(io, "text/plain", ohlc) + show(IOContext(io, :limit => true), MIME("text/plain"), ohlc) let str = String(take!(io)) out = """500×4 $(disptype(ohlc)) 2000-01-03 to 2001-12-31 +┌────────────┬────────┬────────┬────────┬────────┐ │ │ Open │ High │ Low │ Close │ ├────────────┼────────┼────────┼────────┼────────┤ -│ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ -│ 2000-01-04 │ 108.25 │ 110.62 │ 101.19 │ 102.5 │ -│ 2000-01-05 │ 103.75 │ 110.56 │ 103.0 │ 104.0 │ -│ 2000-01-06 │ 106.12 │ 107.0 │ 95.0 │ 95.0 │ -│ 2000-01-07 │ 96.5 │ 101.0 │ 95.5 │ 99.5 │ -│ 2000-01-10 │ 102.0 │ 102.25 │ 94.75 │ 97.75 │ -│ 2000-01-11 │ 95.94 │ 99.38 │ 90.5 │ 92.75 │ -│ 2000-01-12 │ 95.0 │ 95.5 │ 86.5 │ 87.19 │ -│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ -│ 2001-12-20 │ 21.4 │ 21.47 │ 20.62 │ 20.67 │ -│ 2001-12-21 │ 21.01 │ 21.54 │ 20.8 │ 21.0 │ -│ 2001-12-24 │ 20.9 │ 21.45 │ 20.9 │ 21.36 │ -│ 2001-12-26 │ 21.35 │ 22.3 │ 21.14 │ 21.49 │ -│ 2001-12-27 │ 21.58 │ 22.25 │ 21.58 │ 22.07 │ -│ 2001-12-28 │ 21.97 │ 23.0 │ 21.96 │ 22.43 │ -│ 2001-12-31 │ 22.51 │ 22.66 │ 21.83 │ 21.9 │""" +│ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ +│ 2000-01-04 │ 108.25 │ 110.62 │ 101.19 │ 102.5 │ +│ 2000-01-05 │ 103.75 │ 110.56 │ 103.0 │ 104.0 │ +│ 2000-01-06 │ 106.12 │ 107.0 │ 95.0 │ 95.0 │ +│ 2000-01-07 │ 96.5 │ 101.0 │ 95.5 │ 99.5 │ +│ 2000-01-10 │ 102.0 │ 102.25 │ 94.75 │ 97.75 │ +│ 2000-01-11 │ 95.94 │ 99.38 │ 90.5 │ 92.75 │ +│ 2000-01-12 │ 95.0 │ 95.5 │ 86.5 │ 87.19 │ +│ 2000-01-13 │ 94.48 │ 98.75 │ 92.5 │ 96.75 │ +│ 2000-01-14 │ 100.0 │ 102.25 │ 99.38 │ 100.44 │ +│ 2000-01-18 │ 101.0 │ 106.0 │ 100.44 │ 103.94 │ +│ 2000-01-19 │ 105.62 │ 108.75 │ 103.38 │ 106.56 │ +│ 2000-01-20 │ 115.5 │ 121.5 │ 113.5 │ 113.5 │ +│ 2000-01-21 │ 114.25 │ 114.25 │ 110.19 │ 111.31 │ +│ 2000-01-24 │ 108.44 │ 112.75 │ 105.12 │ 106.25 │ +│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ +└────────────┴────────┴────────┴────────┴────────┘ + 485 rows omitted""" @test str == out end @@ -559,70 +565,56 @@ end out = "8336×12 $(disptype(AAPL)) 1980-12-12 to 2013-12-31" @test str == out end - show(IOContext(io, :limit => false), AAPL) + show(IOContext(io, :limit => true), MIME("text/plain"), AAPL) let str = String(take!(io)) out = """8336×12 $(disptype(AAPL)) 1980-12-12 to 2013-12-31 -│ │ Open │ High │ Low │ Close │ Volume │ ExDividend │⋯ -├────────────┼────────┼────────┼────────┼────────┼───────────┼────────────┤ -│ 1980-12-12 │ 28.75 │ 28.88 │ 28.75 │ 28.75 │ 2.0939e6 │ 0.0 │ -│ 1980-12-15 │ 27.38 │ 27.38 │ 27.25 │ 27.25 │ 785200.0 │ 0.0 │ -│ 1980-12-16 │ 25.38 │ 25.38 │ 25.25 │ 25.25 │ 472000.0 │ 0.0 │⋯ -│ 1980-12-17 │ 25.88 │ 26.0 │ 25.88 │ 25.88 │ 385900.0 │ 0.0 │ -│ 1980-12-18 │ 26.62 │ 26.75 │ 26.62 │ 26.62 │ 327900.0 │ 0.0 │ -│ 1980-12-19 │ 28.25 │ 28.38 │ 28.25 │ 28.25 │ 217100.0 │ 0.0 │⋯ -│ 1980-12-22 │ 29.62 │ 29.75 │ 29.62 │ 29.62 │ 166800.0 │ 0.0 │ -│ 1980-12-23 │ 30.88 │ 31.0 │ 30.88 │ 30.88 │ 209600.0 │ 0.0 │ -│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ -│ 2013-12-20 │ 545.43 │ 551.61 │ 544.82 │ 549.02 │ 1.55862e7 │ 0.0 │ -│ 2013-12-23 │ 568.0 │ 570.72 │ 562.76 │ 570.09 │ 1.79038e7 │ 0.0 │⋯ -│ 2013-12-24 │ 569.89 │ 571.88 │ 566.03 │ 567.67 │ 5.9841e6 │ 0.0 │ -│ 2013-12-26 │ 568.1 │ 569.5 │ 563.38 │ 563.9 │ 7.286e6 │ 0.0 │ -│ 2013-12-27 │ 563.82 │ 564.41 │ 559.5 │ 560.09 │ 8.0673e6 │ 0.0 │⋯ -│ 2013-12-30 │ 557.46 │ 560.09 │ 552.32 │ 554.52 │ 9.0582e6 │ 0.0 │ -│ 2013-12-31 │ 554.17 │ 561.28 │ 554.0 │ 561.02 │ 7.9673e6 │ 0.0 │ - 5 columns omitted""" +┌────────────┬───────┬───────┬───────┬───────┬──────────┬────────────┬────────── +│ │ Open │ High │ Low │ Close │ Volume │ ExDividend │ SplitRa ⋯ +├────────────┼───────┼───────┼───────┼───────┼──────────┼────────────┼────────── +│ 1980-12-12 │ 28.75 │ 28.88 │ 28.75 │ 28.75 │ 2.0939e6 │ 0.0 │ ⋯ +│ 1980-12-15 │ 27.38 │ 27.38 │ 27.25 │ 27.25 │ 785200.0 │ 0.0 │ ⋯ +│ 1980-12-16 │ 25.38 │ 25.38 │ 25.25 │ 25.25 │ 472000.0 │ 0.0 │ ⋯ +│ 1980-12-17 │ 25.88 │ 26.0 │ 25.88 │ 25.88 │ 385900.0 │ 0.0 │ ⋯ +│ 1980-12-18 │ 26.62 │ 26.75 │ 26.62 │ 26.62 │ 327900.0 │ 0.0 │ ⋯ +│ 1980-12-19 │ 28.25 │ 28.38 │ 28.25 │ 28.25 │ 217100.0 │ 0.0 │ ⋯ +│ 1980-12-22 │ 29.62 │ 29.75 │ 29.62 │ 29.62 │ 166800.0 │ 0.0 │ ⋯ +│ 1980-12-23 │ 30.88 │ 31.0 │ 30.88 │ 30.88 │ 209600.0 │ 0.0 │ ⋯ +│ 1980-12-24 │ 32.5 │ 32.62 │ 32.5 │ 32.5 │ 214300.0 │ 0.0 │ ⋯ +│ 1980-12-26 │ 35.5 │ 35.62 │ 35.5 │ 35.5 │ 248100.0 │ 0.0 │ ⋯ +│ 1980-12-29 │ 36.0 │ 36.12 │ 36.0 │ 36.0 │ 415900.0 │ 0.0 │ ⋯ +│ 1980-12-30 │ 35.25 │ 35.25 │ 35.12 │ 35.12 │ 307500.0 │ 0.0 │ ⋯ +│ 1980-12-31 │ 34.25 │ 34.25 │ 34.12 │ 34.12 │ 159600.0 │ 0.0 │ ⋯ +│ 1981-01-02 │ 34.5 │ 34.75 │ 34.5 │ 34.5 │ 96700.0 │ 0.0 │ ⋯ +│ 1981-01-05 │ 33.88 │ 33.88 │ 33.75 │ 33.75 │ 159500.0 │ 0.0 │ ⋯ +│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ ⋱ +└────────────┴───────┴───────┴───────┴───────┴──────────┴────────────┴────────── + 6 columns and 8321 rows omitted""" @test str == out end - show(io, "text/plain", AAPL) + show(IOContext(io, :limit => true), MIME("text/plain"), AAPL; allcols=true) let str = String(take!(io)) out = """8336×12 $(disptype(AAPL)) 1980-12-12 to 2013-12-31 -│ │ Open │ High │ Low │ Close │ Volume │ ExDividend │⋯ -├────────────┼────────┼────────┼────────┼────────┼───────────┼────────────┤ -│ 1980-12-12 │ 28.75 │ 28.88 │ 28.75 │ 28.75 │ 2.0939e6 │ 0.0 │ -│ 1980-12-15 │ 27.38 │ 27.38 │ 27.25 │ 27.25 │ 785200.0 │ 0.0 │ -│ 1980-12-16 │ 25.38 │ 25.38 │ 25.25 │ 25.25 │ 472000.0 │ 0.0 │⋯ -│ 1980-12-17 │ 25.88 │ 26.0 │ 25.88 │ 25.88 │ 385900.0 │ 0.0 │ -│ 1980-12-18 │ 26.62 │ 26.75 │ 26.62 │ 26.62 │ 327900.0 │ 0.0 │ -│ 1980-12-19 │ 28.25 │ 28.38 │ 28.25 │ 28.25 │ 217100.0 │ 0.0 │⋯ -│ 1980-12-22 │ 29.62 │ 29.75 │ 29.62 │ 29.62 │ 166800.0 │ 0.0 │ -│ 1980-12-23 │ 30.88 │ 31.0 │ 30.88 │ 30.88 │ 209600.0 │ 0.0 │ -│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ -│ 2013-12-20 │ 545.43 │ 551.61 │ 544.82 │ 549.02 │ 1.55862e7 │ 0.0 │ -│ 2013-12-23 │ 568.0 │ 570.72 │ 562.76 │ 570.09 │ 1.79038e7 │ 0.0 │⋯ -│ 2013-12-24 │ 569.89 │ 571.88 │ 566.03 │ 567.67 │ 5.9841e6 │ 0.0 │ -│ 2013-12-26 │ 568.1 │ 569.5 │ 563.38 │ 563.9 │ 7.286e6 │ 0.0 │ -│ 2013-12-27 │ 563.82 │ 564.41 │ 559.5 │ 560.09 │ 8.0673e6 │ 0.0 │⋯ -│ 2013-12-30 │ 557.46 │ 560.09 │ 552.32 │ 554.52 │ 9.0582e6 │ 0.0 │ -│ 2013-12-31 │ 554.17 │ 561.28 │ 554.0 │ 561.02 │ 7.9673e6 │ 0.0 │ - -│ │ SplitRatio │ AdjOpen │ AdjHigh │ AdjLow │ AdjClose │ -├────────────┼────────────┼──────────┼──────────┼──────────┼──────────┤ -│ 1980-12-12 │ 1.0 │ 3.3766 │ 3.3919 │ 3.3766 │ 3.3766 │ -│ 1980-12-15 │ 1.0 │ 3.2157 │ 3.2157 │ 3.2004 │ 3.2004 │ -│ 1980-12-16 │ 1.0 │ 2.9808 │ 2.9808 │ 2.9655 │ 2.9655 │ -│ 1980-12-17 │ 1.0 │ 3.0395 │ 3.0536 │ 3.0395 │ 3.0395 │ -│ 1980-12-18 │ 1.0 │ 3.1264 │ 3.1417 │ 3.1264 │ 3.1264 │ -│ 1980-12-19 │ 1.0 │ 3.3179 │ 3.3331 │ 3.3179 │ 3.3179 │ -│ 1980-12-22 │ 1.0 │ 3.4788 │ 3.494 │ 3.4788 │ 3.4788 │ -│ 1980-12-23 │ 1.0 │ 3.6267 │ 3.6408 │ 3.6267 │ 3.6267 │ -│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ -│ 2013-12-20 │ 1.0 │ 542.2033 │ 548.3467 │ 541.5969 │ 545.7721 │ -│ 2013-12-23 │ 1.0 │ 564.6398 │ 567.3437 │ 559.4308 │ 566.7174 │ -│ 2013-12-24 │ 1.0 │ 566.5186 │ 568.4968 │ 562.6814 │ 564.3117 │ -│ 2013-12-26 │ 1.0 │ 564.7392 │ 566.1309 │ 560.0471 │ 560.564 │ -│ 2013-12-27 │ 1.0 │ 560.4845 │ 561.071 │ 556.1901 │ 556.7766 │ -│ 2013-12-30 │ 1.0 │ 554.1621 │ 556.7766 │ 549.0525 │ 551.2395 │ -│ 2013-12-31 │ 1.0 │ 550.8916 │ 557.9595 │ 550.7226 │ 557.7011 │""" +┌────────────┬───────┬───────┬───────┬───────┬──────────┬────────────┬────────────┬─────────┬─────────┬─────────┬──────────┬───────────┐ +│ │ Open │ High │ Low │ Close │ Volume │ ExDividend │ SplitRatio │ AdjOpen │ AdjHigh │ AdjLow │ AdjClose │ AdjVolume │ +├────────────┼───────┼───────┼───────┼───────┼──────────┼────────────┼────────────┼─────────┼─────────┼─────────┼──────────┼───────────┤ +│ 1980-12-12 │ 28.75 │ 28.88 │ 28.75 │ 28.75 │ 2.0939e6 │ 0.0 │ 1.0 │ 3.37658 │ 3.39185 │ 3.37658 │ 3.37658 │ 1.67512e7 │ +│ 1980-12-15 │ 27.38 │ 27.38 │ 27.25 │ 27.25 │ 785200.0 │ 0.0 │ 1.0 │ 3.21568 │ 3.21568 │ 3.20041 │ 3.20041 │ 6.2816e6 │ +│ 1980-12-16 │ 25.38 │ 25.38 │ 25.25 │ 25.25 │ 472000.0 │ 0.0 │ 1.0 │ 2.98079 │ 2.98079 │ 2.96552 │ 2.96552 │ 3.776e6 │ +│ 1980-12-17 │ 25.88 │ 26.0 │ 25.88 │ 25.88 │ 385900.0 │ 0.0 │ 1.0 │ 3.03951 │ 3.05361 │ 3.03951 │ 3.03951 │ 3.0872e6 │ +│ 1980-12-18 │ 26.62 │ 26.75 │ 26.62 │ 26.62 │ 327900.0 │ 0.0 │ 1.0 │ 3.12642 │ 3.14169 │ 3.12642 │ 3.12642 │ 2.6232e6 │ +│ 1980-12-19 │ 28.25 │ 28.38 │ 28.25 │ 28.25 │ 217100.0 │ 0.0 │ 1.0 │ 3.31786 │ 3.33313 │ 3.31786 │ 3.31786 │ 1.7368e6 │ +│ 1980-12-22 │ 29.62 │ 29.75 │ 29.62 │ 29.62 │ 166800.0 │ 0.0 │ 1.0 │ 3.47876 │ 3.49403 │ 3.47876 │ 3.47876 │ 1.3344e6 │ +│ 1980-12-23 │ 30.88 │ 31.0 │ 30.88 │ 30.88 │ 209600.0 │ 0.0 │ 1.0 │ 3.62674 │ 3.64084 │ 3.62674 │ 3.62674 │ 1.6768e6 │ +│ 1980-12-24 │ 32.5 │ 32.62 │ 32.5 │ 32.5 │ 214300.0 │ 0.0 │ 1.0 │ 3.81701 │ 3.8311 │ 3.81701 │ 3.81701 │ 1.7144e6 │ +│ 1980-12-26 │ 35.5 │ 35.62 │ 35.5 │ 35.5 │ 248100.0 │ 0.0 │ 1.0 │ 4.16935 │ 4.18344 │ 4.16935 │ 4.16935 │ 1.9848e6 │ +│ 1980-12-29 │ 36.0 │ 36.12 │ 36.0 │ 36.0 │ 415900.0 │ 0.0 │ 1.0 │ 4.22807 │ 4.24216 │ 4.22807 │ 4.22807 │ 3.3272e6 │ +│ 1980-12-30 │ 35.25 │ 35.25 │ 35.12 │ 35.12 │ 307500.0 │ 0.0 │ 1.0 │ 4.13998 │ 4.13998 │ 4.12472 │ 4.12472 │ 2.46e6 │ +│ 1980-12-31 │ 34.25 │ 34.25 │ 34.12 │ 34.12 │ 159600.0 │ 0.0 │ 1.0 │ 4.02254 │ 4.02254 │ 4.00727 │ 4.00727 │ 1.2768e6 │ +│ 1981-01-02 │ 34.5 │ 34.75 │ 34.5 │ 34.5 │ 96700.0 │ 0.0 │ 1.0 │ 4.0519 │ 4.08126 │ 4.0519 │ 4.0519 │ 773600.0 │ +│ 1981-01-05 │ 33.88 │ 33.88 │ 33.75 │ 33.75 │ 159500.0 │ 0.0 │ 1.0 │ 3.97908 │ 3.97908 │ 3.96382 │ 3.96382 │ 1.276e6 │ +│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ +└────────────┴───────┴───────┴───────┴───────┴──────────┴────────────┴────────────┴─────────┴─────────┴─────────┴──────────┴───────────┘ + 8321 rows omitted""" @test str == out end @@ -633,12 +625,14 @@ end show(io, "text/plain", ohlc[1:4]) let str = String(take!(io)) out = """4×4 $(disptype(ohlc[1:4])) 2000-01-03 to 2000-01-06 +┌────────────┬────────┬────────┬────────┬────────┐ │ │ Open │ High │ Low │ Close │ ├────────────┼────────┼────────┼────────┼────────┤ -│ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ -│ 2000-01-04 │ 108.25 │ 110.62 │ 101.19 │ 102.5 │ -│ 2000-01-05 │ 103.75 │ 110.56 │ 103.0 │ 104.0 │ -│ 2000-01-06 │ 106.12 │ 107.0 │ 95.0 │ 95.0 │""" +│ 2000-01-03 │ 104.88 │ 112.5 │ 101.69 │ 111.94 │ +│ 2000-01-04 │ 108.25 │ 110.62 │ 101.19 │ 102.5 │ +│ 2000-01-05 │ 103.75 │ 110.56 │ 103.0 │ 104.0 │ +│ 2000-01-06 │ 106.12 │ 107.0 │ 95.0 │ 95.0 │ +└────────────┴────────┴────────┴────────┴────────┘""" @test str == out end @@ -670,10 +664,12 @@ end show(io, "text/plain", lag(cl[1:2], padding=true)) let str = String(take!(io)) out = """2×1 $(disptype(lag(cl[1:2], padding=true))) 2000-01-03 to 2000-01-04 +┌────────────┬────────┐ │ │ Close │ ├────────────┼────────┤ -│ 2000-01-03 │ NaN │ -│ 2000-01-04 │ 111.94 │""" +│ 2000-01-03 │ NaN │ +│ 2000-01-04 │ 111.94 │ +└────────────┴────────┘""" @test str == out end end # @testset "show methods don't throw errors" From 5ba222b8de66224497dbc8c90ca65acb1cd87e22 Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 11:02:33 +0100 Subject: [PATCH 2/8] compat --- Project.toml | 1 + src/timearray.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7c19dd40..d9f4cfb4 100644 --- a/Project.toml +++ b/Project.toml @@ -22,6 +22,7 @@ Reexport = "1" Statistics = "1" Tables = "1" julia = "1" +PrettyTables = "2" [extras] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" diff --git a/src/timearray.jl b/src/timearray.jl index 68aa0efe..48fe1f13 100644 --- a/src/timearray.jl +++ b/src/timearray.jl @@ -226,7 +226,7 @@ function Base.show(io::IO, ::MIME"text/plain", ta::TimeArray; allrows = !get(io reserved_display_lines = 2, row_label_alignment = :r, header_alignment = :l, - crop, + crop=crop, ) end From 7a2a42ab7a4325a3c50ffc963d73d1d059587f2b Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 11:09:06 +0100 Subject: [PATCH 3/8] compat --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index d9f4cfb4..7334c6e7 100644 --- a/Project.toml +++ b/Project.toml @@ -22,7 +22,7 @@ Reexport = "1" Statistics = "1" Tables = "1" julia = "1" -PrettyTables = "2" +PrettyTables = "1, 2" [extras] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" From d7b9c4c8a3f07fec369f7d07d5290ac58e36bcbe Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 11:46:46 +0100 Subject: [PATCH 4/8] changes LTS version --- .github/workflows/CI.yml | 4 ++-- Project.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ee937bce..c8e23fba 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,8 +15,8 @@ jobs: fail-fast: false matrix: version: - - "1.0" # LTS - - "1.5" + - "1.6.7" # LTS + - "1.6" - "1" # Latest Release os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 7334c6e7..93768a48 100644 --- a/Project.toml +++ b/Project.toml @@ -21,8 +21,8 @@ RecipesBase = "0.5, 0.7, 0.8, 1.0" Reexport = "1" Statistics = "1" Tables = "1" -julia = "1" -PrettyTables = "1, 2" +julia = "1.6" +PrettyTables = "2" [extras] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" From ef442c73f2fb59e9de39fb6d8c19fac41c55b1b2 Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 11:54:51 +0100 Subject: [PATCH 5/8] compat Documenter.jl --- docs/Project.toml | 2 +- docs/make.jl | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 7f279df2..dc219c72 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -7,4 +7,4 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" [compat] -Documenter = "~0.24" +Documenter = "1" diff --git a/docs/make.jl b/docs/make.jl index 24a5a651..a632a645 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -3,10 +3,10 @@ using TimeSeries makedocs( - format = Documenter.HTML(), - sitename = "TimeSeries.jl", - modules = [TimeSeries], - pages = [ + format=Documenter.HTML(; prettyurls=(get(ENV, "CI", nothing) == "true")), + sitename="TimeSeries.jl", + modules=[TimeSeries], + pages=[ "index.md", "getting_started.md", "timearray.md", @@ -24,7 +24,7 @@ makedocs( ) deploydocs( - repo = "github.com/JuliaStats/TimeSeries.jl.git", - devbranch = "master", - push_preview = true, + repo="github.com/JuliaStats/TimeSeries.jl.git", + devbranch="master", + push_preview=true, ) From 35a757c3e8cd9f3e0bd64ec38cf29ed29d33123b Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 14:00:48 +0100 Subject: [PATCH 6/8] updates version --- .github/workflows/CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c8e23fba..2f19f766 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,7 +25,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/setup-julia@latest with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} @@ -54,9 +54,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/setup-julia@latest with: - version: '1.5' + version: '1' - run: | git config --global user.name name git config --global user.email email From fea5ff41cea6f79168d7906082c78aaed1d36a7a Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Wed, 15 Nov 2023 14:12:25 +0100 Subject: [PATCH 7/8] do not error on doc build --- docs/make.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/make.jl b/docs/make.jl index a632a645..7a944d29 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,6 +6,7 @@ makedocs( format=Documenter.HTML(; prettyurls=(get(ENV, "CI", nothing) == "true")), sitename="TimeSeries.jl", modules=[TimeSeries], + warnonly=true, # some docstrings are not in the manual pages=[ "index.md", "getting_started.md", From 76da9a26aa693ce468f6f12d389965e8cfd18cd8 Mon Sep 17 00:00:00 2001 From: Valentin Kaisermayer Date: Fri, 17 Nov 2023 15:50:20 +0100 Subject: [PATCH 8/8] switch to using --- src/TimeSeries.jl | 2 +- src/timearray.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TimeSeries.jl b/src/TimeSeries.jl index 01dafa70..727e3be2 100644 --- a/src/TimeSeries.jl +++ b/src/TimeSeries.jl @@ -9,7 +9,7 @@ using DocStringExtensions: SIGNATURES using RecipesBase using Reexport using Tables -import PrettyTables +using PrettyTables: pretty_table export TimeArray, AbstractTimeSeries, when, from, to, findwhen, timestamp, values, colnames, meta, head, tail, diff --git a/src/timearray.jl b/src/timearray.jl index 48fe1f13..09da43e7 100644 --- a/src/timearray.jl +++ b/src/timearray.jl @@ -220,7 +220,7 @@ function Base.show(io::IO, ::MIME"text/plain", ta::TimeArray; allrows = !get(io data = hcat(timestamp(ta), values(ta)) header = vcat("", string.(colnames(ta))) - PrettyTables.pretty_table(io, data; + pretty_table(io, data; header=header, newline_at_end = false, reserved_display_lines = 2,