-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add reset functions to evtools #1222
Conversation
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.
I got a little spooked adding a function with a vanilla name like
reset()
and wanted to get explicit about all of this in the code.
Makes sense.
We have to use some value for compartment; setting that to 1
Checking my understanding. The compartment is not explicitly set to 1 in reset, correct? It's just that it's left at the default value.
out2 <- mrgsim(mod, param = list(mode = 13)) | ||
expect_identical(as.data.frame(out1), as.data.frame(out2)) | ||
|
||
# Do an equivalent simulation with no evtools |
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.
Nice.
Yeah, that's right. The description I left was misleading on intent - I didn't have it clear in my own head at first. But now I think that's the only reasonable thing to do; and it's consistent with how Thanks for reviewing this. |
Summary
Trying to follow a similar pattern to what we do for replace, bolus and friends; this should (hopefully) all be natural / consistent riffing on the
evtools
machinery that is already in place.EVID 3
; it resets the entire PK system (all compartments)reset()
functions withself
as the first argument (the event is sent off right away, no return) and withoutself
as first argument (you get the object back, with opportunity to interact with it)reset()
with option to pass along dosing information; this isEVID 4
in NONMEM and mrgsolve; it resets the system and then dosesreset()
with dose, I'm tacking onrate
as an optional argument, defaulting to0
(or bolus); this is a slight difference from what we've done before in that we don't provide separate functions to reset and bolus or reset and infuseI also went back into some of the previously-developed functions and used explicit
evt::
references to functions inside theevtools
namespace. I got a little spooked adding a function with a vanilla name likereset()
and wanted to get explicit about all of this in the code.Tests
You can see from Files Changed that tests are in
inst/maintenance/unit-cpp/test-evtools.R
. This can be run withmake test-cpp
from the command line.The tests are a little tedious, trying to figure out when the system was reset and when there was a dose. I thought to run the equivalent simulation with no evtools involvement and verify results later on in the process; I think this is pretty compelling, but kept the more brute force tests anyway; probably still useful for catching something that might go wrong some day.