From 61114e89cc8a853fadf434361e60cd24783fa346 Mon Sep 17 00:00:00 2001 From: Dave Kleinschmidt Date: Fri, 13 Sep 2019 17:23:30 -0400 Subject: [PATCH 1/3] specialize lead/lag apply schema to Schema --- src/StatsModels.jl | 2 +- src/temporal_terms.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/StatsModels.jl b/src/StatsModels.jl index 02ac635a..642534c8 100644 --- a/src/StatsModels.jl +++ b/src/StatsModels.jl @@ -59,8 +59,8 @@ export include("traits.jl") include("contrasts.jl") include("terms.jl") -include("temporal_terms.jl") include("schema.jl") +include("temporal_terms.jl") include("formula.jl") include("modelframe.jl") include("statsmodel.jl") diff --git a/src/temporal_terms.jl b/src/temporal_terms.jl index 41611bdb..5a29ee24 100644 --- a/src/temporal_terms.jl +++ b/src/temporal_terms.jl @@ -26,7 +26,7 @@ struct LeadLagTerm{T<:AbstractTerm, F<:Union{typeof(lead), typeof(lag)}} <: Abst nsteps::Int end -function apply_schema(t::FunctionTerm{F}, sch, ctx::Type) where F<:Union{typeof(lead), typeof(lag)} +function apply_schema(t::FunctionTerm{F}, sch::Schema, ctx::Type) where F<:Union{typeof(lead), typeof(lag)} opname = string(nameof(F.instance)) if length(t.args_parsed) == 1 # lag(term) term_parsed = first(t.args_parsed) From 98bf20bd4b341cd3832ad17aa2ae66b44d7fe14c Mon Sep 17 00:00:00 2001 From: Dave Kleinschmidt Date: Fri, 27 Sep 2019 17:01:01 +0200 Subject: [PATCH 2/3] add test to detect ambiguities in StatsModels --- test/extension.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/extension.jl b/test/extension.jl index 10a56483..6fe90ace 100644 --- a/test/extension.jl +++ b/test/extension.jl @@ -93,4 +93,8 @@ end @testset "Fallback" begin @test_throws ArgumentError modelcols(DummyTerm(), (a=[1], )) end + + @testset "Ambiguity detection" begin + @test isempty(Test.detect_ambiguities(StatsModels)) + end end From fa779cc9c18469cbc5f74377531a6a4dd348d7c1 Mon Sep 17 00:00:00 2001 From: Dave Kleinschmidt Date: Sat, 28 Sep 2019 09:43:24 +0200 Subject: [PATCH 3/3] test ambiguities first, leave broken test in extensions adding additional methods in the extensions tests creates ambiguities :((( --- test/ambiguity.jl | 3 +++ test/extension.jl | 3 ++- test/runtests.jl | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 test/ambiguity.jl diff --git a/test/ambiguity.jl b/test/ambiguity.jl new file mode 100644 index 00000000..de9f10b8 --- /dev/null +++ b/test/ambiguity.jl @@ -0,0 +1,3 @@ +@testset "Ambiguity detection" begin + @test isempty(Test.detect_ambiguities(StatsModels)) +end diff --git a/test/extension.jl b/test/extension.jl index 6fe90ace..2f056928 100644 --- a/test/extension.jl +++ b/test/extension.jl @@ -95,6 +95,7 @@ end end @testset "Ambiguity detection" begin - @test isempty(Test.detect_ambiguities(StatsModels)) + # ambiguities are introduced by adding additional methods here + @test_broken isempty(Test.detect_ambiguities(StatsModels)) end end diff --git a/test/runtests.jl b/test/runtests.jl index 02713f1d..a39e0777 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,8 @@ using StatsBase using StatsModels: ContrastsMatrix -my_tests = ["formula.jl", +my_tests = ["ambiguity.jl", + "formula.jl", "terms.jl", "temporal_terms.jl", "schema.jl",