@@ -216,15 +216,18 @@ function Base.showerror(io::IO, e::FunctionArgumentsError)
216216end
217217
218218"""
219- isinplace(f, inplace_param_number[,fname="f"])
219+ isinplace(f, inplace_param_number, fname = "f", iip_preferred = true;
220+ has_two_dispatches = true,
221+ outofplace_param_number = inplace_param_number - 1)
220222 isinplace(f::AbstractSciMLFunction[, inplace_param_number])
221223
222224Check whether a function operates in place by comparing its number of arguments
223225to the expected number. If `f` is an `AbstractSciMLFunction`, then the type
224226parameter is assumed to be correct and is used. Otherwise `inplace_param_number`
225227is checked against the methods table, where `inplace_param_number` is the number
226228of arguments for the in-place dispatch. The out-of-place dispatch is assumed
227- to have one less. If neither of these dispatches exist, an error is thrown.
229+ to have `outofplace_param_number` parameters (one less than the inplace version
230+ by default). If neither of these dispatches exist, an error is thrown.
228231If the error is thrown, `fname` is used to tell the user which function has the
229232incorrect dispatches.
230233
@@ -238,22 +241,23 @@ form is disabled and the 2-argument signature is ensured to be matched.
238241
239242# See also
240243
241- - [`numargs`](@ref numargs)
244+ - [`numargs`](@ref numargs)
242245"""
243246function isinplace (f, inplace_param_number, fname = " f" , iip_preferred = true ;
244- has_two_dispatches = true , isoptimization = false )
247+ has_two_dispatches = true , isoptimization = false ,
248+ outofplace_param_number = inplace_param_number - 1 )
245249 nargs = numargs (f)
246250 iip_dispatch = any (x -> x == inplace_param_number, nargs)
247- oop_dispatch = any (x -> x == inplace_param_number - 1 , nargs)
251+ oop_dispatch = any (x -> x == outofplace_param_number , nargs)
248252
249253 if length (nargs) == 0
250254 throw (NoMethodsError (fname))
251255 end
252256
253257 if ! iip_dispatch && ! oop_dispatch && ! isoptimization
254- if all (x -> x > inplace_param_number, nargs)
258+ if all (> ( inplace_param_number) , nargs)
255259 throw (TooManyArgumentsError (fname, f))
256- elseif all (x -> x < inplace_param_number - 1 , nargs) && has_two_dispatches
260+ elseif all (< (outofplace_param_number) , nargs) && has_two_dispatches
257261 # Possible extra safety?
258262 # Find if there's a `f(args...)` dispatch
259263 # If so, no error
0 commit comments