diff --git a/src/traits.jl b/src/traits.jl index 614daf53..9b566120 100644 --- a/src/traits.jl +++ b/src/traits.jl @@ -6,13 +6,6 @@ const DOC_UNKNOWN = "not overloaded the trait. " const DOC_ON_TYPE = "The value of the trait must depend only on the type of `algorithm`. " -DOC_ONLY_ONE(func) = - "Ordinarily, at most one of the following should be overloaded for given "* - "algorithm "* - "`LearnAPI.$(func)_scitype`, `LearnAPI.$(func)_type`, "* - "`LearnAPI.$(func)_observation_scitype`, "* - "`LearnAPI.$(func)_observation_type`." - const DOC_EXPLAIN_EACHOBS = """ @@ -82,7 +75,7 @@ value is non-empty. # New implementations -All new implementations must overload this trait. Here's a checklist for elements in the +All new implementations must implement this trait. Here's a checklist for elements in the return value: | expression | implementation compulsory? | include in returned tuple? | @@ -107,7 +100,6 @@ algorithm-specific ones. The LearnAPI.jl accessor functions are: $ACCESSOR_FUNCT (`LearnAPI.strip` is always included). """ -functions(::Any) = () functions() = ( :(LearnAPI.fit), :(LearnAPI.algorithm), @@ -196,8 +188,6 @@ tags() = [ "meta-algorithms" ] -const DOC_TAGS_LIST = join(map(d -> "`\"$d\"`", tags()), ", ") - """ LearnAPI.tags(algorithm) @@ -403,7 +393,7 @@ See also [`LearnAPI.target_observation_scitype`](@ref). # New implementations -Optional. The fallback return value is `Union{}`. $(DOC_ONLY_ONE(:fit)) +Optional. The fallback return value is `Union{}`. """ fit_observation_scitype(::Any) = Union{} diff --git a/test/accessor_functions.jl b/test/accessor_functions.jl new file mode 100644 index 00000000..f22e73bb --- /dev/null +++ b/test/accessor_functions.jl @@ -0,0 +1,4 @@ +using Test +using LearnAPI + +@test strip("junk") == "junk" diff --git a/test/fit_update.jl b/test/fit_update.jl new file mode 100644 index 00000000..aa783432 --- /dev/null +++ b/test/fit_update.jl @@ -0,0 +1,14 @@ +using Test +using LearnAPI + +struct Gander end + +LearnAPI.update(::Gander, data) = sum(data) +LearnAPI.update_features(::Gander, data) = prod(data) + +@testset "update, update_features slurping" begin + @test update(Gander(), 2, 3, 4) == 9 + @test update_features(Gander(), 2, 3, 4) == 24 +end + +true diff --git a/test/runtests.jl b/test/runtests.jl index 9af76002..9ef643f8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,8 @@ test_files = [ "tools.jl", "traits.jl", "clone.jl", + "fit_update.jl", + "accessor_functions.jl", "predict_transform.jl", "patterns/regression.jl", "patterns/static_algorithms.jl", diff --git a/test/traits.jl b/test/traits.jl index ab4cad1a..e6eaae45 100644 --- a/test/traits.jl +++ b/test/traits.jl @@ -44,6 +44,7 @@ small = SmallAlgorithm() @test LearnAPI.data_interface(small) == LearnAPI.RandomAccess() @test !(6 isa LearnAPI.fit_observation_scitype(small)) @test 6 isa LearnAPI.target_observation_scitype(small) +@test !LearnAPI.is_static(small) # DERIVED TRAITS