Skip to content

Commit 5abf86b

Browse files
Make verbose parameter default more robust for Julia LTS
Changed the default value of `verbose` from `true` to `LinearVerbosity()` to ensure type stability across all Julia versions without relying on constant propagation hints like `@constprop :aggressive`. This approach: - Works robustly on Julia LTS (1.10.x) and newer versions - Doesn't depend on compiler optimization hints - The default value is already the concrete type we want - Maintains full backward compatibility (still accepts Bool, Preset, etc.) The verbose processing logic was reordered to check for LinearVerbosity first (the common case) for optimal performance.
1 parent c4ce1de commit 5abf86b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/common.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm, arg
261261
__init(prob, alg, args...; kwargs...)
262262
end
263263

264-
Base.@constprop :aggressive function __init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm,
264+
function __init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm,
265265
args...;
266266
alias = LinearAliasSpecifier(),
267267
abstol = default_tol(real(eltype(prob.b))),
268268
reltol = default_tol(real(eltype(prob.b))),
269269
maxiters::Int = length(prob.b),
270-
verbose = true,
270+
verbose = LinearVerbosity(),
271271
Pl = nothing,
272272
Pr = nothing,
273273
assumptions = OperatorAssumptions(issquare(prob.A)),
@@ -324,7 +324,13 @@ Base.@constprop :aggressive function __init(prob::LinearProblem, alg::SciMLLinea
324324
copy(A)
325325
end
326326

327-
if verbose isa Bool
327+
if verbose isa LinearVerbosity
328+
verbose_spec = verbose
329+
init_cache_verb = verbose_spec
330+
elseif verbose isa SciMLLogging.AbstractVerbosityPreset
331+
verbose_spec = LinearVerbosity(verbose)
332+
init_cache_verb = verbose_spec
333+
elseif verbose isa Bool
328334
# @warn "Using `true` or `false` for `verbose` is being deprecated. Please use a `LinearVerbosity` type to specify verbosity settings.
329335
# For details see the verbosity section of the common solver options documentation page."
330336
init_cache_verb = verbose
@@ -333,10 +339,8 @@ Base.@constprop :aggressive function __init(prob::LinearProblem, alg::SciMLLinea
333339
else
334340
verbose_spec = LinearVerbosity(SciMLLogging.None())
335341
end
336-
elseif verbose isa SciMLLogging.AbstractVerbosityPreset
337-
verbose_spec = LinearVerbosity(verbose)
338-
init_cache_verb = verbose_spec
339342
else
343+
# Fallback for any other type
340344
verbose_spec = verbose
341345
init_cache_verb = verbose_spec
342346
end

0 commit comments

Comments
 (0)