Open Technici4n opened 3 hours ago
To me the issue is bigger than one missing method: you are trying to use ForwardDiff in a setting where it is not meant to work. As the docstring of ForwardDiff.derivative
clearly states,
This method assumes that
isa(f(x), Union{Real,AbstractArray})
.
Thus, even if you add this method, calling derivative
with non-array outputs will be outside of the public API. It won't necessarily be tested, and it will be vulnerable to breaking even between patch versions. That is, unless the API is extended, but I'm not sure it's worth it to open such a can of worms?
The following code works:
But this code:
Leads to a runtime error:
Adding the following line fixes this problem: