Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix size of float columns without eltypes #2542

Merged
merged 2 commits into from
Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/abstractdataframe/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function _show(io::IO,
# Check if we need additional left padding to right align the values
# in the cell. This can happen if the header length is larger than
# the values at the cells.
header_size = max(names_len[i], textwidth(types_str[i]))
header_size = max(names_len[i], eltypes ? textwidth(types_str[i]) : 0)
lpad = header_size - (align_col_i + max_size_after_align_col)
lpad > 0 && (align_col_i += lpad)

Expand Down
35 changes: 35 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,41 @@ end
14 │ 1.0e6 14 true 1.0e6 1.0e6
15 │ 1.0e7 15 false 1.0e7 1.0e7"""


io = IOBuffer()
show(io, df, eltypes = false)
str = String(take!(io))
@test str == """
15×5 DataFrame
Row │ a b c d e
─────┼────────────────────────────────────────────────
1 │ 1.0e-7 1 false 1.0e-7 1.0e-7
2 │ 1.0e-6 2 true 1.0e-6 1.0e-6
3 │ 1.0e-5 3 false 1.0e-5 1.0e-5
4 │ 0.0001 4 true 0.0001 0.0001
5 │ 0.001 5 false 0.001 0.001
6 │ 0.01 6 true 0.01 0.01
7 │ 0.1 7 false 0.1 0.1
8 │ 1.0 8 true 1.0 1.0
9 │ 10.0 9 false 10.0 10.0
10 │ missing 10 true test -0.0
11 │ 1000.0 11 false 1000.0 0.0
12 │ 10000.0 12 true 10000.0 10000.0
13 │ 100000.0 13 false 100000.0 100000.0
14 │ 1.0e6 14 true 1.0e6 1.0e6
15 │ 1.0e7 15 false 1.0e7 1.0e7"""

df = DataFrame(This_is_a_very_big_name = 1.0, b = 2.0, c = 3.0)

io = IOBuffer()
show(io, df, eltypes = false)
str = String(take!(io))
@test str == """
1×3 DataFrame
Row │ This_is_a_very_big_name b c
─────┼───────────────────────────────────
1 │ 1.0 2.0 3.0"""

df = DataFrame(This_is_a_very_big_name = [10.0^i for i = -5:1:5],
This_is_smaller = 1.0:2:22,
T = 100001:1.:100011)
Expand Down