Skip to content

Commit bd4fba9

Browse files
RomeoVChrisRackauckas
authored andcommitted
Make string interpolations lazy
This is to appease JET and get all the paths ready for trimming.
1 parent ec48b57 commit bd4fba9

File tree

10 files changed

+22
-19
lines changed

10 files changed

+22
-19
lines changed

ext/NonlinearSolvePETScExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function SciMLBase.__solve(
3535
end
3636

3737
if petsclibidx === nothing
38-
error("No compatible PETSc library found for element type $(T). Pass in a \
38+
error(lazy"No compatible PETSc library found for element type $(T). Pass in a \
3939
custom `petsclib` via `PETScSNES(; petsclib = <petsclib>, ....)`.")
4040
end
4141
petsclib = PETSc.petsclibs[petsclibidx]

ext/NonlinearSolveSIAMFANLEquationsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function siamfanlequations_retcode_mapping(sol)
1818
elseif sol.errcode == -1
1919
return ReturnCode.Default
2020
else
21-
error("Unknown SIAMFANLEquations return code: $(sol.errcode)")
21+
error(lazy"Unknown SIAMFANLEquations return code: $(sol.errcode)")
2222
end
2323
end
2424

lib/NonlinearSolveBase/src/abstract_types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function Base.show(io::IO, ::MIME"text/plain", cache::AbstractNonlinearSolveCach
336336
end
337337

338338
function show_nonlinearsolve_cache(io::IO, cache::AbstractNonlinearSolveCache, indent = 0)
339-
println(io, "$(nameof(typeof(cache)))(")
339+
println(io, lazy"$(nameof(typeof(cache)))(")
340340
show_nonlinearsolve_algorithm(
341341
io,
342342
cache.alg,

lib/NonlinearSolveBase/src/autodiff.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ function select_forward_mode_autodiff(
2323
if warn_check_mode && !(ADTypes.mode(ad) isa ADTypes.ForwardMode) &&
2424
!(ADTypes.mode(ad) isa ADTypes.ForwardOrReverseMode) &&
2525
!is_finite_differences_backend(ad)
26-
@warn "The chosen AD backend $(ad) is not a forward mode AD. Use with caution."
26+
@warn lazy"The chosen AD backend $(ad) is not a forward mode AD. Use with caution."
2727
end
2828
if incompatible_backend_and_problem(prob, ad)
2929
adₙ = select_forward_mode_autodiff(prob, nothing; warn_check_mode)
30-
@warn "The chosen AD backend `$(ad)` does not support the chosen problem. This \
30+
@warn lazy"The chosen AD backend `$(ad)` does not support the chosen problem. This \
3131
could be because the backend package for the chosen AD isn't loaded. After \
3232
running autodiff selection detected `$(adₙ)` as a potential forward mode \
3333
backend."
@@ -50,11 +50,11 @@ function select_reverse_mode_autodiff(
5050
if warn_check_mode && !(ADTypes.mode(ad) isa ADTypes.ReverseMode) &&
5151
!(ADTypes.mode(ad) isa ADTypes.ForwardOrReverseMode) &&
5252
!is_finite_differences_backend(ad)
53-
@warn "The chosen AD backend $(ad) is not a reverse mode AD. Use with caution."
53+
@warn lazy"The chosen AD backend $(ad) is not a reverse mode AD. Use with caution."
5454
end
5555
if incompatible_backend_and_problem(prob, ad)
5656
adₙ = select_reverse_mode_autodiff(prob, nothing; warn_check_mode)
57-
@warn "The chosen AD backend `$(ad)` does not support the chosen problem. This \
57+
@warn lazy"The chosen AD backend `$(ad)` does not support the chosen problem. This \
5858
could be because the backend package for the chosen AD isn't loaded. After \
5959
running autodiff selection detected `$(adₙ)` as a potential reverse mode \
6060
backend."
@@ -75,7 +75,7 @@ end
7575
function select_jacobian_autodiff(prob::AbstractNonlinearProblem, ad::AbstractADType)
7676
if incompatible_backend_and_problem(prob, ad)
7777
adₙ = select_jacobian_autodiff(prob, nothing)
78-
@warn "The chosen AD backend `$(ad)` does not support the chosen problem. This \
78+
@warn lazy"The chosen AD backend `$(ad)` does not support the chosen problem. This \
7979
could be because the backend package for the chosen AD isn't loaded. After \
8080
running autodiff selection detected `$(adₙ)` as a potential jacobian \
8181
backend."

lib/NonlinearSolveBase/src/descent/damped_newton.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function InternalAPI.solve!(
215215
end
216216
b = cache.Jᵀfu_cache
217217
else
218-
error("Unknown Mode: $(cache.mode).")
218+
error(lazy"Unknown Mode: $(cache.mode).")
219219
end
220220
end
221221

lib/NonlinearSolveBase/src/jacobian.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function construct_concrete_adtype(f::NonlinearFunction, ad::AbstractADType)
234234
else
235235
if sparse_or_structured_prototype(f.jac_prototype)
236236
if !(sparsity_detector isa NoSparsityDetector)
237-
@warn "`jac_prototype` is a sparse matrix but sparsity = $(f.sparsity) \
237+
@warn lazy"`jac_prototype` is a sparse matrix but sparsity = $(f.sparsity) \
238238
has also been specified. Ignoring sparsity field and using \
239239
`jac_prototype` sparsity."
240240
end
@@ -248,7 +248,7 @@ function construct_concrete_adtype(f::NonlinearFunction, ad::AbstractADType)
248248
end
249249

250250
function construct_concrete_adtype(::NonlinearFunction, ad::AutoSparse)
251-
error("Specifying a sparse AD type for Nonlinear Problems was removed in v4. \
251+
error(lazy"Specifying a sparse AD type for Nonlinear Problems was removed in v4. \
252252
Instead use the `sparsity`, `jac_prototype`, and `colorvec` to specify \
253253
the right sparsity pattern and coloring algorithm. Ignoring the sparsity \
254254
detection algorithm and coloring algorithm present in $(ad).")

lib/NonlinearSolveBase/src/polyalg.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ function Base.show(io::IO, ::MIME"text/plain", cache::NonlinearSolvePolyAlgorith
9292
println(io, "NonlinearSolvePolyAlgorithmCache with \
9393
$(Utils.unwrap_val(cache.static_length)) algorithms:")
9494
best_alg = ifelse(cache.best == -1, "nothing", cache.best)
95-
println(io, " Best Algorithm: $(best_alg)")
95+
println(io, lazy" Best Algorithm: $(best_alg)")
9696
println(
97-
io, " Current Algorithm: [$(cache.current) / $(Utils.unwrap_val(cache.static_length))]"
97+
io, lazy" Current Algorithm: [$(cache.current) / $(Utils.unwrap_val(cache.static_length))]"
9898
)
99-
println(io, " nsteps: $(cache.nsteps)")
100-
println(io, " retcode: $(cache.retcode)")
99+
println(io, lazy" nsteps: $(cache.nsteps)")
100+
println(io, lazy" retcode: $(cache.retcode)")
101101
print(io, " Current Cache: ")
102102
NonlinearSolveBase.show_nonlinearsolve_cache(io, cache.caches[cache.current], 4)
103103
end

lib/NonlinearSolveBase/src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222

2323
function Base.convert(::Type{AbstractArray}, A::Pinv)
2424
hasmethod(pinv, Tuple{typeof(A.J)}) && return pinv(A.J)
25-
@warn "`pinv` not defined for $(typeof(A.J)). Jacobian will not be inverted when \
25+
@warn lazy"`pinv` not defined for $(typeof(A.J)). Jacobian will not be inverted when \
2626
tracing." maxlog=1
2727
return A.J
2828
end

lib/NonlinearSolveBase/src/wrappers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function assert_extension_supported_termination_condition(
44
no_termination_condition = termination_condition === nothing
55
no_termination_condition && return nothing
66
abs_norm_supported && termination_condition isa AbsNormTerminationMode && return nothing
7-
throw(AssertionError("`$(nameof(typeof(alg)))` does not support termination conditions!"))
7+
throw(AssertionError(lazy"`$(nameof(typeof(alg)))` does not support termination conditions!"))
88
end
99

1010
function construct_extension_function_wrapper(

lib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ function SciPyLeastSquares(; method::String = "trf", loss::String = "linear")
4343
valid_methods = ("trf", "dogbox", "lm")
4444
valid_losses = ("linear", "soft_l1", "huber", "cauchy", "arctan")
4545
method in valid_methods ||
46-
throw(ArgumentError("Invalid method: $method. Valid methods are: $(join(valid_methods, ", "))"))
46+
throw(ArgumentError(
47+
lazy"Invalid method: $method. Valid methods are: $(join(valid_methods, ", "))"))
4748
loss in valid_losses ||
48-
throw(ArgumentError("Invalid loss: $loss. Valid loss functions are: $(join(valid_losses, ", "))"))
49+
throw(ArgumentError(
50+
lazy"Invalid loss: $loss. Valid loss functions are: $(join(valid_losses, ",
51+
"))"))
4952
return SciPyLeastSquares(method, loss, :SciPyLeastSquares)
5053
end
5154

0 commit comments

Comments
 (0)