Is `callback` really compatible with NonlinearProblem?

Hi everyone,

According to the documentation (Nonlinear Problems · NonlinearSolve.jl), “if you set a callback in the problem, then that callback will be added in every solve call”. So I tried to add a callback but nothing seems to happen, see the following example.

using NonlinearSolve

f(u, p) = u .* u .- p
u0 = [1.0, 1.0]
p = 2.0
prob = NonlinearProblem(f, u0, p; callback = x -> error("hello world"))
sol = solve(prob) # nothing special happens

condition(args...) = true
affect!(integrator) = error("hello world !")
cb = DiscreteCallback(condition, affect!;)
prob = NonlinearProblem(f, u0, p; callback = cb)
sol = solve(prob) # nothing special happens

I saw on discourse the use of termination_condition, do you recommend to tweak this callback to insert what I want to do and return a termination condition? Or should I use the step interface to take control of the iterations and insert my callback?

PS : I’m using NonlinearSolve version 4.12.0

Yeah, pretty sure that’s a doc bug. @ChrisRackauckas can you confirm?

yes that is a docs issue