Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query current logger instead of global one (should fix #92) #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,20 @@ function GMMk(n::Int, x::DataOrMatrix{T}; kind=:diag, nInit::Int=50, nIter::Int=
xx = vcat(yy...)
end
end
min_level = Logging.min_enabled_level(global_logger())
if min_level ≤ Logging.Debug
loglevel = :iter

# Query info about the `current_logger` (not the global one),
# so that the user could choose a different logger:
#
# my_gmm = Logging.with_logger(Logging.NullLogger()) do GMM(...) end
min_level = Logging.min_enabled_level(Logging.current_logger())
loglevel = if min_level ≤ Logging.Debug
:iter
elseif min_level ≤ Logging.Info
loglevel = :final
:final
else
loglevel = :none
:none
end

km = Clustering.kmeans(xx'[:,:], n, maxiter=nInit, display = loglevel)
μ::Matrix{T} = km.centers'
if kind == :diag
Expand Down