Skip to content

Commit 462dd68

Browse files
committed
fix up the tests
1 parent 18e06b7 commit 462dd68

File tree

1 file changed

+91
-89
lines changed

1 file changed

+91
-89
lines changed

test/verbosity.jl

Lines changed: 91 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ using Test
66
@testset "Default constructor" begin
77
v1 = LinearVerbosity()
88
@test v1 isa LinearVerbosity{true}
9-
@test v1.default_lu_fallback isa SciMLLogging.Warn
10-
@test v1.KrylovKit_verbosity isa SciMLLogging.Warn
9+
@test v1.default_lu_fallback isa SciMLLogging.WarnLevel
10+
@test v1.KrylovKit_verbosity isa SciMLLogging.WarnLevel
1111
end
1212

1313
@testset "Bool constructor" begin
@@ -26,51 +26,51 @@ using Test
2626

2727
@test v3_none isa LinearVerbosity{false}
2828
@test v3_all isa LinearVerbosity{true}
29-
@test v3_all.default_lu_fallback isa SciMLLogging.Info
30-
@test v3_minimal.default_lu_fallback isa SciMLLogging.Error
29+
@test v3_all.default_lu_fallback isa SciMLLogging.InfoLevel
30+
@test v3_minimal.default_lu_fallback isa SciMLLogging.ErrorLevel
3131
@test v3_minimal.KrylovKit_verbosity isa SciMLLogging.Silent
3232
@test v3_standard isa LinearVerbosity{true}
33-
@test v3_detailed.KrylovKit_verbosity isa SciMLLogging.Warn
33+
@test v3_detailed.KrylovKit_verbosity isa SciMLLogging.WarnLevel
3434
end
3535

3636
@testset "Group-level keyword constructors" begin
37-
v4_error = LinearVerbosity(error_control = SciMLLogging.Error())
38-
@test v4_error.default_lu_fallback isa SciMLLogging.Error
37+
v4_error = LinearVerbosity(error_control = ErrorLevel())
38+
@test v4_error.default_lu_fallback isa SciMLLogging.ErrorLevel
3939

40-
v4_numerical = LinearVerbosity(numerical = SciMLLogging.Silent())
40+
v4_numerical = LinearVerbosity(numerical = Silent())
4141
@test v4_numerical.KrylovKit_verbosity isa SciMLLogging.Silent
4242
@test v4_numerical.using_IterativeSolvers isa SciMLLogging.Silent
4343
@test v4_numerical.pardiso_verbosity isa SciMLLogging.Silent
4444

45-
v4_performance = LinearVerbosity(performance = SciMLLogging.Info())
46-
@test v4_performance.no_right_preconditioning isa SciMLLogging.Info
45+
v4_performance = LinearVerbosity(performance = InfoLevel())
46+
@test v4_performance.no_right_preconditioning isa SciMLLogging.InfoLevel
4747
end
4848

4949
@testset "Mixed group and individual settings" begin
5050
v5_mixed = LinearVerbosity(
51-
numerical = SciMLLogging.Silent(),
52-
KrylovKit_verbosity = SciMLLogging.Warn(),
53-
performance = SciMLLogging.Info()
51+
numerical = Silent(),
52+
KrylovKit_verbosity = WarnLevel(),
53+
performance = InfoLevel()
5454
)
5555
# Individual override should take precedence
56-
@test v5_mixed.KrylovKit_verbosity isa SciMLLogging.Warn
56+
@test v5_mixed.KrylovKit_verbosity isa SciMLLogging.WarnLevel
5757
# Other numerical options should use group setting
5858
@test v5_mixed.using_IterativeSolvers isa SciMLLogging.Silent
5959
# Performance group setting should apply
60-
@test v5_mixed.no_right_preconditioning isa SciMLLogging.Info
60+
@test v5_mixed.no_right_preconditioning isa SciMLLogging.InfoLevel
6161
end
6262

6363
@testset "Individual keyword arguments" begin
6464
v6_individual = LinearVerbosity(
65-
default_lu_fallback = SciMLLogging.Error(),
66-
KrylovKit_verbosity = SciMLLogging.Info(),
67-
pardiso_verbosity = SciMLLogging.Silent()
65+
default_lu_fallback = ErrorLevel(),
66+
KrylovKit_verbosity = InfoLevel(),
67+
pardiso_verbosity = Silent()
6868
)
69-
@test v6_individual.default_lu_fallback isa SciMLLogging.Error
70-
@test v6_individual.KrylovKit_verbosity isa SciMLLogging.Info
69+
@test v6_individual.default_lu_fallback isa SciMLLogging.ErrorLevel
70+
@test v6_individual.KrylovKit_verbosity isa SciMLLogging.InfoLevel
7171
@test v6_individual.pardiso_verbosity isa SciMLLogging.Silent
7272
# Unspecified options should use defaults
73-
@test v6_individual.no_right_preconditioning isa SciMLLogging.Warn
73+
@test v6_individual.no_right_preconditioning isa SciMLLogging.WarnLevel
7474
end
7575

7676
@testset "Group classification functions" begin
@@ -83,12 +83,12 @@ using Test
8383
end
8484

8585
@testset "Group options function" begin
86-
v8 = LinearVerbosity(numerical = SciMLLogging.Warn())
86+
v8 = LinearVerbosity(numerical = WarnLevel())
8787
numerical_opts = group_options(v8, :numerical)
8888
@test numerical_opts isa NamedTuple
8989
@test :KrylovKit_verbosity in keys(numerical_opts)
9090
@test :using_IterativeSolvers in keys(numerical_opts)
91-
@test numerical_opts.KrylovKit_verbosity isa SciMLLogging.Warn
91+
@test numerical_opts.KrylovKit_verbosity isa SciMLLogging.WarnLevel
9292

9393
error_opts = group_options(v8, :error_control)
9494
@test :default_lu_fallback in keys(error_opts)
@@ -132,41 +132,41 @@ using Test
132132
@test :using_IterativeSolvers in keys(numerical_group)
133133
@test :pardiso_verbosity in keys(numerical_group)
134134

135-
# Test values are LogLevel types
136-
@test error_group.default_lu_fallback isa SciMLLogging.LogLevel
137-
@test performance_group.no_right_preconditioning isa SciMLLogging.LogLevel
138-
@test numerical_group.KrylovKit_verbosity isa SciMLLogging.LogLevel
135+
# Test values are MessageLevel types
136+
@test error_group.default_lu_fallback isa SciMLLogging.MessageLevel
137+
@test performance_group.no_right_preconditioning isa SciMLLogging.MessageLevel
138+
@test numerical_group.KrylovKit_verbosity isa SciMLLogging.MessageLevel
139139

140140
# Individual field access should still work
141-
@test v.default_lu_fallback isa SciMLLogging.Warn
142-
@test v.KrylovKit_verbosity isa SciMLLogging.Warn
141+
@test v.default_lu_fallback isa SciMLLogging.WarnLevel
142+
@test v.KrylovKit_verbosity isa SciMLLogging.WarnLevel
143143
end
144144

145145
@testset "Group setproperty! setting" begin
146146
v = LinearVerbosity()
147147

148148
# Test setting entire error_control group
149-
v.error_control = SciMLLogging.Error()
150-
@test v.default_lu_fallback isa SciMLLogging.Error
149+
v.error_control = ErrorLevel()
150+
@test v.default_lu_fallback isa SciMLLogging.ErrorLevel
151151

152152
# Test setting entire performance group
153-
v.performance = SciMLLogging.Info()
154-
@test v.no_right_preconditioning isa SciMLLogging.Info
153+
v.performance = InfoLevel()
154+
@test v.no_right_preconditioning isa SciMLLogging.InfoLevel
155155

156156
# Test setting entire numerical group
157-
v.numerical = SciMLLogging.Silent()
157+
v.numerical = Silent()
158158
@test v.KrylovKit_verbosity isa SciMLLogging.Silent
159159
@test v.using_IterativeSolvers isa SciMLLogging.Silent
160160
@test v.pardiso_verbosity isa SciMLLogging.Silent
161161
@test v.HYPRE_verbosity isa SciMLLogging.Silent
162162

163163
# Test that other groups aren't affected
164-
@test v.default_lu_fallback isa SciMLLogging.Error # error_control unchanged
165-
@test v.no_right_preconditioning isa SciMLLogging.Info # performance unchanged
164+
@test v.default_lu_fallback isa SciMLLogging.ErrorLevel # error_control unchanged
165+
@test v.no_right_preconditioning isa SciMLLogging.InfoLevel # performance unchanged
166166

167167
# Test individual setting still works after group setting
168-
v.KrylovKit_verbosity = SciMLLogging.Warn()
169-
@test v.KrylovKit_verbosity isa SciMLLogging.Warn
168+
v.KrylovKit_verbosity = WarnLevel()
169+
@test v.KrylovKit_verbosity isa SciMLLogging.WarnLevel
170170
# Other numerical options should still be Silent
171171
@test v.using_IterativeSolvers isa SciMLLogging.Silent
172172
end
@@ -188,59 +188,61 @@ using Test
188188
v = LinearVerbosity()
189189

190190
# Set a group and verify getproperty reflects the change
191-
v.numerical = SciMLLogging.Error()
191+
v.numerical = ErrorLevel()
192192
numerical_group = v.numerical
193193

194-
@test all(x -> x isa SciMLLogging.Error, values(numerical_group))
194+
@test all(x -> x isa SciMLLogging.ErrorLevel, values(numerical_group))
195195

196196
# Set individual option and verify both individual and group access work
197-
v.KrylovKit_verbosity = SciMLLogging.Info()
198-
@test v.KrylovKit_verbosity isa SciMLLogging.Info
197+
v.KrylovKit_verbosity = InfoLevel()
198+
@test v.KrylovKit_verbosity isa SciMLLogging.InfoLevel
199199

200200
updated_numerical = v.numerical
201-
@test updated_numerical.KrylovKit_verbosity isa SciMLLogging.Info
201+
@test updated_numerical.KrylovKit_verbosity isa SciMLLogging.InfoLevel
202202
# Other numerical options should still be Error
203-
@test updated_numerical.using_IterativeSolvers isa SciMLLogging.Error
203+
@test updated_numerical.using_IterativeSolvers isa SciMLLogging.ErrorLevel
204204
end
205205
end
206206

207207

208-
A = [1.0 0 0 0
209-
0 1 0 0
210-
0 0 1 0
211-
0 0 0 0]
212-
b = rand(4)
213-
prob = LinearProblem(A, b)
208+
@testset "LinearVerbosity Logs Tests" begin
209+
A = [1.0 0 0 0
210+
0 1 0 0
211+
0 0 1 0
212+
0 0 0 0]
213+
b = rand(4)
214+
prob = LinearProblem(A, b)
214215

215-
@test_logs (:warn,
216-
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
217-
prob,
218-
verbose = LinearVerbosity(default_lu_fallback = SciMLLogging.Warn()))
216+
@test_logs (:warn,
217+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
218+
prob,
219+
verbose = LinearVerbosity(default_lu_fallback = WarnLevel()))
219220

220-
@test_logs (:warn,
221-
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
222-
prob, verbose = true)
221+
@test_logs (:warn,
222+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
223+
prob, verbose = true)
223224

224-
@test_logs min_level=SciMLLogging.Logging.Warn solve(prob, verbose = false)
225+
@test_logs min_level=SciMLLogging.Logging.Warn solve(prob, verbose = false)
225226

226-
@test_logs (:info,
227-
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
228-
prob,
229-
verbose = LinearVerbosity(default_lu_fallback = SciMLLogging.Info()))
227+
@test_logs (:info,
228+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
229+
prob,
230+
verbose = LinearVerbosity(default_lu_fallback = InfoLevel()))
230231

231-
verb = LinearVerbosity(default_lu_fallback = SciMLLogging.Warn())
232+
verb = LinearVerbosity(default_lu_fallback = WarnLevel())
232233

233-
@test_logs (:warn,
234-
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
235-
prob,
236-
verbose = verb)
234+
@test_logs (:warn,
235+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
236+
prob,
237+
verbose = verb)
237238

238-
verb.default_lu_fallback = SciMLLogging.Info()
239+
verb.default_lu_fallback = InfoLevel()
239240

240-
@test_logs (:info,
241-
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
242-
prob,
243-
verbose = verb)
241+
@test_logs (:info,
242+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") solve(
243+
prob,
244+
verbose = verb)
245+
end
244246

245247
@testset "BLAS Return Code Interpretation" begin
246248
# Test interpretation of various BLAS return codes
@@ -285,7 +287,7 @@ verb.default_lu_fallback = SciMLLogging.Info()
285287
@test info[:memory_usage_MB] >= 0 # Memory can be 0 for very small matrices
286288

287289
# Test with condition number computation enabled via verbosity
288-
verbose_with_cond = LinearVerbosity(condition_number = SciMLLogging.Info())
290+
verbose_with_cond = LinearVerbosity(condition_number = InfoLevel())
289291
info_with_cond = LinearSolve.get_blas_operation_info(
290292
:dgetrf, A, b, condition = !isa(verbose_with_cond.condition_number, SciMLLogging.Silent))
291293
@test haskey(info_with_cond, :condition_number)
@@ -331,9 +333,9 @@ end
331333
prob_good = LinearProblem(A_good, b_good)
332334

333335
verbose_success = LinearVerbosity(
334-
blas_success = SciMLLogging.Info(),
335-
blas_errors = SciMLLogging.Silent(),
336-
blas_info = SciMLLogging.Silent()
336+
blas_success = InfoLevel(),
337+
blas_errors = Silent(),
338+
blas_info = Silent()
337339
)
338340

339341
@test_logs (:info, r"BLAS LU factorization.*completed successfully") solve(
@@ -345,40 +347,40 @@ end
345347
prob_singular = LinearProblem(A_singular, b_singular)
346348

347349
verbose_errors = LinearVerbosity(
348-
blas_errors = SciMLLogging.Warn(),
349-
blas_success = SciMLLogging.Silent(),
350-
blas_info = SciMLLogging.Silent()
350+
blas_errors = WarnLevel(),
351+
blas_success = Silent(),
352+
blas_info = Silent()
351353
)
352354

353355
@test_logs (:warn, r"BLAS/LAPACK.*Matrix is singular") solve(
354356
prob_singular, BLISLUFactorization(); verbose = verbose_errors)
355357

356358
# Test with info logging enabled
357359
verbose_info = LinearVerbosity(
358-
blas_info = SciMLLogging.Info(),
359-
blas_errors = SciMLLogging.Info(),
360-
blas_success = SciMLLogging.Silent()
360+
blas_info = InfoLevel(),
361+
blas_errors = InfoLevel(),
362+
blas_success = Silent()
361363
)
362364

363365
@test_logs (:info, r"BLAS/LAPACK.*Matrix is singular") solve(
364366
prob_singular, BLISLUFactorization(); verbose = verbose_info)
365367

366368
# Test with all BLAS logging disabled - should produce no logs
367369
verbose_silent = LinearVerbosity(
368-
blas_errors = SciMLLogging.Silent(),
369-
blas_invalid_args = SciMLLogging.Silent(),
370-
blas_info = SciMLLogging.Silent(),
371-
blas_success = SciMLLogging.Silent()
370+
blas_errors = Silent(),
371+
blas_invalid_args = Silent(),
372+
blas_info = Silent(),
373+
blas_success = Silent()
372374
)
373375

374376
@test_logs min_level=SciMLLogging.Logging.Warn solve(
375377
prob_singular, BLISLUFactorization(); verbose = verbose_silent)
376378

377379
# Test condition number logging if enabled
378380
verbose_with_cond = LinearVerbosity(
379-
condition_number = SciMLLogging.Info(),
380-
blas_success = SciMLLogging.Info(),
381-
blas_errors = SciMLLogging.Silent()
381+
condition_number = InfoLevel(),
382+
blas_success = InfoLevel(),
383+
blas_errors = Silent()
382384
)
383385

384386
@test_logs (:info, r"Matrix condition number:.*for.*matrix") match_mode=:any solve(

0 commit comments

Comments
 (0)