@@ -39,30 +39,33 @@ __internal_oop(::JacFunctionWrapper{iip, oop}) where {iip, oop} = oop
39
39
(f:: JacFunctionWrapper{false, true, 3} )(u) = f. f (u)
40
40
41
41
function 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
42
44
fu = fu_ === nothing ? copy (u) : copy (fu_)
43
45
if t != = nothing
44
46
iip = static_hasmethod (f, typeof ((fu, u, p, t)))
45
47
oop = static_hasmethod (f, typeof ((u, p, t)))
46
48
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)
48
54
end
49
- return JacFunctionWrapper {iip, oop, 1, F, typeof(fu), typeof(p), typeof(t)} (f,
50
- fu, p, t)
51
55
elseif p != = nothing
52
56
iip = static_hasmethod (f, typeof ((fu, u, p)))
53
57
oop = static_hasmethod (f, typeof ((u, p)))
54
58
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)
56
64
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)
67
65
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)
68
71
end
0 commit comments