SciMLOperators.jl
SciMLOperators.jl copied to clipboard
Allowing `FunctionOperator`s with unspecified/unused parameters
Imagine we have a function g(op) -> FunctionOperator(...)
, which makes a function operator that uses op
. If op
has u/p/t dependence, we could accept these parameters in g
and thread them through to FunctionOperator
.
But it can be more ergonomic for op
to directly encode the dependence on u/p/t and for the implementation of g
to not even have to think about the existence of p
and t
. The following code would help achieve this:
function update_coefficients!(L::FunctionOperator, u, p, t)
ops = getops(L)
for op in ops
update_coefficients!(op, u, p, t)
end
# Allow p/t = nothing to indicate that the parameters are not used by the operator, and hence need not be stored.
(L.p !== nothing) && L.p = p
(L.t !== nothing) && L.t = t
nothing
end
This came up in the context of JacVec
from SparseDiffTools.jl. After discussion with @vpuri3, we've decided to hold off on this change since we can just thread the parameters through for now, but making an issue for the future.
Edit: L.op
already gets updated since it is part of getops(L)
, so only the unused param task is left -- updated issue title accordingly. Again, we're going to hold off on this for now