Skip to content

Commit 0ac7245

Browse files
committed
add verbosity tests
1 parent d51c6e3 commit 0ac7245

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/verbosity.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@testitem "Nonlinear Verbosity" tags=[:misc] begin
2+
using IntervalNonlinearSolve
3+
using NonlinearSolve
4+
using NonlinearSolve: NonlinearVerbosity
5+
using LinearSolve: LinearVerbosity
6+
using SciMLVerbosity: SciMLVerbosity, Verbosity
7+
using Test
8+
using Logging
9+
10+
g(u, p) = u^2 - 4
11+
12+
int_prob = IntervalNonlinearProblem(g, (3.0, 5.0))
13+
14+
@test_logs (:info,
15+
"The interval is not an enclosing interval, opposite signs at the boundaries are required.") solve(
16+
int_prob,
17+
ITP(), verbose = NonlinearVerbosity(non_enclosing_interval = Verbosity.Info()))
18+
19+
@test_logs (:error,
20+
"The interval is not an enclosing interval, opposite signs at the boundaries are required.") solve(
21+
int_prob,
22+
ITP(), verbose = NonlinearVerbosity(non_enclosing_interval = Verbosity.Error()))
23+
24+
# Test that the linear verbosity is passed to the linear solve
25+
f(u, p) = [u[1]^2 - 2u[1] + 1, sum(u)]
26+
prob = NonlinearProblem(f, [1.0, 1.0])
27+
28+
@test_logs (:warn,
29+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") match_mode=:any solve(
30+
prob,
31+
verbose = NonlinearVerbosity())
32+
33+
@test_logs (:info,
34+
"LU factorization failed, falling back to QR factorization. `A` is potentially rank-deficient.") match_mode=:any solve(
35+
prob,
36+
verbose = NonlinearVerbosity(linear_verbosity = LinearVerbosity(default_lu_fallback = Verbosity.Info())))
37+
38+
# Test that caches get correct verbosities
39+
cache = init(prob, verbose = NonlinearVerbosity(threshold_state = Verbosity.Info()))
40+
41+
@test cache.verbose.numerical.threshold_state == Verbosity.Info()
42+
end

0 commit comments

Comments
 (0)