Skip to content

Commit

Permalink
add test for the warning in train_best=false case
Browse files Browse the repository at this point in the history
  • Loading branch information
ablaom committed Mar 3, 2024
1 parent 76f97a0 commit 62ede03
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/tuned_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,23 @@ end
models=fill(EphemeralRegressor(), 2),
measure=l2,
resampling=Holdout(),
train_best=false,
)
mach = machine(tmodel, X, y) |> fit!
mach = machine(tmodel, X, y)
fit!(mach, verbosity=0)
io = IOBuffer()
@test_logs(
(:warn, MLJBase.WARN_SERIALIZATION),
MLJBase.save(io, mach),
)
close(io)
tmodel.train_best = true
fit!(mach, verbosity=0)
io = IOBuffer()
MLJBase.save(io, mach)
@test_logs MLJBase.save(io, mach)
seekstart(io)
mach2 = machine(io)
close(io)
@test MLJBase.predict(mach2, (; x = rand(2))) fill(42.0, 2)
end

Expand Down

0 comments on commit 62ede03

Please sign in to comment.