Skip to content

Commit

Permalink
Merge pull request #62 from alan-turing-institute/dev
Browse files Browse the repository at this point in the history
Changes for 0.7.1
  • Loading branch information
ablaom authored Oct 21, 2019
2 parents 48e4346 + edacc6a commit 18d07f0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
9 changes: 6 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLJBase"
uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "0.7.0"
version = "0.7.1"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand All @@ -19,10 +19,13 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
CategoricalArrays = "<0.5.3, 0.7"
CSV = "0.5"
Distributions = "0.21.3"
Missings = "0.4.3"
OrderedCollections = "1.1"
Requires = "^0.5.2"
ScientificTypes = "0.2.0"
Tables = "<0.1.19, >= 0.2"
StatsBase = "0.32"
Tables = "<0.1.19, 0.2"
julia = "1"

[extras]
Expand Down
34 changes: 17 additions & 17 deletions src/metadata_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function docstring_ext(T; descr::String="")
model_name = MLJBase.name(T)
# the message to return
message = "$descr"
message *= "\n→ based on [$package_name]($package_url)"
message *= "\n→ do `@load $model_name` to use the model"
message *= "\n→ based on [$package_name]($package_url)."
message *= "\n→ do `@load $model_name pkg=\"$package_name\"` to use the model."
message *= "\n→ do `?$model_name` for documentation."
end

Expand All @@ -23,14 +23,14 @@ function metadata_pkg(T; name::String="unknown", uuid::String="unknown", url::St
julia::Union{Missing,Bool}=missing, license::String="unknown",
is_wrapper::Bool=false)
ex = quote
package_name(::Type{<:$T}) = $name
package_uuid(::Type{<:$T}) = $uuid
package_url(::Type{<:$T}) = $url
is_pure_julia(::Type{<:$T}) = $julia
package_license(::Type{<:$T}) = $license
is_wrapper(::Type{<:$T}) = $is_wrapper
MLJBase.package_name(::Type{<:$T}) = $name
MLJBase.package_uuid(::Type{<:$T}) = $uuid
MLJBase.package_url(::Type{<:$T}) = $url
MLJBase.is_pure_julia(::Type{<:$T}) = $julia
MLJBase.package_license(::Type{<:$T}) = $license
MLJBase.is_wrapper(::Type{<:$T}) = $is_wrapper
end
eval(ex)
parentmodule(T).eval(ex)
end

"""
Expand All @@ -43,15 +43,15 @@ function metadata_model(T; input=Unknown, target=Unknown,
output=Unknown, weights::Bool=false,
descr::String="", path::String="")
if isempty(path)
path = "MLJModels.$(package_name(T))_.$(name(T))"
path = "MLJModels.$(MLJBase.package_name(T))_.$(MLJBase.name(T))"
end
ex = quote
input_scitype(::Type{<:$T}) = $input
output_scitype(::Type{<:$T}) = $output
target_scitype(::Type{<:$T}) = $target
supports_weights(::Type{<:$T}) = $weights
docstring(::Type{<:$T}) = docstring_ext($T, descr=$descr)
load_path(::Type{<:$T}) = $path
MLJBase.input_scitype(::Type{<:$T}) = $input
MLJBase.output_scitype(::Type{<:$T}) = $output
MLJBase.target_scitype(::Type{<:$T}) = $target
MLJBase.supports_weights(::Type{<:$T}) = $weights
MLJBase.docstring(::Type{<:$T}) = MLJBase.docstring_ext($T; descr=$descr)
MLJBase.load_path(::Type{<:$T}) = $path
end
eval(ex)
parentmodule(T).eval(ex)
end
4 changes: 2 additions & 2 deletions test/metadata_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ infos = info_dict(FooRegressor)
@test infos[:is_pure_julia]
@test !infos[:is_wrapper]
@test infos[:docstring] == raw"""La di da
→ based on [FooRegressor](http://existentialcomics.com/)
→ do `@load FooRegressor` to use the model
→ based on [FooRegressor](http://existentialcomics.com/).
→ do `@load FooRegressor pkg="FooRegressor"` to use the model.
→ do `?FooRegressor` for documentation."""
@test infos[:name] == "FooRegressor"

Expand Down

0 comments on commit 18d07f0

Please sign in to comment.