-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate kwargs through update_coefficients! #143
Conversation
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
==========================================
+ Coverage 71.85% 72.58% +0.73%
==========================================
Files 11 11
Lines 1407 1430 +23
==========================================
+ Hits 1011 1038 +27
+ Misses 396 392 -4
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
454a346
to
7143793
Compare
I like the idea. We can simply pass AD-able parameters in |
You can go ahead and modify |
Would be good if you can modify the |
Sure, working on it |
Regarding SciML/DifferentialEquations.jl#881: there's still more design work to do in terms of how users can specify extra parameters, but yes hopefully this comes in handy. The nice thing about this PR is that it's very general. All it is doing is making SciMLOperators more flexible: if you want to use a SciMLOperator in a context where something else is expected beyond u/p/t, you can do it. It's still up to upstream projects how to use this flexibility: as one possibility, SciML-verse problems could take in an |
When you do modify function update_coeff...
for op in getops(L)
if !isnothing(op)
update_coefficients!(op, u, p, t; kw...)
end
end |
check now:) The construction is a bit awkward, because the |
@ChrisRackauckas ready for merge. The PR body, added docs+example, and #143 (comment) should give the relevant context if you want to give it a look over |
@ChrisRackauckas bumping this since it's a bit of a blocker for work on other operators (because the constructor style is changed slightly here), and for integration into OrdinaryDiffEq.jl. |
@ChrisRackauckas ping :) |
@vpuri3 I decided I want to finish and merge SciML/OrdinaryDiffEq.jl#1917 before this one, if that sounds good? So I can make sure I get the design right here 🙂 |
I want to revise the design I'll make the change in the next day or two! |
I guess I'm not getting this. Can't you pass arbitrary structs into kwargs anyway? What would the update_func(diag, u, p, t; NN = NN, x = x) = NN(p)(x)
L = DiagonalOperator(zeros(N); update_func = update_func)
# with this branch
L(u, p, t; x = x1, NN = NN1) # == NN1(x1) .* u
L(u, p, t; x = x2, NN = NN2) # == NN2(x2) .* u |
The But actually, I think I'm OK with the current approach in this PR. It does have its own benefits too, like doing the keyword filtering automatically for each op rather than having each op extract what it needs from the I am a little bit swamped with work right now but I've added you as a contributor on the branch if you'd like to resolve the conflicts before I get back to this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable enough to me.
great. we just gotta clean up FunctionOperator and this this is good to go. |
@ChrisRackauckas this is done. |
Resolves #125. For example usage, see the added test for a scalar operator.
I left function operator mostly alone because I don't understand some aspects of it, and from some of the other issues it seems it still might be in flux. More comprehensive tests can be added in a follow up PR, but note that this change is totally backwards compatible.(Addressed)For developers of this library, this is what you should know about the new design:
update_func
andaccepted_kwargs
arguments, and preprocess them using thepreprocess_update_func
utility before making the struct, as done here.update_func
has already been processed,accepted_kwargs
should be set toNoKwargFilter()
, which indicates that no kwarg filtering should be done.