Skip to content

Commit 813ba0c

Browse files
committed
tweak docstrings, error message, and add test
1 parent b4f7fb2 commit 813ba0c

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/machines.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,10 @@ function save(file::Union{String,IO}, mach::Machine)
10891089
end
10901090

10911091
const ERR_INVALID_DEFAULT_LOGGER = ArgumentError(
1092-
"`default_logger()` is currently `nothing`. "*
1093-
"Either specify an explicit path or stream as "*
1094-
"target of the save, or use `default_logger(logger)` "*
1092+
"You have attempted to save a machine to the default logger "*
1093+
"but `default_logger()` is currently `nothing`. "*
1094+
"Either specify an explicit logger, path or stream to save to, "*
1095+
"or use `default_logger(logger)` "*
10951096
"to change the default logger. "
10961097
)
10971098

src/resampling.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ const DOC_DEFAULT_LOGGER =
760760
761761
!!! note
762762
763-
In MLJ version prior to 0.21 the default logger is always `nothing`.
763+
Prior to MLJ v0.20.7 (and MLJBase 1.5) the default logger was always `nothing`.
764764
765765
"""
766766

test/resampling.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,4 +932,21 @@ end
932932
end
933933
end
934934

935+
# DUMMY LOGGER
936+
937+
struct DummyLogger end
938+
939+
MLJBase.save(logger::DummyLogger, mach::Machine) = mach.model
940+
941+
@testset "default logger" begin
942+
@test isnothing(default_logger())
943+
model = ConstantClassifier()
944+
mach = machine(model, make_moons(10)...)
945+
fit!(mach, verbosity=0)
946+
@test_throws MLJBase.ERR_INVALID_DEFAULT_LOGGER MLJBase.save(mach)
947+
default_logger(DummyLogger())
948+
@test default_logger() == DummyLogger()
949+
@test MLJBase.save(mach) == model
950+
end
951+
935952
true

0 commit comments

Comments
 (0)