Skip to content

Commit 4b9bc5b

Browse files
committed
give LearnAPI.functions() a default
1 parent 5e60305 commit 4b9bc5b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/traits.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ functions() = (
115115
:(LearnAPI.transform),
116116
:(LearnAPI.inverse_transform),
117117
)
118+
functions(::Any) = ()
118119

119120
"""
120121
LearnAPI.kinds_of_proxy(learner)

test/patterns/static_algorithms.jl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using LearnAPI
2-
using LinearAlgebra
32
using Tables
43
import MLUtils
54
import DataFrames
@@ -71,7 +70,22 @@ end
7170
struct FancySelector
7271
names::Vector{Symbol}
7372
end
74-
FancySelector(; names=Symbol[]) = FancySelector(names) # LearnAPI.constructor defined later
73+
74+
"""
75+
FancySelector(; names=Symbol[])
76+
77+
Instantiate a feature selector that exposes the names of rejected features.
78+
79+
```julia
80+
learner = FancySelector(names=[:x, :w])
81+
X = DataFrames.DataFrame(rand(3, 4), [:x, :y, :z, :w])
82+
model = fit(learner) # no data arguments!
83+
transform(model, X) # mutates `model`
84+
@assert rejected(model) == [:y, :z]
85+
```
86+
87+
"""
88+
FancySelector(; names=Symbol[]) = FancySelector(names)
7589

7690
mutable struct FancySelectorFitted
7791
learner::FancySelector

0 commit comments

Comments
 (0)