Skip to content

Commit

Permalink
Merge pull request #936 from JuliaAI/patch9
Browse files Browse the repository at this point in the history
Add test for display of hyper-parameter ranges and models
  • Loading branch information
ablaom authored Sep 25, 2023
2 parents 38439f9 + f45eeeb commit 36ef770
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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.21.14"
version = "1.0.0"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
11 changes: 11 additions & 0 deletions test/hyperparam/one_dimensional_ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,16 @@ end
range(any1, :any, lower=1, upper=10))
end

@testset "coverage" begin
io = IOBuffer()
r1 = range(Int, :junk, lower=1, upper=10)
r2 = range(Char, :junk, values=['c', 'd'])
show(io, r1)
@test String(take!(io)) == "NumericRange(1 ≤ junk ≤ 10; origin=5.5, unit=4.5)"
show(io, r2)
@test String(take!(io)) == "NominalRange(junk = c, d)"
close(io)
end

end
true
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include("preliminaries.jl")
@conditional_testset "misc" begin
@test include("utilities.jl")
@test include("static.jl")
@test include("show.jl")
end

@conditional_testset "interface" begin
Expand Down
14 changes: 14 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using .Models

@testset "display of models" begin
io = IOBuffer()
show(io, KNNRegressor())
@test String(take!(io)) == "KNNRegressor(K = 5, …)"
show(io, MIME("text/plain"), KNNRegressor())
@test String(take!(io)) ==
"KNNRegressor(\n K = 5, \n algorithm = :kdtree, \n "*
"metric = Distances.Euclidean(0.0), \n leafsize = 10, \n "*
"reorder = true, \n weights = :uniform)"
end

true

0 comments on commit 36ef770

Please sign in to comment.