Skip to content

Commit d0a592c

Browse files
committed
fixed dots alignment and spacing
tighter test bounds
1 parent 799adde commit d0a592c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/statmodels.jl

+10-8
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function show(io::IO, ct::CoefTable)
129129
end
130130

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

147147
# remove columns that do not fit on the screen
148148
maxcols = length(A)
149-
totwidth = sum(sum.(A)) + 2 * (length(A) - 1)+sepsize
150149
if maxcols < nc+1
151150
ncols = min(nc, maxcols)
152151
mat = mat[:, 1:ncols]
152+
mat = hcat(mat, [hdots for i in 1:nr])
153153
colnms = colnms[1:ncols]
154-
sepsize = length(hdots)+1
154+
sepsize = textwidth(hdots)+1
155155
else
156156
sepsize = 0
157157
end
158158

159159
# print table
160-
totwidth = sum(sum.(A)) + 2 * (length(A) - 1)+sepsize
160+
totwidth = sum(sum, A) + 2 * (maxcols - 1) + sepsize
161+
161162
println(io, repeat('', totwidth))
162163
print(io, repeat(' ', sum(A[1])))
163164
for j in 1:maxcols-1
164165
print(io, " ", lpad(colnms[j], sum(A[j+1])))
165166
end
166167
maxcols < nc+1 && print(io, lpad(hdots, sepsize))
167168
println(io, '\n', repeat('', totwidth))
168-
for i in 1:size(mat, 1)
169-
Base.print_matrix_row(io, mat, A, i, 1:size(mat, 2), " ")
170-
maxcols < nc+1 && print(io, lpad(hdots, sepsize))
171-
i != size(mat, 1) && println(io)
169+
m, n =size(mat)
170+
for i in 1:m
171+
Base.print_matrix_row(io, mat, A, i, 1:n, " ")
172+
maxcols < nc+1 && (i+4)%5 == 0 && print(io, lpad(hdots, sepsize))
173+
i != m && println(io)
172174
end
173175
print(io, '\n', repeat('', totwidth))
174176
nothing

test/statmodels.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ ct = CoefTable(m, ["Estimate", "Stderror", "df", "p"], [], 4)
8282
df = 0.2422083248151139, p = 0.4530583319523316)
8383
]
8484

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

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

0 commit comments

Comments
 (0)