@@ -39,30 +39,33 @@ __internal_oop(::JacFunctionWrapper{iip, oop}) where {iip, oop} = oop
3939(f:: JacFunctionWrapper{false, true, 3} )(u) = f. f (u)
4040
4141function JacFunctionWrapper (f:: F , fu_, u, p, t) where {F}
42+ # The warning instead of error ensures a non-breaking change for users relying on an
43+ # undefined / undocumented feature
4244 fu = fu_ === nothing ? copy (u) : copy (fu_)
4345 if t != = nothing
4446 iip = static_hasmethod (f, typeof ((fu, u, p, t)))
4547 oop = static_hasmethod (f, typeof ((u, p, t)))
4648 if ! iip && ! oop
47- throw (ArgumentError (" `f(u, p, t)` or `f(fu, u, p, t)` not defined for `f`" ))
49+ @warn """ `p` and `t` provided but `f(u, p, t)` or `f(fu, u, p, t)` not defined
50+ for `f`! Will fallback to `f(u)` or `f(fu, u)`.""" maxlog= 1
51+ else
52+ return JacFunctionWrapper {iip, oop, 1, F, typeof(fu), typeof(p), typeof(t)} (f,
53+ fu, p, t)
4854 end
49- return JacFunctionWrapper {iip, oop, 1, F, typeof(fu), typeof(p), typeof(t)} (f,
50- fu, p, t)
5155 elseif p != = nothing
5256 iip = static_hasmethod (f, typeof ((fu, u, p)))
5357 oop = static_hasmethod (f, typeof ((u, p)))
5458 if ! iip && ! oop
55- throw (ArgumentError (" `f(u, p)` or `f(fu, u, p)` not defined for `f`" ))
59+ @warn """ `p` provided but `f(u, p)` or `f(fu, u, p)` not defined for `f`! Will
60+ fallback to `f(u)` or `f(fu, u)`.""" maxlog= 1
61+ else
62+ return JacFunctionWrapper {iip, oop, 2, F, typeof(fu), typeof(p), typeof(t)} (f,
63+ fu, p, t)
5664 end
57- return JacFunctionWrapper {iip, oop, 2, F, typeof(fu), typeof(p), typeof(t)} (f,
58- fu, p, t)
59- else
60- iip = static_hasmethod (f, typeof ((fu, u)))
61- oop = static_hasmethod (f, typeof ((u,)))
62- if ! iip && ! oop
63- throw (ArgumentError (" `f(u)` or `f(fu, u)` not defined for `f`" ))
64- end
65- return JacFunctionWrapper {iip, oop, 3, F, typeof(fu), typeof(p), typeof(t)} (f,
66- fu, p, t)
6765 end
66+ iip = static_hasmethod (f, typeof ((fu, u)))
67+ oop = static_hasmethod (f, typeof ((u,)))
68+ ! iip && ! oop && throw (ArgumentError (" `f(u)` or `f(fu, u)` not defined for `f`" ))
69+ return JacFunctionWrapper {iip, oop, 3, F, typeof(fu), typeof(p), typeof(t)} (f,
70+ fu, p, t)
6871end
0 commit comments