-
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 replace() function to evtools #1203
Conversation
@@ -49,7 +49,7 @@ struct resim { | |||
}; | |||
|
|||
struct evdata { | |||
evdata(double a_, int b_) : time(a_), evid(b_) { | |||
evdata(double a_, int b_) : time(a_), evid(b_) { |
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.
Just a lint.
@@ -34,6 +34,21 @@ void infuse(databox& self, const double amt, const int cmt, const double rate) { | |||
return; | |||
} | |||
|
|||
mrgsolve::evdata replace(const double amt, const int cmt) { | |||
mrgsolve::evdata ev(0, 8); |
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.
The signature for the constructor is time
and evid
. We use 8
here because that signals to zero out the compartment and add the new amount. The time
value (0) is arbitrary b/c we'll set the object to get implemented now
later on.
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
after <- filter(a, time >= 5) | ||
expect_true(all(after$C==50)) | ||
|
||
#' When the replacement is timed into the future, we see the |
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.
extreme nit-pick: I think it'd be better to use plain comments rather than roxygen-style ones. (I've been allergic to unnecessary roxygen-style comments ever since I spent time debugging this issue.)
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.
Thanks, @kyleam; I reverted the comments and will try to stick to plain R comments going forward (I think I do most of the time, but I'm sure there's tons of #'
comments in the code too.)
Summary
To date, the
evtools
plugin has been able to quickly create and give doses given asbolus()
orinfuse()
.This PR implements an equivalent function to
replace()
the amount in a specific compartment with a new amount. This is accomplished viaevid 8
(already-existing functionality).The basic setup is similar to
bolus()
andinfuse()
: we provide two overloadedreplace()
functions, one that gets theself
object first (this will create and "send" the dose in one function call) and anotherreplace()
function that will create the object and return it to the user for further config.