From a87bf75e8473254e6d59f4b2a0f643d7f30eb4a0 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 31 May 2024 09:07:34 +1200 Subject: [PATCH 1/4] bump 1.10 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0987e1d..9c37054 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJModelInterface" uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" authors = ["Thibaut Lienart and Anthony Blaom"] -version = "1.9.6" +version = "1.10.0" [deps] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" From d27a4d73e20dc8d3a9eaf7c706295b413eb8de20 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 31 May 2024 09:09:12 +1200 Subject: [PATCH 2/4] bump [compat] StatisticalTraits = "3.4" --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9c37054..5b75333 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,7 @@ OrderedCollections = "1" Random = "<0.0.1, 1" ScientificTypes = "3" ScientificTypesBase = "3" -StatisticalTraits = "3.2" +StatisticalTraits = "3.4" Tables = "1" Test = "<0.0.1, 1" julia = "1.6" From 0d28a11b82b4b3a05eb2288a826818d754079a83 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Mon, 3 Jun 2024 16:11:44 +1200 Subject: [PATCH 3/4] fix [compat] StatisticalTraits = "3.3" --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5b75333..48278fb 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,7 @@ OrderedCollections = "1" Random = "<0.0.1, 1" ScientificTypes = "3" ScientificTypesBase = "3" -StatisticalTraits = "3.4" +StatisticalTraits = "3.3" Tables = "1" Test = "<0.0.1, 1" julia = "1.6" From 7a93b093dda9c3ada33f318e744139df3ff1bab3 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Mon, 3 Jun 2024 16:13:06 +1200 Subject: [PATCH 4/4] add constructor trait; base docstring fallback on this if u can --- src/MLJModelInterface.jl | 1 + src/model_traits.jl | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/MLJModelInterface.jl b/src/MLJModelInterface.jl index 6193110..244d141 100644 --- a/src/MLJModelInterface.jl +++ b/src/MLJModelInterface.jl @@ -33,6 +33,7 @@ const MODEL_TRAITS = [ :reports_feature_importances, :deep_properties, :reporting_operations, + :constructor, ] const ABSTRACT_MODEL_SUBTYPES = [ diff --git a/src/model_traits.jl b/src/model_traits.jl index 2269ecf..418cf30 100644 --- a/src/model_traits.jl +++ b/src/model_traits.jl @@ -13,10 +13,18 @@ const DeterministicDetector = Union{ const StatTraits = StatisticalTraits +# note that if F is a constructor, like `TunedModel`, then `docstring(F)` already falls +# back to the function's document string. function StatTraits.docstring(M::Type{<:Model}) - docstring = Base.Docs.doc(M) |> string + constructor = StatTraits.constructor(M) + # At time of writing, `constructor` is a new trait only overloaded for model wrappers + # that have multiple types associated with the same constructor (e.g., `TunedModel` is + # a constructor that can return objects of either `ProbabilisticTunedModel` or + # `DeterministicTunedModel` type. However, we want these bound to the same docstring. + C = isnothing(constructor) ? M : constructor + docstring = Base.Docs.doc(C) |> string if occursin("No documentation found", docstring) - docstring = synthesize_docstring(M) + docstring = synthesize_docstring(C) end return docstring end