Skip to content

Commit

Permalink
Update PrettyTables to v0.12 (#2715)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronisbr authored Apr 12, 2021
1 parent 049e32c commit 397dfa4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ InvertedIndices = "1"
IteratorInterfaceExtensions = "0.1.1, 1"
Missings = "0.4.2"
PooledArrays = "1.2.1"
PrettyTables = "0.11"
PrettyTables = "0.12"
Reexport = "0.1, 0.2, 1.0"
SortingAlgorithms = "0.1, 0.2, 0.3"
TableTraits = "0.4, 1"
Expand Down
14 changes: 7 additions & 7 deletions src/abstractdataframe/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,14 @@ function _show(io::IO,

_check_consistency(df)

aux = names(df)
names_len = textwidth.(aux)
names_str = names(df)
names_len = textwidth.(names_str)
maxwidth = max.(9, names_len)
names_mat = permutedims(aux)
types = eltype.(eachcol(df))

# NOTE: If we reuse `types` here, the time to print the first table is 2x more.
# This should be something related to type inference.
types_str = permutedims(compacttype.(eltype.(eachcol(df)), maxwidth))
# NOTE: If we reuse `types` here, the time to print the first table is 2x
# more. This should be something related to type inference.
types_str = compacttype.(eltype.(eachcol(df)), maxwidth)

if allcols && allrows
crop = :none
Expand Down Expand Up @@ -302,7 +301,7 @@ function _show(io::IO,
end

# Print the table with the selected options.
pretty_table(io, df, vcat(names_mat, types_str);
pretty_table(io, df;
alignment = alignment,
alignment_anchor_fallback = :r,
alignment_anchor_regex = alignment_anchor_regex,
Expand All @@ -311,6 +310,7 @@ function _show(io::IO,
crop_num_lines_at_beginning = 2,
ellipsis_line_skip = 3,
formatters = (_pretty_tables_general_formatter,),
header = (names_str, types_str),
header_alignment = :l,
hlines = [:header],
highlighters = (_PRETTY_TABLES_HIGHLIGHTER,),
Expand Down
3 changes: 1 addition & 2 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ end
│ Int64 Int64 Int64 Int64 Int64
─────┼──────────────────────────────────────────────────
1 │ 10000001 10000026 10000051 10000076 10000101
2 │ 10000002 10000027 10000052 10000077 10000102
⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮
25 │ 10000025 10000050 10000075 10000100 10000125
22 rows omitted"""
23 rows omitted"""

io = IOContext(IOBuffer(), :displaysize=>(11, 40), :limit=>true)
show(io, df_big, allrows=true, allcols=true)
Expand Down

0 comments on commit 397dfa4

Please sign in to comment.