Skip to content

Commit 83e56bf

Browse files
authored
Merge pull request #33 from JuliaAI/coverage
improve coverage
2 parents c1d4220 + 92e5e3b commit 83e56bf

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? |
@@ -107,7 +100,6 @@ algorithm-specific ones. The LearnAPI.jl accessor functions are: $ACCESSOR_FUNCT
107100
(`LearnAPI.strip` is always included).
108101
109102
"""
110-
functions(::Any) = ()
111103
functions() = (
112104
:(LearnAPI.fit),
113105
:(LearnAPI.algorithm),
@@ -196,8 +188,6 @@ tags() = [
196188
"meta-algorithms"
197189
]
198190

199-
const DOC_TAGS_LIST = join(map(d -> "`\"$d\"`", tags()), ", ")
200-
201191
"""
202192
LearnAPI.tags(algorithm)
203193
@@ -403,7 +393,7 @@ See also [`LearnAPI.target_observation_scitype`](@ref).
403393
404394
# New implementations
405395
406-
Optional. The fallback return value is `Union{}`. $(DOC_ONLY_ONE(:fit))
396+
Optional. The fallback return value is `Union{}`.
407397
408398
"""
409399
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
"predict_transform.jl",
810
"patterns/regression.jl",
911
"patterns/static_algorithms.jl",

test/traits.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ small = SmallAlgorithm()
4444
@test LearnAPI.data_interface(small) == LearnAPI.RandomAccess()
4545
@test !(6 isa LearnAPI.fit_observation_scitype(small))
4646
@test 6 isa LearnAPI.target_observation_scitype(small)
47+
@test !LearnAPI.is_static(small)
4748

4849
# DERIVED TRAITS
4950

0 commit comments

Comments
 (0)