Skip to content

Commit 61de82a

Browse files
authored
Fix missing coeftable method detection. (#252)
* fix error catching for missing coeftable in show * explicitly test 1.6 * patch bump * goodbye 1.0
1 parent 3099bec commit 61de82a

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
version:
20-
- '1.0'
20+
- '1.6'
2121
- '1' # automatically expands to the latest stable 1.x release of Julia
2222
os:
2323
- ubuntu-latest

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StatsModels"
22
uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
3-
version = "0.6.28"
3+
version = "0.6.29"
44

55
[deps]
66
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
@@ -23,7 +23,7 @@ ShiftedArrays = "1"
2323
StatsBase = "0.33.5"
2424
StatsFuns = "0.9"
2525
Tables = "0.2, 1"
26-
julia = "1"
26+
julia = "1.6"
2727

2828
[extras]
2929
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"

src/statsmodel.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const TableModels = Union{TableStatisticalModel, TableRegressionModel}
132132
StatsBase.stderror, StatsBase.vcov, StatsBase.fitted]
133133
@delegate TableRegressionModel.model [StatsBase.modelmatrix,
134134
StatsBase.residuals, StatsBase.response,
135-
StatsBase.predict, StatsBase.predict!,
135+
StatsBase.predict, StatsBase.predict!,
136136
StatsBase.cooksdistance]
137137
StatsBase.predict(m::TableRegressionModel, new_x::AbstractMatrix; kwargs...) =
138138
predict(m.model, new_x; kwargs...)
@@ -195,16 +195,15 @@ end
195195

196196
# show function that delegates to coeftable
197197
function Base.show(io::IO, model::TableModels)
198+
println(io, typeof(model))
199+
println(io)
200+
println(io, model.mf.f)
201+
println(io)
198202
try
199-
ct = coeftable(model)
200-
println(io, typeof(model))
201-
println(io)
202-
println(io, model.mf.f)
203-
println(io)
204203
println(io,"Coefficients:")
205-
show(io, ct)
204+
show(io, coeftable(model))
206205
catch e
207-
if isa(e, ErrorException) && occursin("coeftable is not defined", e.msg)
206+
if isa(e, MethodError) || isa(e, ErrorException) && occursin("coeftable is not defined", e.msg)
208207
show(io, model.model)
209208
else
210209
rethrow(e)

test/statsmodel.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ end
106106
StatsBase.fit(::Type{DummyModTwo}, ::Matrix, ::Vector) = DummyModTwo("hello!")
107107
Base.show(io::IO, m::DummyModTwo) = println(io, m.msg)
108108

109-
110109
@testset "stat model types" begin
111110

112111
## Test fitting
@@ -230,8 +229,8 @@ Base.show(io::IO, m::DummyModTwo) = println(io, m.msg)
230229
@test predict(m4, d[2:4, :]) == predict(m4)[2:4]
231230

232231
m2 = fit(DummyModTwo, f, d)
232+
# make sure show() still works when there is no coeftable method
233233
show(io, m2)
234-
235234
end
236235

237236
@testset "lrtest" begin

0 commit comments

Comments
 (0)