Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve coverage #33

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
"""

Expand Down Expand Up @@ -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? |
Expand All @@ -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),
Expand Down Expand Up @@ -196,8 +188,6 @@ tags() = [
"meta-algorithms"
]

const DOC_TAGS_LIST = join(map(d -> "`\"$d\"`", tags()), ", ")

"""
LearnAPI.tags(algorithm)

Expand Down Expand Up @@ -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{}
Expand Down
4 changes: 4 additions & 0 deletions test/accessor_functions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using Test
using LearnAPI

@test strip("junk") == "junk"
14 changes: 14 additions & 0 deletions test/fit_update.jl
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions test/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading