-
Notifications
You must be signed in to change notification settings - Fork 19
Include state and kwargs... to callback
#56
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #56 +/- ##
==========================================
- Coverage 98.42% 98.39% -0.04%
==========================================
Files 6 6
Lines 191 187 -4
==========================================
- Hits 188 184 -4
Misses 3 3
Continue to review full report at Codecov.
|
|
I assume that I am a bit more reluctant with the keyword arguments though. They were not included on purpose and I think there are good reasons for keeping it this way. If we include them here, then every callback has to handle keyword arguments (most by just discarding |
About
|
Maybe it would make sense to use the iteration (or transducer) interface in this case. Of course, some of the defaults such as progress bars etc. would be lost (I don't know how important they are for you) but you would have direct access to all samples and could easily collect them, perform additional computations (also with the collection of samples), apply "callbacks" only in every n-th step etc.
Hmm I'm not sure what exactly you mean - are you referring to the fact that one should avoid to clse over non-constant global variables? In this case one can apply e.g. the
True, it's just a slightly more complex structure. But why make it more complex if it is not needed? In other places we actually reduced the number of positional and keyword arguments since they were not used and made the interface more complex. IMO it is good to keep the interface as simple as possible (but not simpler). Though maybe this does not apply to keyword arguments to the same extent as positional arguments since they can be dropped by developers quite easily in the implementation with the catch-all |
|
I think it kind of depends on how powerful we want the callbacks to be. The current format is rigorous and simple, but not as extensible as if keyword arguments were included. I'm on the side of adding keyword arguments mostly because devs are going to have to make a change anyway to accommodate the That said, I'm sympathetic to the argument that that is kind of an annoying thing to do if you are writing a quick-and-dirty callback function. Maybe we can catch this internally and allow both forms. Is there a robust way to check if the signature of the callback accepts keyword arguments, other than |
|
I find the callback problem generally so annoying! I was thinking: how about passing everything via keywords arguments? [EDIT cause writing faster than thinking] : This would not allow any multiple dispatch for the callback functions but this could be eventually done internally: |
|
Just to rejuvenate this discussion: I also want
And this is why I'm pro kwargs despite slight increase in complexity. Current moving AHMC over to AMCMC interface, and I think we want to continue using the process tracking that already exists in AHMC (due to additional information provided). AFAIK it's easiest to implement this is as a Of course, all of this is easy to implement using the iterator or transducer interface, but IMO it's somewhat breaking with "user expectation": I very much expected EDIT: Ughh, I also need |
|
Okay, I think I'm perfectly happy to add keyword arguments.
Yeah, I think this is a non-negotiable add -- |
|
@theogf could you bump the version to 3.0, since this will be very breaking? |
|
Nevermind, I changed the version myself. |
Following #55 ,
stateandkwargs...are passed to thecallbackfunction.