Skip to content

Commit 4464595

Browse files
authored
Merge pull request #221 from JuliaAI/dev
For a 1.12 release
2 parents 00d8eea + 86a9845 commit 4464595

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name = "MLJModelInterface"
22
uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
33
authors = ["Thibaut Lienart and Anthony Blaom"]
4-
version = "1.11.1"
4+
version = "1.12.0"
55

66
[deps]
7+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
78
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
89
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
910
ScientificTypesBase = "30f210dd-8aff-4c5f-94ba-8e64358c1161"
@@ -21,7 +22,7 @@ REPL = "<0.0.1, 1"
2122
Random = "<0.0.1, 1"
2223
ScientificTypes = "3"
2324
ScientificTypesBase = "3"
24-
StatisticalTraits = "3.4"
25+
StatisticalTraits = "3.5"
2526
Tables = "1"
2627
Test = "<0.0.1, 1"
2728
julia = "1.6"

src/MLJModelInterface.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const MODEL_TRAITS = [
2222
:docstring,
2323
:name,
2424
:human_name,
25+
:tags,
2526
:is_supervised,
2627
:prediction_type,
2728
:abstract_type,
@@ -63,7 +64,8 @@ const ABSTRACT_MODEL_SUBTYPES = [
6364
using ScientificTypesBase
6465
using StatisticalTraits
6566
using Random
66-
using REPL # apparently needed to get Base.Docs.doc to work
67+
using InteractiveUtils
68+
using REPL # needed to get Base.Docs.doc to work
6769

6870
import StatisticalTraits: info
6971

src/equality.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Base.in(x::MLJType, itr::Set) = special_in(x, itr)
158158
Base.in(x::MLJType, itr::AbstractVector{<:MLJType}) = special_in(x, itr)
159159
Base.in(x::MLJType, itr::AbstractRange{<:MLJType}) = special_in(x, itr)
160160
Base.in(x::MLJType, itr::Tuple) = special_in(x, itr)
161+
Base.in(x::MLJType, itr::Tuple{(Any for _ in 1:32)..., Vararg{Any}}) = special_in(x, itr)
161162

162163
# A version of `in` that actually uses `==`:
163164

src/model_traits.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ function StatTraits.target_scitype(::Type{<:DeterministicDetector})
5050
return AbstractVector{<:Union{Missing, OrderedFactor{2}}}
5151
end
5252

53-
# implementation is deferred as it requires methodswith which depends upon
54-
# InteractiveUtils which we don't want to bring here as a dependency
55-
# (even if it's stdlib).
56-
implemented_methods(M::Type) = implemented_methods(get_interface_mode(), M)
53+
implemented_methods(M::Type) = getfield.(methodswith(M), :name) |> unique
5754
implemented_methods(model) = implemented_methods(typeof(model))
55+
56+
# can be removed in MLJModelInterface 2.0:
5857
implemented_methods(::LightInterface, M) = errlight("implemented_methods")
5958

6059
for M in ABSTRACT_MODEL_SUBTYPES

test/metadata_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ infos = Dict(trait => eval(:(MLJModelInterface.$trait))(FooRegressor) for
142142
@test infos[:hyperparameters] == (:a, :b)
143143
@test infos[:hyperparameter_types] == ("Int64", "Any")
144144
@test infos[:hyperparameter_ranges] == (nothing, nothing)
145-
@test !infos[:supports_training_losses]
145+
@test !infos[:supports_training_losses]
146146
@test !infos[:reports_feature_importances]
147147
end
148148

test/model_traits.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ bar(::P1) = nothing
3333
M.package_name(::Type{<:S1}) = "Sibelius"
3434
M.package_url(::Type{<:S1}) = "www.find_the_eighth.org"
3535
M.human_name(::Type{<:S1}) = "silly model"
36+
M.tags(::Type{<:S1}) = ["regression", "gradient descent"]
3637

3738
M.package_name(::Type{<:U1}) = "Bach"
3839
M.package_url(::Type{<:U1}) = "www.did_he_write_565.com"
@@ -103,6 +104,7 @@ M.input_scitype(::Type{<:SupervisedTransformer}) = Finite
103104

104105
@test name(ms) == "S1"
105106
@test human_name(ms) == "silly model"
107+
@test tags(ms) == ["regression", "gradient descent"]
106108

107109

108110
@test is_supervised(ms)
@@ -117,18 +119,14 @@ M.input_scitype(::Type{<:SupervisedTransformer}) = Finite
117119
@test hyperparameters(md) == (:a,)
118120
@test hyperparameter_types(md) == ("Int64",)
119121

120-
# implemented methods is deferred
121-
setlight()
122-
@test_throws M.InterfaceError implemented_methods(mp)
123-
124-
setfull()
122+
@test implemented_methods(ms) == [:clean!,]
125123

126124
@test Set(implemented_methods(mp)) == Set([:clean!,:bar,:foo])
127125

128-
@test fit_data_scitype(mu) == Tuple{Unknown};;;
126+
@test fit_data_scitype(mu) == Tuple{Unknown}
129127
@test fit_data_scitype(mu) == Tuple{Unknown}
130128
@test fit_data_scitype(supervised_transformer) == Tuple{Finite,Continuous}
131-
129+
132130
end
133131

134132
@testset "`_density` - helper for predict_scitype fallback" begin

0 commit comments

Comments
 (0)