Skip to content

Commit 66207bc

Browse files
authored
Add stub for categorical (#13)
1 parent b5cb164 commit 66207bc

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MLJModelInterface"
22
uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
33
authors = ["Thibaut Lienart and Anthony Blaom"]
4-
version = "0.1.4"
4+
version = "0.1.5"
55

66
[deps]
77
ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81"

src/data_utils.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ const REQUIRE = "(requires MLJBase to be loaded)"
66
errlight(s) = throw(InterfaceError("Only `MLJModelInterface` is loaded. " *
77
"Import `MLJBase` in order to use `$s`."))
88

9+
# ------------------------------------------------------------------------
10+
# categorical, note: not exported to avoid clashes; this is fine because
11+
# MLJBase loads CategoricalArrays and MLJ interfaces should use qualified
12+
# statements.
13+
14+
categorical(a...; kw...) = categorical(get_interface_mode(), a...; kw...)
15+
16+
categorical(::LightInterface, a...; kw...) = errlight("categorical")
17+
918
# ------------------------------------------------------------------------
1019
# matrix
1120

test/data_utils.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
@testset "categorical-light" begin
2+
setlight()
3+
x = 1:5
4+
@test_throws M.InterfaceError M.categorical(x)
5+
end
6+
@testset "categorical-full" begin
7+
setfull()
8+
M.categorical(::FI, a...; kw...) = categorical(a...; kw...)
9+
x = 1:5
10+
@test M.categorical(x) == categorical(x)
11+
end
12+
# ------------------------------------------------------------------------
113
@testset "matrix-light" begin
214
setlight()
315
X = ones(2,3)

0 commit comments

Comments
 (0)