Skip to content

Commit d4546c3

Browse files
committed
improve coverage
1 parent a33bea4 commit d4546c3

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

src/traits.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ const DOC_UNKNOWN =
66
"not overloaded the trait. "
77
const DOC_ON_TYPE = "The value of the trait must depend only on the type of `algorithm`. "
88

9-
DOC_ONLY_ONE(func) =
10-
"Ordinarily, at most one of the following should be overloaded for given "*
11-
"algorithm "*
12-
"`LearnAPI.$(func)_scitype`, `LearnAPI.$(func)_type`, "*
13-
"`LearnAPI.$(func)_observation_scitype`, "*
14-
"`LearnAPI.$(func)_observation_type`."
15-
169
const DOC_EXPLAIN_EACHOBS =
1710
"""
1811
@@ -82,7 +75,7 @@ value is non-empty.
8275
8376
# New implementations
8477
85-
All new implementations must overload this trait. Here's a checklist for elements in the
78+
All new implementations must implement this trait. Here's a checklist for elements in the
8679
return value:
8780
8881
| expression | implementation compulsory? | include in returned tuple? |
@@ -106,7 +99,6 @@ Also include any implemented accessor functions, both those owned by LearnaAPI.j
10699
algorithm-specific ones. The LearnAPI.jl accessor functions are: $ACCESSOR_FUNCTIONS_LIST.
107100
108101
"""
109-
functions(::Any) = ()
110102
functions() = (
111103
:(LearnAPI.fit),
112104
:(LearnAPI.algorithm),
@@ -195,8 +187,6 @@ tags() = [
195187
"meta-algorithms"
196188
]
197189

198-
const DOC_TAGS_LIST = join(map(d -> "`\"$d\"`", tags()), ", ")
199-
200190
"""
201191
LearnAPI.tags(algorithm)
202192
@@ -402,7 +392,7 @@ See also [`LearnAPI.target_observation_scitype`](@ref).
402392
403393
# New implementations
404394
405-
Optional. The fallback return value is `Union{}`. $(DOC_ONLY_ONE(:fit))
395+
Optional. The fallback return value is `Union{}`.
406396
407397
"""
408398
fit_observation_scitype(::Any) = Union{}

test/accessor_functions.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using Test
2+
using LearnAPI
3+
4+
@test strip("junk") == "junk"

test/fit_update.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Test
2+
using LearnAPI
3+
4+
struct Gander end
5+
6+
LearnAPI.update(::Gander, data) = sum(data)
7+
LearnAPI.update_features(::Gander, data) = prod(data)
8+
9+
@testset "update, update_features slurping" begin
10+
@test update(Gander(), 2, 3, 4) == 9
11+
@test update_features(Gander(), 2, 3, 4) == 24
12+
end
13+
14+
true

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ test_files = [
44
"tools.jl",
55
"traits.jl",
66
"clone.jl",
7+
"fit_update.jl",
8+
"accessor_functions.jl",
79
"integration/regression.jl",
810
"integration/static_algorithms.jl",
911
"integration/ensembling.jl",

test/traits.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ small = SmallAlgorithm()
4141
@test LearnAPI.data_interface(small) == LearnAPI.RandomAccess()
4242
@test !(6 isa LearnAPI.fit_observation_scitype(small))
4343
@test 6 isa LearnAPI.target_observation_scitype(small)
44+
@test !LearnAPI.is_static(small)
4445

4546
# DERIVED TRAITS
4647

0 commit comments

Comments
 (0)