Skip to content

Commit 939dbf9

Browse files
committed
use multiple dispatch for handling verbose kwarg
1 parent 8653c49 commit 939dbf9

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

lib/OrdinaryDiffEqCore/src/solve.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,7 @@ function SciMLBase.__init(
9696
error("This solver is not able to use mass matrices. For compatible solvers see https://docs.sciml.ai/DiffEqDocs/stable/solvers/dae_solve/")
9797
end
9898

99-
if verbose isa Bool
100-
if verbose
101-
verbose_spec = ODEVerbosity()
102-
else
103-
verbose_spec = ODEVerbosity(None())
104-
end
105-
elseif verbose isa AbstractVerbosityPreset
106-
verbose_spec = ODEVerbosity(verbose)
107-
else
108-
verbose_spec = verbose
109-
end
99+
verbose_spec = _process_verbose_param(verbose)
110100

111101
if alg isa OrdinaryDiffEqRosenbrockAdaptiveAlgorithm &&
112102
# https://github.com/SciML/OrdinaryDiffEq.jl/pull/2079 fixes this for Rosenbrock23 and 32

lib/OrdinaryDiffEqCore/src/verbosity.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,15 @@ end
364364
Silent()
365365
)
366366
end
367+
368+
const DEFAULT_VERBOSE = ODEVerbosity()
369+
370+
@inline function _process_verbose_param(verbose::SciMLLogging.AbstractVerbosityPreset)
371+
ODEVerbosity(verbose)
372+
end
373+
374+
@inline function _process_verbose_param(verbose::Bool)
375+
verbose ? DEFAULT_VERBOSE : ODEVerbosity(SciMLLogging.None())
376+
end
377+
378+
@inline _process_verbose_param(verbose::ODEVerbosity) = verbose

0 commit comments

Comments
 (0)