Skip to content

Commit

Permalink
fixed dots alignment and spacing
Browse files Browse the repository at this point in the history
tighter test bounds
  • Loading branch information
wildart committed Sep 4, 2022
1 parent 799adde commit d0a592c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/statmodels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function show(io::IO, ct::CoefTable)
end

sepsize = 3
hdots = " \u2026 "
hdots = " "
mat = [j == 1 ? NoQuote(rownms[i]) :
j-1 == ct.pvalcol ? NoQuote(sprint(show, PValue(cols[j-1][i]))) :
j-1 in ct.teststatcol ? TestStat(cols[j-1][i]) :
Expand All @@ -146,29 +146,31 @@ function show(io::IO, ct::CoefTable)

# remove columns that do not fit on the screen
maxcols = length(A)
totwidth = sum(sum.(A)) + 2 * (length(A) - 1)+sepsize
if maxcols < nc+1
ncols = min(nc, maxcols)
mat = mat[:, 1:ncols]
mat = hcat(mat, [hdots for i in 1:nr])
colnms = colnms[1:ncols]
sepsize = length(hdots)+1
sepsize = textwidth(hdots)+1
else
sepsize = 0
end

# print table
totwidth = sum(sum.(A)) + 2 * (length(A) - 1)+sepsize
totwidth = sum(sum, A) + 2 * (maxcols - 1) + sepsize

println(io, repeat('', totwidth))
print(io, repeat(' ', sum(A[1])))
for j in 1:maxcols-1
print(io, " ", lpad(colnms[j], sum(A[j+1])))
end
maxcols < nc+1 && print(io, lpad(hdots, sepsize))
println(io, '\n', repeat('', totwidth))
for i in 1:size(mat, 1)
Base.print_matrix_row(io, mat, A, i, 1:size(mat, 2), " ")
maxcols < nc+1 && print(io, lpad(hdots, sepsize))
i != size(mat, 1) && println(io)
m, n =size(mat)
for i in 1:m
Base.print_matrix_row(io, mat, A, i, 1:n, " ")
maxcols < nc+1 && (i+4)%5 == 0 && print(io, lpad(hdots, sepsize))
i != m && println(io)
end
print(io, '\n', repeat('', totwidth))
nothing
Expand Down
6 changes: 3 additions & 3 deletions test/statmodels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ ct = CoefTable(m, ["Estimate", "Stderror", "df", "p"], [], 4)
df = 0.2422083248151139, p = 0.4530583319523316)
]

ct = CoefTable(rand(1,100), ["c$i" for i in 1:100], [], 4)
ct = CoefTable(rand(15,100), ["c$i" for i in 1:100], [], 4)
sct = sprint(show, ct, context=:limit=>false)
@test length(first(split(sct, '\n'))) > 900
@test textwidth(first(split(sct, '\n'))) > 900
sct = sprint(show, ct, context=:limit=>true)
@test length(first(split(sct, '\n'))) < 200
@test textwidth(first(split(sct, '\n'))) <= displaysize()[2]

@test sprint(show, PValue(1.0)) == "1.0000"
@test sprint(show, PValue(1e-1)) == "0.1000"
Expand Down

0 comments on commit d0a592c

Please sign in to comment.