Skip to content

Commit a78c7a6

Browse files
committed
Make the printing of the cache more readable
1 parent 128e353 commit a78c7a6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/abstract_types.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,17 @@ Abstract Type for all NonlinearSolve.jl Caches.
202202
abstract type AbstractNonlinearSolveCache{iip, timeit} end
203203

204204
function SymbolicIndexingInterface.symbolic_container(cache::AbstractNonlinearSolveCache)
205-
cache.prob
205+
return cache.prob
206206
end
207207
function SymbolicIndexingInterface.parameter_values(cache::AbstractNonlinearSolveCache)
208-
parameter_values(symbolic_container(cache))
208+
return parameter_values(symbolic_container(cache))
209209
end
210210
function SymbolicIndexingInterface.state_values(cache::AbstractNonlinearSolveCache)
211-
state_values(symbolic_container(cache))
211+
return state_values(symbolic_container(cache))
212212
end
213213

214214
function Base.getproperty(cache::AbstractNonlinearSolveCache, sym::Symbol)
215-
if sym == :ps
216-
return ParameterIndexingProxy(cache)
217-
end
215+
sym == :ps && return ParameterIndexingProxy(cache)
218216
return getfield(cache, sym)
219217
end
220218

@@ -230,10 +228,16 @@ function __show_cache(io::IO, cache::AbstractNonlinearSolveCache, indent = 0)
230228
println(io, "$(nameof(typeof(cache)))(")
231229
__show_algorithm(io, cache.alg,
232230
(" "^(indent + 4)) * "alg = " * string(get_name(cache.alg)), indent + 4)
233-
println(io, ",")
234-
println(io, (" "^(indent + 4)) * "u = ", get_u(cache), ",")
235-
println(io, (" "^(indent + 4)) * "residual = ", get_fu(cache), ",")
236-
println(io, (" "^(indent + 4)) * "inf-norm(residual) = ", norm(get_fu(cache), Inf), ",")
231+
232+
ustr = sprint(show, get_u(cache); context=(:compact=>true, :limit=>true))
233+
println(io, ",\n" * (" "^(indent + 4)) * "u = $(ustr),")
234+
235+
residstr = sprint(show, get_fu(cache); context=(:compact=>true, :limit=>true))
236+
println(io, (" "^(indent + 4)) * "residual = $(residstr),")
237+
238+
normstr = sprint(show, norm(get_fu(cache), Inf); context=(:compact=>true, :limit=>true))
239+
println(io, (" "^(indent + 4)) * "inf-norm(residual) = $(normstr),")
240+
237241
println(io, " "^(indent + 4) * "nsteps = ", cache.stats.nsteps, ",")
238242
println(io, " "^(indent + 4) * "retcode = ", cache.retcode)
239243
print(io, " "^(indent) * ")")

0 commit comments

Comments
 (0)