-
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 support for etas attached to idata #1092
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.
Re-using all of the get_etas() code.
That worked out cleanly. Looks good to me.
src/dataobject.cpp
Outdated
for(int j = 0; j < n_eta; ++j) { | ||
if(eta_location[j] > 0) { | ||
if(eta_location[j] >= 0) { |
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 was confused at why this would be necessary for the idata
change. I reverted it (on top of c64ac9a) and tests still pass.
Looking more closely at the existing upstream code, eta_location
is the result of std::find
on the eta labels, so 0-based. By not considering j = 0
, it mishandles an eta column if it's the first column. So this is relevant for data
too and is an independent fix for a bug from gh-1037. Okay.
Fwiw here's a regression test that fails without the >
to >=
equal change:
test_that("etasrc works with ETA in first column", {
mod <- param(mod, mode = 0)
data <- expand.ev(amt = 100, ID = seq(4), cmt = 1)
data <- mutate(data, ETA1 = rev(ID) / 10)
data <- expand_observations(data, times = seq(5))
data <- mutate(data, cmt = 0)
set.seed(9812)
expect_identical(
mrgsim(mod, data, etasrc = "data"),
mrgsim(mod, select(data, "ETA1", everything()), etasrc = "data")
)
})
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; yes, I discovered this when creating the tests for this PR. I should have created another PR or at least written it up in the message. I'm going to revert this change and make it clean in a new PR in case this comes up in the future.
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 Kyle for providing this so fast. It should make things much easier and flexible. The code looks good to me.
Add on to #1037 ;
etasrc
can now beidata
idata.all
Re-using all of the
get_etas()
code.Checklist
etasrc = "idata"
oretasrc = "idata.all"
get_etas()
works withidata
object; one minor change to fill outStartrow
for idata sets.Discovered a bug when implementing #1092 where ETA was missed if it was in the first column of the data set. Please see #1095 for the fix.