Skip to content

Commit dd09611

Browse files
Remove numargs usage
This just doesn't match the JuliaDiff style which is that the function call is defined by the function. I.e. out of place calls use out of place functions and in-place calls use in-place functions. This mixed it up which shouldn't be allowed in the API.
1 parent 25a276b commit dd09611

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

src/differentiation/vecjac_products.jl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
function _numargs(f)
2-
typ = Tuple{Any, Val{:analytic}, Vararg}
3-
typ2 = Tuple{Any, Type{Val{:analytic}}, Vararg} # This one is required for overloaded types
4-
typ3 = Tuple{Any, Val{:jac}, Vararg}
5-
typ4 = Tuple{Any, Type{Val{:jac}}, Vararg} # This one is required for overloaded types
6-
typ5 = Tuple{Any, Val{:tgrad}, Vararg}
7-
typ6 = Tuple{Any, Type{Val{:tgrad}}, Vararg} # This one is required for overloaded types
8-
numparam = maximum([(m.sig<:typ || m.sig<:typ2 || m.sig<:typ3 || m.sig<:typ4 || m.sig<:typ5 || m.sig<:typ6) ? 0 : num_types_in_tuple(m.sig) for m in methods(f)])
9-
return (numparam-1) #-1 in v0.5 since it adds f as the first parameter
10-
end
11-
12-
13-
#Get the number of parameters of a Tuple type, i.e. the number of fields.
14-
15-
function num_types_in_tuple(sig)
16-
length(sig.parameters)
17-
end
18-
19-
function num_types_in_tuple(sig::UnionAll)
20-
length(Base.unwrap_unionall(sig).parameters)
21-
end
22-
231
function num_vecjac!(
242
du,
253
f,
@@ -29,10 +7,6 @@ function num_vecjac!(
297
cache2 = similar(v);
308
compute_f0 = true,
319
)
32-
if _numargs(f) != 2
33-
du .= num_jacvec(f, x, v)
34-
return du
35-
end
3610
compute_f0 && (f(cache1, x))
3711
T = eltype(x)
3812
# Should it be min? max? mean?

0 commit comments

Comments
 (0)