diff --git a/src/schema.jl b/src/schema.jl index e45ff692..d05b0ad7 100644 --- a/src/schema.jl +++ b/src/schema.jl @@ -215,6 +215,11 @@ function concrete_term(t::Term, xs::AbstractArray, contrasts::AbstractContrasts) CategoricalTerm(t.sym, contrmat) end +# this catches early when someone provides `:x => DummyCoding` as a hint +function concrete_term(t::Term, xs::AbstractArray, ::Type{T}) where {T<:AbstractContrasts} + throw(ArgumentError("contrast types must be instantiated (use $T() instead of $T)")) +end + """ apply_schema(t, schema::StatsModels.Schema[, Mod::Type = Nothing]) diff --git a/test/contrasts.jl b/test/contrasts.jl index 1f508bd1..7758c187 100644 --- a/test/contrasts.jl +++ b/test/contrasts.jl @@ -198,7 +198,7 @@ # contrasts types must be instantiated (should throw ArgumentError, currently # MethodError on apply_schema) - @test_broken setcontrasts!(mf, x = DummyCoding) + @test_throws ArgumentError setcontrasts!(mf, x = DummyCoding) @testset "hypothesis coding" begin diff --git a/test/formula.jl b/test/formula.jl index 2d74509a..4e1a4b93 100644 --- a/test/formula.jl +++ b/test/formula.jl @@ -118,8 +118,9 @@ @formula(foo ~ bar + baz) # drop_term no longer checks for whether term is found... - @test_broken drop_term(@formula(foo ~ bar + baz), term(0)) - @test_broken drop_term(@formula(foo ~ bar + baz), term(:boz)) + f = @formula(foo ~ bar + baz) + @test drop_term(f, term(0)) == f + @test drop_term(f, term(:boz)) == f form = @formula(foo ~ 1 + bar + baz) @test form == @formula(foo ~ 1 + bar + baz)