1- LinearSolve. @concrete struct LinearVerbosity{Enabled} < :
2- AbstractVerbositySpecifier{Enabled}
1+ LinearSolve. @concrete struct LinearVerbosity < :
2+ AbstractVerbositySpecifier
33 # Error control
44 default_lu_fallback
55 # Performance
@@ -19,12 +19,34 @@ LinearSolve.@concrete struct LinearVerbosity{Enabled} <:
1919 condition_number
2020end
2121
22- function LinearVerbosity {true} (;
23- # Error control defaults
22+ function LinearVerbosity (;
23+ error_control = nothing , performance = nothing , numerical = nothing , kwargs... )
24+ # Validate group arguments
25+ if error_control != = nothing && ! (error_control isa AbstractMessageLevel)
26+ throw (ArgumentError (" error_control must be a SciMLLogging.AbstractMessageLevel, got $(typeof (error_control)) " ))
27+ end
28+ if performance != = nothing && ! (performance isa AbstractMessageLevel)
29+ throw (ArgumentError (" performance must be a SciMLLogging.AbstractMessageLevel, got $(typeof (performance)) " ))
30+ end
31+ if numerical != = nothing && ! (numerical isa AbstractMessageLevel)
32+ throw (ArgumentError (" numerical must be a SciMLLogging.AbstractMessageLevel, got $(typeof (numerical)) " ))
33+ end
34+
35+ # Validate individual kwargs
36+ for (key, value) in kwargs
37+ if ! (key in error_control_options || key in performance_options ||
38+ key in numerical_options)
39+ throw (ArgumentError (" Unknown verbosity option: $key . Valid options are: $(tuple (error_control_options... , performance_options... , numerical_options... )) " ))
40+ end
41+ if ! (value isa AbstractMessageLevel)
42+ throw (ArgumentError (" $key must be a SciMLLogging.AbstractMessageLevel, got $(typeof (value)) " ))
43+ end
44+ end
45+
46+ # Build arguments using NamedTuple for type stability
47+ default_args = (
2448 default_lu_fallback = WarnLevel (),
25- # Performance defaults
2649 no_right_preconditioning = WarnLevel (),
27- # Numerical defaults
2850 using_iterative_solvers = WarnLevel (),
2951 using_IterativeSolvers = WarnLevel (),
3052 IterativeSolvers_iterations = WarnLevel (),
@@ -36,29 +58,32 @@ function LinearVerbosity{true}(;
3658 blas_invalid_args = WarnLevel (),
3759 blas_info = Silent (),
3860 blas_success = Silent (),
39- condition_number = Silent ())
40- LinearVerbosity {true} (default_lu_fallback, no_right_preconditioning,
41- using_iterative_solvers, using_IterativeSolvers,
42- IterativeSolvers_iterations, KrylovKit_verbosity,
43- KrylovJL_verbosity, HYPRE_verbosity, pardiso_verbosity,
44- blas_errors, blas_invalid_args, blas_info, blas_success, condition_number)
45- end
61+ condition_number = Silent ()
62+ )
4663
64+ # Apply group-level settings
65+ final_args = if error_control != = nothing || performance != = nothing ||
66+ numerical != = nothing
67+ NamedTuple {keys(default_args)} (
68+ _resolve_arg_value (
69+ key, default_args[key], error_control, performance, numerical)
70+ for key in keys (default_args)
71+ )
72+ else
73+ default_args
74+ end
4775
48- function LinearVerbosity {false} ()
49- LinearVerbosity {false} ( Silent (), Silent (),
50- Silent (), Silent (),
51- Silent (), Silent (),
52- Silent (), Silent (), Silent (),
53- Silent (), Silent (), Silent (), Silent (), Silent () )
76+ # Apply individual overrides
77+ if ! isempty (kwargs)
78+ final_args = merge (final_args, NamedTuple (kwargs))
79+ end
80+
81+ LinearVerbosity ( values (final_args) ... )
5482end
55- LinearVerbosity (enabled:: Bool ) = enabled ? LinearVerbosity {true} () : LinearVerbosity {false} ()
5683
57- function LinearVerbosity (verbose:: VerbosityPreset )
58- if verbose isa None
59- LinearVerbosity {false} ()
60- elseif verbose isa All
61- LinearVerbosity {true} (
84+ function LinearVerbosity (verbose:: AbstractVerbosityPreset )
85+ if verbose isa All
86+ LinearVerbosity (
6287 default_lu_fallback = InfoLevel (),
6388 no_right_preconditioning = InfoLevel (),
6489 using_iterative_solvers = InfoLevel (),
@@ -75,7 +100,7 @@ function LinearVerbosity(verbose::VerbosityPreset)
75100 condition_number = InfoLevel ()
76101 )
77102 elseif verbose isa Minimal
78- LinearVerbosity {true} (
103+ LinearVerbosity (
79104 default_lu_fallback = ErrorLevel (),
80105 no_right_preconditioning = Silent (),
81106 using_iterative_solvers = Silent (),
@@ -92,9 +117,9 @@ function LinearVerbosity(verbose::VerbosityPreset)
92117 condition_number = Silent ()
93118 )
94119 elseif verbose isa Standard
95- LinearVerbosity {true} () # Use default settings
120+ LinearVerbosity () # Use default settings
96121 elseif verbose isa Detailed
97- LinearVerbosity {true} (
122+ LinearVerbosity (
98123 default_lu_fallback = InfoLevel (),
99124 no_right_preconditioning = InfoLevel (),
100125 using_iterative_solvers = InfoLevel (),
@@ -111,70 +136,26 @@ function LinearVerbosity(verbose::VerbosityPreset)
111136 condition_number = InfoLevel ()
112137 )
113138 else
114- LinearVerbosity {true} () # Default fallback
139+ LinearVerbosity () # Default fallback
115140 end
116141end
117142
118- @inline function LinearVerbosity (verbose:: None )
119- LinearVerbosity {false} ()
120- end
121-
122- function LinearVerbosity (; error_control= nothing , performance= nothing , numerical= nothing , kwargs... )
123- # Validate group arguments
124- if error_control != = nothing && ! (error_control isa AbstractMessageLevel)
125- throw (ArgumentError (" error_control must be a SciMLLogging.AbstractMessageLevel, got $(typeof (error_control)) " ))
126- end
127- if performance != = nothing && ! (performance isa AbstractMessageLevel)
128- throw (ArgumentError (" performance must be a SciMLLogging.AbstractMessageLevel, got $(typeof (performance)) " ))
129- end
130- if numerical != = nothing && ! (numerical isa AbstractMessageLevel)
131- throw (ArgumentError (" numerical must be a SciMLLogging.AbstractMessageLevel, got $(typeof (numerical)) " ))
132- end
133-
134- # Validate individual kwargs
135- for (key, value) in kwargs
136- if ! (key in error_control_options || key in performance_options || key in numerical_options)
137- throw (ArgumentError (" Unknown verbosity option: $key . Valid options are: $(tuple (error_control_options... , performance_options... , numerical_options... )) " ))
138- end
139- if ! (value isa AbstractMessageLevel)
140- throw (ArgumentError (" $key must be a SciMLLogging.AbstractMessageLevel, got $(typeof (value)) " ))
141- end
142- end
143-
144- # Build arguments using NamedTuple for type stability
145- default_args = (
146- default_lu_fallback = WarnLevel (),
147- no_right_preconditioning = WarnLevel (),
148- using_iterative_solvers = WarnLevel (),
149- using_IterativeSolvers = WarnLevel (),
150- IterativeSolvers_iterations = WarnLevel (),
151- KrylovKit_verbosity = WarnLevel (),
152- KrylovJL_verbosity = Silent (),
153- HYPRE_verbosity = InfoLevel (),
154- pardiso_verbosity = Silent (),
155- blas_errors = WarnLevel (),
156- blas_invalid_args = WarnLevel (),
157- blas_info = Silent (),
158- blas_success = Silent (),
159- condition_number = Silent ()
160- )
161-
162- # Apply group-level settings
163- final_args = if error_control != = nothing || performance != = nothing || numerical != = nothing
164- NamedTuple {keys(default_args)} (
165- _resolve_arg_value (key, default_args[key], error_control, performance, numerical)
166- for key in keys (default_args)
167- )
168- else
169- default_args
170- end
171-
172- # Apply individual overrides
173- if ! isempty (kwargs)
174- final_args = merge (final_args, NamedTuple (kwargs))
175- end
176-
177- LinearVerbosity {true} (; final_args... )
143+ @inline function LinearVerbosity (verbose:: None )
144+ LinearVerbosity (
145+ Silent (),
146+ Silent (),
147+ Silent (),
148+ Silent (),
149+ Silent (),
150+ Silent (),
151+ Silent (),
152+ Silent (),
153+ Silent (),
154+ Silent (),
155+ Silent (),
156+ Silent (),
157+ Silent (),
158+ Silent ())
178159end
179160
180161# Helper function to resolve argument values based on group membership
@@ -234,36 +215,4 @@ function Base.getproperty(verbosity::LinearVerbosity, name::Symbol)
234215 # Fall back to default field access
235216 return getfield (verbosity, name)
236217 end
237- end
238-
239- function Base. show (io:: IO , verbosity:: LinearVerbosity{Enabled} ) where Enabled
240- if Enabled
241- println (io, " LinearVerbosity{true}:" )
242-
243- # Show error control group
244- println (io, " Error Control:" )
245- for opt in error_control_options
246- level = getfield (verbosity, opt)
247- level_name = typeof (level). name. name
248- println (io, " $opt : $level_name " )
249- end
250-
251- # Show performance group
252- println (io, " Performance:" )
253- for opt in performance_options
254- level = getfield (verbosity, opt)
255- level_name = typeof (level). name. name
256- println (io, " $opt : $level_name " )
257- end
258-
259- # Show numerical group
260- println (io, " Numerical:" )
261- for opt in numerical_options
262- level = getfield (verbosity, opt)
263- level_name = typeof (level). name. name
264- println (io, " $opt : $level_name " )
265- end
266- else
267- print (io, " LinearVerbosity{false} (all logging disabled)" )
268- end
269- end
218+ end
0 commit comments